You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.5 KiB

from couchpotato.core.helpers.rss import RSS
13 years ago
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 re
log = CPLog(__name__)
class Rottentomatoes(Automation, RSS):
interval = 1800
13 years ago
urls = {
'namespace': 'http://www.rottentomatoes.com/xmlns/rtmovie/',
'theater': 'http://www.rottentomatoes.com/syndication/rss/in_theaters.xml',
}
def getIMDBids(self):
movies = []
13 years ago
rss_movies = self.getRSSData(self.urls['theater'])
rating_tag = str(QName(self.urls['namespace'], 'tomatometer_percent'))
13 years ago
for movie in rss_movies:
13 years ago
value = self.getTextElement(movie, "title")
result = re.search('(?<=%\s).*', value)
13 years ago
if result:
13 years ago
log.info2('Something smells...')
rating = tryInt(self.getTextElement(movie, rating_tag))
name = result.group(0)
13 years ago
if rating < tryInt(self.conf('tomatometer_percent')):
12 years ago
log.info2('%s seems to be rotten...', name)
13 years ago
else:
12 years ago
log.info2('Found %s fresh enough movies, enqueuing: %s', (rating, name))
13 years ago
year = datetime.datetime.now().strftime("%Y")
imdb = self.search(name, year)
if imdb and self.isMinimalMovie(imdb):
13 years ago
movies.append(imdb['imdb'])
return movies