Browse Source

Support multiple watchlist pages for Letterboxd

pull/7202/head
Hans van Luttikhuizen 8 years ago
parent
commit
adc0b4604a
  1. 26
      couchpotato/core/media/movie/providers/automation/letterboxd.py

26
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
@ -48,16 +48,28 @@ class Letterboxd(Automation):
soup = BeautifulSoup(self.getHTMLData(self.url % username))
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)))
# soup = BeautifulSoup(Plugin.urlopen(self, url=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