From 28f4169e44832a4dcc3284394ab5ae9f8815c96c Mon Sep 17 00:00:00 2001 From: Ruud Date: Mon, 5 Nov 2012 17:56:44 +0100 Subject: [PATCH] Allow csv file from imdb.com. closes #1017 --- .../core/providers/automation/imdb/main.py | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/couchpotato/core/providers/automation/imdb/main.py b/couchpotato/core/providers/automation/imdb/main.py index a4511b49..c2324856 100644 --- a/couchpotato/core/providers/automation/imdb/main.py +++ b/couchpotato/core/providers/automation/imdb/main.py @@ -1,9 +1,8 @@ from couchpotato.core.helpers.rss import RSS -from couchpotato.core.helpers.variable import md5, getImdb +from couchpotato.core.helpers.variable import md5, getImdb, splitString, tryInt from couchpotato.core.logger import CPLog from couchpotato.core.providers.automation.base import Automation import traceback -import xml.etree.ElementTree as XMLTree log = CPLog(__name__) @@ -19,30 +18,25 @@ class IMDB(Automation, RSS): movies = [] - enablers = self.conf('automation_urls_use').split(',') + enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))] + urls = splitString(self.conf('automation_urls')) index = -1 - for rss_url in self.conf('automation_urls').split(','): + for url in urls: index += 1 if not enablers[index]: continue - elif 'rss.imdb' not in rss_url: - log.error('This isn\'t the correct url.: %s', rss_url) - continue try: - cache_key = 'imdb.rss.%s' % md5(rss_url) + cache_key = 'imdb.rss.%s' % md5(url) + rss_data = self.getCache(cache_key, url) + imdbs = getImdb(rss_data, multiple = True) - rss_data = self.getCache(cache_key, rss_url) - data = XMLTree.fromstring(rss_data) - rss_movies = self.getElements(data, 'channel/item') - - for movie in rss_movies: - imdb = getImdb(self.getTextElement(movie, "link")) + for imdb in imdbs: movies.append(imdb) except: - log.error('Failed loading IMDB watchlist: %s %s', (rss_url, traceback.format_exc())) + log.error('Failed loading IMDB watchlist: %s %s', (url, traceback.format_exc())) return movies