From 4ede2c20a1afcdc0e62cb91616a53ea40165b2e9 Mon Sep 17 00:00:00 2001 From: Ruud Date: Tue, 12 Feb 2013 23:10:34 +0100 Subject: [PATCH] Goodfilm automation provider. closes #1366 --- .../providers/automation/goodfilms/__init__.py | 28 +++++++++++++++++ .../core/providers/automation/goodfilms/main.py | 36 ++++++++++++++++++++++ 2 files changed, 64 insertions(+) create mode 100644 couchpotato/core/providers/automation/goodfilms/__init__.py create mode 100644 couchpotato/core/providers/automation/goodfilms/main.py diff --git a/couchpotato/core/providers/automation/goodfilms/__init__.py b/couchpotato/core/providers/automation/goodfilms/__init__.py new file mode 100644 index 0000000..795e21d --- /dev/null +++ b/couchpotato/core/providers/automation/goodfilms/__init__.py @@ -0,0 +1,28 @@ +from .main import Goodfilms + +def start(): + return Goodfilms() + +config = [{ + 'name': 'goodfilms', + 'groups': [ + { + 'tab': 'automation', + 'list': 'watchlist_providers', + 'name': 'goodfilms_automation', + 'label': 'Goodfilms', + 'description': 'import movies from your Goodfilms queue', + 'options': [ + { + 'name': 'automation_enabled', + 'default': False, + 'type': 'enabler', + }, + { + 'name': 'automation_username', + 'label': 'Username', + }, + ], + }, + ], +}] \ No newline at end of file diff --git a/couchpotato/core/providers/automation/goodfilms/main.py b/couchpotato/core/providers/automation/goodfilms/main.py new file mode 100644 index 0000000..dd4b1ae --- /dev/null +++ b/couchpotato/core/providers/automation/goodfilms/main.py @@ -0,0 +1,36 @@ +from couchpotato.core.logger import CPLog +from couchpotato.core.providers.automation.base import Automation +from bs4 import BeautifulSoup + +log = CPLog(__name__) + + +class Goodfilms(Automation): + + url = 'http://goodfil.ms/%s/queue' + + def getIMDBids(self): + + if not self.conf('automation_username'): + log.error('Please fill in your username') + return [] + + movies = [] + + for movie in self.getWatchlist(): + imdb_id = self.search(movie.get('title'), movie.get('year'), imdb_only = True) + movies.append(imdb_id) + + return movies + + def getWatchlist(self): + + url = self.url % self.conf('automation_username') + soup = BeautifulSoup(self.getHTMLData(url)) + + movies = [] + + for movie in soup.find_all('div', attrs = { 'class': 'movie', 'data-film-title': True }): + movies.append({ 'title': movie['data-film-title'], 'year': movie['data-film-year'] }) + + return movies