Browse Source

Support multiple watchlist pages for Letterboxd

pull/7203/head
Hans van Luttikhuizen 8 years ago
parent
commit
5ba6901d00
  1. 27
      couchpotato/core/media/movie/providers/automation/letterboxd.py

27
couchpotato/core/media/movie/providers/automation/letterboxd.py

@ -13,7 +13,7 @@ autoload = 'Letterboxd'
class Letterboxd(Automation): class Letterboxd(Automation):
url = 'http://letterboxd.com/%s/watchlist/' url = 'http://letterboxd.com/%s/watchlist/page/%d/'
pattern = re.compile(r'(.*)\((\d*)\)') pattern = re.compile(r'(.*)\((\d*)\)')
interval = 1800 interval = 1800
@ -46,18 +46,29 @@ class Letterboxd(Automation):
if not enablers[index]: if not enablers[index]:
continue continue
soup = BeautifulSoup(self.getHTMLData(self.url % username)) soup = BeautifulSoup(self.getHTMLData(self.url % (username, 1)))
for movie in soup.find_all('li', attrs = {'class': 'poster-container'}): pagination_items = soup.find_all('li', attrs={'class': 'paginate-page'})
img = movie.find('img') pages = range(1, len(pagination_items) + 1) if pagination_items else [1]
title = img.get('alt')
movies.append({ for page in pages:
'title': title soup = BeautifulSoup(self.getHTMLData(self.url % (username, page)))
}) movies += self.getMoviesFromHTML(soup)
return movies return movies
def getMoviesFromHTML(self, html):
movies = []
for movie in html.find_all('li', attrs={'class': 'poster-container'}):
img = movie.find('img')
title = img.get('alt')
movies.append({
'title': title
})
return movies
config = [{ config = [{
'name': 'letterboxd', 'name': 'letterboxd',

Loading…
Cancel
Save