Make letterboxd multi-watchlist
This commit is contained in:
@@ -11,7 +11,7 @@ config = [{
|
||||
'list': 'watchlist_providers',
|
||||
'name': 'letterboxd_automation',
|
||||
'label': 'Letterboxd',
|
||||
'description': 'import movies from your <a href="http://letterboxd.com/">Letterboxd</a> watchlist',
|
||||
'description': 'Import movies from any public <a href="http://letterboxd.com/">Letterboxd</a> watchlist',
|
||||
'options': [
|
||||
{
|
||||
'name': 'automation_enabled',
|
||||
@@ -19,10 +19,16 @@ config = [{
|
||||
'type': 'enabler',
|
||||
},
|
||||
{
|
||||
'name': 'automation_username',
|
||||
'name': 'automation_urls_use',
|
||||
'label': 'Use',
|
||||
},
|
||||
{
|
||||
'name': 'automation_urls',
|
||||
'label': 'Username',
|
||||
'type': 'combined',
|
||||
'combine': ['automation_urls_use', 'automation_urls'],
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
}]
|
||||
}]
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
from bs4 import BeautifulSoup
|
||||
from couchpotato.core.helpers.variable import tryInt, splitString
|
||||
from couchpotato.core.logger import CPLog
|
||||
from couchpotato.core.providers.automation.base import Automation
|
||||
from bs4 import BeautifulSoup
|
||||
import re
|
||||
|
||||
log = CPLog(__name__)
|
||||
|
||||
|
||||
class Letterboxd(Automation):
|
||||
|
||||
url = 'http://letterboxd.com/%s/watchlist/'
|
||||
pattern = re.compile(r'(.*)\((\d*)\)')
|
||||
|
||||
def getIMDBids(self):
|
||||
|
||||
if not self.conf('automation_username'):
|
||||
log.error('Please fill in your username')
|
||||
urls = splitString(self.conf('automation_urls'))
|
||||
|
||||
if len(urls) == 0:
|
||||
return []
|
||||
|
||||
movies = []
|
||||
@@ -25,13 +28,22 @@ class Letterboxd(Automation):
|
||||
return movies
|
||||
|
||||
def getWatchlist(self):
|
||||
url = self.url % self.conf('automation_username')
|
||||
soup = BeautifulSoup(self.getHTMLData(url))
|
||||
|
||||
enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]
|
||||
urls = splitString(self.conf('automation_urls'))
|
||||
|
||||
index = -1
|
||||
movies = []
|
||||
for username in urls:
|
||||
|
||||
for movie in soup.find_all('a', attrs = { 'class': 'frame' }):
|
||||
match = filter(None, self.pattern.split(movie['title']))
|
||||
movies.append({ 'title': match[0], 'year': match[1] })
|
||||
index += 1
|
||||
if not enablers[index]:
|
||||
continue
|
||||
|
||||
soup = BeautifulSoup(self.getHTMLData(self.url % username))
|
||||
|
||||
for movie in soup.find_all('a', attrs = { 'class': 'frame' }):
|
||||
match = filter(None, self.pattern.split(movie['title']))
|
||||
movies.append({'title': match[0], 'year': match[1] })
|
||||
|
||||
return movies
|
||||
|
||||
Reference in New Issue
Block a user