Cleanup automation providers
This commit is contained in:
1 parent
b07a937fa7
commit
ee21610bc3
4 files changed
+18
-42
No files matched your search
@@ -27,36 +27,31 @@ class Automation(Plugin):
|
|||||||
|
|
||||||
return self.getIMDBids()
|
return self.getIMDBids()
|
||||||
|
|
||||||
def search(self, name, year = None):
|
def search(self, name, year = None, imdb_only = False):
|
||||||
result = fireEvent('movie.search', q = '%s %s' % (name, year if year else ''), limit = 1, merge = True)
|
result = fireEvent('movie.search', q = '%s %s' % (name, year if year else ''), limit = 1, merge = True)
|
||||||
|
|
||||||
if len(result) > 0:
|
if len(result) > 0:
|
||||||
return result[0].get('imdb')
|
return result[0].get('imdb') if imdb_only else result[0]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def isMinimalMovie(self, movie):
|
def isMinimalMovie(self, movie):
|
||||||
|
if not movie.get('rating'):
|
||||||
|
return False
|
||||||
|
|
||||||
if movie['rating'] and movie['rating'].get('imdb'):
|
if movie['rating'] and movie['rating'].get('imdb'):
|
||||||
movie['votes'] = movie['rating']['imdb'][1]
|
movie['votes'] = movie['rating']['imdb'][1]
|
||||||
movie['rating'] = movie['rating']['imdb'][0]
|
movie['rating'] = movie['rating']['imdb'][0]
|
||||||
identifier = movie['imdb']
|
|
||||||
for minimal_type in ['year', 'rating', 'votes']:
|
for minimal_type in ['year', 'rating', 'votes']:
|
||||||
type_value = movie.get(minimal_type, 0)
|
type_value = movie.get(minimal_type, 0)
|
||||||
type_min = self.getMinimal(minimal_type)
|
type_min = self.getMinimal(minimal_type)
|
||||||
if type_value < type_min:
|
if type_value < type_min:
|
||||||
log.info('%s too low for %s, need %s has %s', (minimal_type, identifier, type_min, type_value))
|
log.info('%s too low for %s, need %s has %s', (minimal_type, movie['imdb'], type_min, type_value))
|
||||||
return False
|
return False
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
def getIMDBFromTitle(self, name, year = None):
|
|
||||||
result = fireEvent('movie.search', q = '%s %s' % (name, year), limit = 1, merge = True)
|
|
||||||
|
|
||||||
if len(result) > 0:
|
|
||||||
return result[0]
|
|
||||||
else:
|
|
||||||
return None
|
|
||||||
|
|
||||||
def getMinimal(self, min_type):
|
def getMinimal(self, min_type):
|
||||||
return Env.setting(min_type, 'automation')
|
return Env.setting(min_type, 'automation')
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
from couchpotato.core.helpers.rss import RSS
|
from couchpotato.core.helpers.rss import RSS
|
||||||
from couchpotato.core.helpers.variable import md5
|
from couchpotato.core.helpers.variable import md5, 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
|
||||||
from couchpotato.environment import Env
|
from couchpotato.environment import Env
|
||||||
@@ -19,8 +19,6 @@ class Bluray(Automation, RSS):
|
|||||||
return
|
return
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
RSSMovie = {'name': 'placeholder', 'year' : 'placeholder'}
|
|
||||||
RSSMovies = []
|
|
||||||
|
|
||||||
cache_key = 'bluray.%s' % md5(self.rss_url)
|
cache_key = 'bluray.%s' % md5(self.rss_url)
|
||||||
rss_data = self.getCache(cache_key, self.rss_url)
|
rss_data = self.getCache(cache_key, self.rss_url)
|
||||||
@@ -30,30 +28,16 @@ class Bluray(Automation, RSS):
|
|||||||
rss_movies = self.getElements(data, 'channel/item')
|
rss_movies = self.getElements(data, 'channel/item')
|
||||||
|
|
||||||
for movie in rss_movies:
|
for movie in rss_movies:
|
||||||
RSSMovie['name'] = self.getTextElement(movie, "title").lower().split("blu-ray")[0].strip("(").rstrip()
|
name = self.getTextElement(movie, "title").lower().split("blu-ray")[0].strip("(").rstrip()
|
||||||
RSSMovie['year'] = self.getTextElement(movie, "description").split("|")[1].strip("(").strip()
|
year = self.getTextElement(movie, "description").split("|")[1].strip("(").strip()
|
||||||
|
|
||||||
if not RSSMovie['name'].find("/") == -1: # make sure it is not a double movie release
|
if not name.find("/") == -1: # make sure it is not a double movie release
|
||||||
continue
|
continue
|
||||||
|
|
||||||
if int(RSSMovie['year']) < Env.setting('year', 'automation'): #do year filtering
|
if tryInt(year) < self.getMinimal('year'):
|
||||||
continue
|
continue
|
||||||
|
|
||||||
for test in RSSMovies:
|
imdb = self.search(name, year)
|
||||||
if test.values() == RSSMovie.values(): # make sure we did not already include it...
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
log.info('Release found: %s.' % RSSMovie)
|
|
||||||
RSSMovies.append(RSSMovie.copy())
|
|
||||||
|
|
||||||
if not RSSMovies:
|
|
||||||
log.info('No movies found.')
|
|
||||||
return
|
|
||||||
|
|
||||||
log.debug("Applying IMDB filter to found movies...")
|
|
||||||
|
|
||||||
for RSSMovie in RSSMovies:
|
|
||||||
imdb = self.getIMDBFromTitle(RSSMovie['name'] + ' ' + RSSMovie['year'])
|
|
||||||
|
|
||||||
if imdb:
|
if imdb:
|
||||||
if self.isMinimalMovie(imdb):
|
if self.isMinimalMovie(imdb):
|
||||||
|
|||||||
@@ -19,7 +19,6 @@ class Kinepolis(Automation, RSS):
|
|||||||
return
|
return
|
||||||
|
|
||||||
movies = []
|
movies = []
|
||||||
RSSMovie = {'name': 'placeholder', 'year' : 'placeholder'}
|
|
||||||
|
|
||||||
cache_key = 'kinepolis.%s' % md5(self.rss_url)
|
cache_key = 'kinepolis.%s' % md5(self.rss_url)
|
||||||
rss_data = self.getCache(cache_key, self.rss_url)
|
rss_data = self.getCache(cache_key, self.rss_url)
|
||||||
@@ -29,14 +28,12 @@ class Kinepolis(Automation, RSS):
|
|||||||
rss_movies = self.getElements(data, 'channel/item')
|
rss_movies = self.getElements(data, 'channel/item')
|
||||||
|
|
||||||
for movie in rss_movies:
|
for movie in rss_movies:
|
||||||
RSSMovie['name'] = self.getTextElement(movie, "title")
|
name = self.getTextElement(movie, "title")
|
||||||
currentYear = datetime.datetime.now().strftime("%Y")
|
year = datetime.datetime.now().strftime("%Y")
|
||||||
RSSMovie['year'] = currentYear
|
|
||||||
|
|
||||||
log.debug('Release found: %s.', RSSMovie)
|
imdb = self.search(name, year)
|
||||||
imdb = self.getIMDBFromTitle(RSSMovie['name'], RSSMovie['year'])
|
|
||||||
|
|
||||||
if imdb:
|
if imdb and self.isMinimalMovie(imdb):
|
||||||
movies.append(imdb['imdb'])
|
movies.append(imdb['imdb'])
|
||||||
|
|
||||||
return movies
|
return movies
|
||||||
@@ -9,7 +9,7 @@ config = [{
|
|||||||
{
|
{
|
||||||
'tab': 'automation',
|
'tab': 'automation',
|
||||||
'name': 'moviesio',
|
'name': 'moviesio',
|
||||||
'label': 'Movies.io',
|
'label': 'Movies.IO',
|
||||||
'description': 'Imports movies from <a href="http://movies.io">Movies.io</a> RSS watchlists',
|
'description': 'Imports movies from <a href="http://movies.io">Movies.io</a> RSS watchlists',
|
||||||
'options': [
|
'options': [
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user