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

Loading…
Cancel
Save