diff --git a/couchpotato/core/providers/automation/rottentomatoes/__init__.py b/couchpotato/core/providers/automation/rottentomatoes/__init__.py index 92ff7870..f3c12919 100644 --- a/couchpotato/core/providers/automation/rottentomatoes/__init__.py +++ b/couchpotato/core/providers/automation/rottentomatoes/__init__.py @@ -10,7 +10,7 @@ config = [{ 'tab': 'automation', 'name': 'rottentomatoes_automation', 'label': 'Rottentomatoes', - 'description': 'Imports movies from the rottentomatoes in theaters rss feed.', + 'description': 'Imports movies from the rottentomatoes "in theaters"-feed.', 'options': [ { 'name': 'automation_enabled', diff --git a/couchpotato/core/providers/automation/rottentomatoes/main.py b/couchpotato/core/providers/automation/rottentomatoes/main.py index 302056d5..053b79e8 100644 --- a/couchpotato/core/providers/automation/rottentomatoes/main.py +++ b/couchpotato/core/providers/automation/rottentomatoes/main.py @@ -1,10 +1,9 @@ from couchpotato.core.helpers.rss import RSS -from couchpotato.core.helpers.variable import md5 +from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog from couchpotato.core.providers.automation.base import Automation from xml.etree.ElementTree import QName import datetime -import xml.etree.ElementTree as XMLTree import re log = CPLog(__name__) @@ -12,47 +11,38 @@ log = CPLog(__name__) class Rottentomatoes(Automation, RSS): interval = 1800 - rss_url = 'http://www.rottentomatoes.com/syndication/rss/in_theaters.xml' + urls = { + 'namespace': 'http://www.rottentomatoes.com/xmlns/rtmovie/', + 'theater': 'http://www.rottentomatoes.com/syndication/rss/in_theaters.xml', + } def getIMDBids(self): - if self.isDisabled(): - return - movies = [] - cache_key = 'rottentomatoes.%s' % md5(self.rss_url) - rss_data = self.getCache(cache_key, self.rss_url) - data = XMLTree.fromstring(rss_data) + rss_movies = self.getRSSData(self.urls['theater']) + rating_tag = str(QName(self.urls['namespace'], 'tomatometer_percent')) - if data: + for movie in rss_movies: - namespace = 'http://www.rottentomatoes.com/xmlns/rtmovie/' - rating_tag = str(QName(namespace, 'tomatometer_percent')) - rss_movies = self.getElements(data, 'channel/item') + value = self.getTextElement(movie, "title") + result = re.search('(?<=%\s).*', value) - for movie in rss_movies: + if result: - value = self.getTextElement(movie, "title") - result = re.search('(?<=%\s).*', value) + log.info2('Something smells...') + rating = tryInt(self.getTextElement(movie, rating_tag)) + name = result.group(0) - if result: + if rating < tryInt(self.conf('tomatometer_percent')): + log.info2('%s seems to be rotten...' % name) + else: - log.info('Something smells...') - rating = int(self.getTextElement(movie, rating_tag)) - name = result.group(0) + log.info2('Found %s fresh enough movies, enqueuing: %s' % (rating, name)) + year = datetime.datetime.now().strftime("%Y") + imdb = self.search(name, year) - if rating < int(self.conf('tomatometer_percent')): - - log.info('%s seems to be rotten...' % name) - - else: - - log.info('You find %s fresh enough though, enqueuing: %s' % (rating, name)) - year = datetime.datetime.now().strftime("%Y") - imdb = self.search(name, year) - - if imdb: - movies.append(imdb['imdb']) + if imdb: + movies.append(imdb['imdb']) return movies