Added custom url code handling
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
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.providers.automation.base import Automation
|
||||
from xml.etree.ElementTree import QName
|
||||
@@ -11,38 +11,48 @@ log = CPLog(__name__)
|
||||
class Rottentomatoes(Automation, RSS):
|
||||
|
||||
interval = 1800
|
||||
urls = {
|
||||
'namespace': 'http://www.rottentomatoes.com/xmlns/rtmovie/',
|
||||
'theater': 'http://www.rottentomatoes.com/syndication/rss/in_theaters.xml',
|
||||
}
|
||||
|
||||
|
||||
|
||||
def getIMDBids(self):
|
||||
|
||||
movies = []
|
||||
|
||||
rss_movies = self.getRSSData(self.urls['theater'])
|
||||
rating_tag = str(QName(self.urls['namespace'], 'tomatometer_percent'))
|
||||
rotten_tomatoes_namespace = 'http://www.rottentomatoes.com/xmlns/rtmovie/'
|
||||
enablers = [tryInt(x) for x in splitString(self.conf('automation_urls_use'))]
|
||||
urls = splitString(self.conf('automation_urls'))
|
||||
|
||||
for movie in rss_movies:
|
||||
index = -1
|
||||
|
||||
value = self.getTextElement(movie, "title")
|
||||
result = re.search('(?<=%\s).*', value)
|
||||
for url in urls:
|
||||
|
||||
if result:
|
||||
index += 1
|
||||
if not enablers[index]:
|
||||
continue
|
||||
|
||||
log.info2('Something smells...')
|
||||
rating = tryInt(self.getTextElement(movie, rating_tag))
|
||||
name = result.group(0)
|
||||
rss_movies = self.getRSSData(url)
|
||||
rating_tag = str(QName(rotten_tomatoes_namespace, 'tomatometer_percent'))
|
||||
|
||||
if rating < tryInt(self.conf('tomatometer_percent')):
|
||||
log.info2('%s seems to be rotten...', name)
|
||||
else:
|
||||
for movie in rss_movies:
|
||||
|
||||
log.info2('Found %s fresh enough movies, enqueuing: %s', (rating, name))
|
||||
year = datetime.datetime.now().strftime("%Y")
|
||||
imdb = self.search(name, year)
|
||||
value = self.getTextElement(movie, "title")
|
||||
result = re.search('(?<=%\s).*', value)
|
||||
|
||||
if imdb and self.isMinimalMovie(imdb):
|
||||
movies.append(imdb['imdb'])
|
||||
if result:
|
||||
|
||||
log.info2('Something smells...')
|
||||
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
|
||||
|
||||
Reference in New Issue
Block a user