Allow csv file from imdb.com. closes #1017

This commit is contained in:
Ruud committed 2012-11-05 17:56:44 +01:00
1 parent 2361057e4c
commit 28f4169e44
1 file changed
+9 -15
@@ -1,9 +1,8 @@
from couchpotato.core.helpers.rss import RSS 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.logger import CPLog
from couchpotato.core.providers.automation.base import Automation from couchpotato.core.providers.automation.base import Automation
import traceback import traceback
import xml.etree.ElementTree as XMLTree
log = CPLog(__name__) log = CPLog(__name__)
@@ -19,30 +18,25 @@ class IMDB(Automation, RSS):
movies = [] 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 index = -1
for rss_url in self.conf('automation_urls').split(','): for url in urls:
index += 1 index += 1
if not enablers[index]: if not enablers[index]:
continue continue
elif 'rss.imdb' not in rss_url:
log.error('This isn\'t the correct url.: %s', rss_url)
continue
try: 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) for imdb in imdbs:
data = XMLTree.fromstring(rss_data)
rss_movies = self.getElements(data, 'channel/item')
for movie in rss_movies:
imdb = getImdb(self.getTextElement(movie, "link"))
movies.append(imdb) movies.append(imdb)
except: 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 return movies