Merge branch 'rotten_tomatoes_custom_urls' of git://github.com/Lordcrash/CouchPotatoServer into Lordcrash-rotten_tomatoes_custom_urls

This commit is contained in:
Ruud committed 2013-08-24 13:28:10 +02:00
commit 8ac2869de3
2 files changed
+39 -23

No files matched your search

@@ -11,13 +11,23 @@ config = [{
'list': 'automation_providers', 'list': 'automation_providers',
'name': 'rottentomatoes_automation', 'name': 'rottentomatoes_automation',
'label': 'Rottentomatoes', 'label': 'Rottentomatoes',
'description': 'Imports movies from the rottentomatoes "in theaters"-feed.', 'description': 'Imports movies from rottentomatoes rss feeds specified below.',
'options': [ 'options': [
{ {
'name': 'automation_enabled', 'name': 'automation_enabled',
'default': False, 'default': False,
'type': 'enabler', 'type': 'enabler',
}, },
{
'name': 'automation_urls_use',
'label': 'Use',
},
{
'name': 'automation_urls',
'label': 'url',
'type': 'combined',
'combine': ['automation_urls_use', 'automation_urls'],
},
{ {
'name': 'tomatometer_percent', 'name': 'tomatometer_percent',
'default': '80', 'default': '80',
@@ -1,5 +1,5 @@
from couchpotato.core.helpers.rss import RSS from couchpotato.core.helpers.rss import RSS
from couchpotato.core.helpers.variable import tryInt from couchpotato.core.helpers.variable import tryInt, splitString
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
from xml.etree.ElementTree import QName from xml.etree.ElementTree import QName
@@ -11,38 +11,44 @@ log = CPLog(__name__)
class Rottentomatoes(Automation, RSS): class Rottentomatoes(Automation, RSS):
interval = 1800 interval = 1800
urls = {
'namespace': 'http://www.rottentomatoes.com/xmlns/rtmovie/',
'theater': 'http://www.rottentomatoes.com/syndication/rss/in_theaters.xml',
}
def getIMDBids(self): def getIMDBids(self):
movies = [] movies = []
rss_movies = self.getRSSData(self.urls['theater']) rotten_tomatoes_namespace = 'http://www.rottentomatoes.com/xmlns/rtmovie/'
rating_tag = str(QName(self.urls['namespace'], 'tomatometer_percent')) urls = dict(zip(splitString(self.conf('automation_urls')), [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]))
for movie in rss_movies: for url in urls:
value = self.getTextElement(movie, "title") if not urls[url]:
result = re.search('(?<=%\s).*', value) continue
if result: rss_movies = self.getRSSData(url)
rating_tag = str(QName(rotten_tomatoes_namespace, 'tomatometer_percent'))
log.info2('Something smells...') for movie in rss_movies:
rating = tryInt(self.getTextElement(movie, rating_tag))
name = result.group(0)
if rating < tryInt(self.conf('tomatometer_percent')): value = self.getTextElement(movie, "title")
log.info2('%s seems to be rotten...', name) result = re.search('(?<=%\s).*', value)
else:
log.info2('Found %s fresh enough movies, enqueuing: %s', (rating, name)) if result:
year = datetime.datetime.now().strftime("%Y")
imdb = self.search(name, year)
if imdb and self.isMinimalMovie(imdb): log.info2('Something smells...')
movies.append(imdb['imdb']) rating = tryInt(self.getTextElement(movie, rating_tag))
name = result.group(0)
if rating < tryInt(self.conf('tomatometer_percent')):
log.info2('%s seems to be rotten...', name)
else:
log.info2('Found %s fresh enough movies, enqueuing: %s', (rating, name))
year = datetime.datetime.now().strftime("%Y")
imdb = self.search(name, year)
if imdb and self.isMinimalMovie(imdb):
movies.append(imdb['imdb'])
return movies return movies