diff --git a/couchpotato/core/plugins/automation/__init__.py b/couchpotato/core/plugins/automation/__init__.py index 2eac7dac..75e0d28f 100644 --- a/couchpotato/core/plugins/automation/__init__.py +++ b/couchpotato/core/plugins/automation/__init__.py @@ -25,7 +25,7 @@ config = [{ }, { 'name': 'rating', - 'default': 6.0, + 'default': 7.0, 'type': 'float', }, { diff --git a/couchpotato/core/plugins/automation/main.py b/couchpotato/core/plugins/automation/main.py index a29d8810..12571e4f 100644 --- a/couchpotato/core/plugins/automation/main.py +++ b/couchpotato/core/plugins/automation/main.py @@ -19,4 +19,8 @@ class Automation(Plugin): movies = fireEvent('automation.get_movies', merge = True) for imdb_id in movies: - fireEvent('movie.add', params = {'identifier': imdb_id}, force_readd = False) + prop_name = 'automation.added.%s' % imdb_id + added = Env.prop(prop_name, default = False) + if not added: + fireEvent('movie.add', params = {'identifier': imdb_id}, force_readd = False) + Env.prop(prop_name, True) diff --git a/couchpotato/core/providers/automation/base.py b/couchpotato/core/providers/automation/base.py index d43b5c8c..df04b13b 100644 --- a/couchpotato/core/providers/automation/base.py +++ b/couchpotato/core/providers/automation/base.py @@ -2,7 +2,6 @@ from couchpotato.core.event import addEvent, fireEvent from couchpotato.core.logger import CPLog from couchpotato.core.plugins.base import Plugin from couchpotato.environment import Env -from couchpotato.core.helpers.encoding import simplifyString import time log = CPLog(__name__) @@ -36,14 +35,9 @@ class Automation(Plugin): else: return None - def isMinimal(self, identifier): - movie = fireEvent('movie.info', identifier = identifier, merge = True) - return self.isMinimalMovie(movie) - def isMinimalMovie(self, movie): - if movie['rating']: - rating = movie['rating']['imdb'][0] - movie['votes'] = movie['rating']['imdb'][1] + if movie['rating'] and movie['rating'].get('imdb'): + movie['votes'] = movie['rating']['imdb'][1] movie['rating'] = movie['rating']['imdb'][0] identifier = movie['imdb'] for minimal_type in ['year', 'rating', 'votes']: @@ -55,19 +49,13 @@ class Automation(Plugin): return True - def getIMDBFromTitle(self, title): - cache_key = u'%s/%s' % (__name__, simplifyString(title)) - movies = Env.get('cache').get(cache_key) + def getIMDBFromTitle(self, name, year = None): + result = fireEvent('movie.search', q = '%s %s' % (name, year), limit = 1, merge = True) - if not movies: - movies = fireEvent('movie.searchimdb', q = title, merge = True) - Env.get('cache').set(cache_key, movies) - - try: - return movies[0] - - except: - log.info("No results for " + title) + if len(result) > 0: + return result[0] + else: + return None def getMinimal(self, min_type): return Env.setting(min_type, 'automation') diff --git a/couchpotato/core/providers/automation/bluray/__init__.py b/couchpotato/core/providers/automation/bluray/__init__.py index 5eabba35..6e9d831d 100644 --- a/couchpotato/core/providers/automation/bluray/__init__.py +++ b/couchpotato/core/providers/automation/bluray/__init__.py @@ -10,7 +10,7 @@ config = [{ 'tab': 'automation', 'name': 'bluray_automation', 'label': 'Blu-ray.com', - 'description': 'imports movies from blu-ray.com', + 'description': 'Imports movies from blu-ray.com. (uses minimal requirements)', 'options': [ { 'name': 'automation_enabled', @@ -20,4 +20,4 @@ config = [{ ], }, ], -}] \ No newline at end of file +}] diff --git a/couchpotato/core/providers/automation/bluray/main.py b/couchpotato/core/providers/automation/bluray/main.py index 2dec9fc1..cd7c0c90 100644 --- a/couchpotato/core/providers/automation/bluray/main.py +++ b/couchpotato/core/providers/automation/bluray/main.py @@ -3,9 +3,7 @@ from couchpotato.core.helpers.variable import md5 from couchpotato.core.logger import CPLog from couchpotato.core.providers.automation.base import Automation from couchpotato.environment import Env -import traceback import xml.etree.ElementTree as XMLTree -import json log = CPLog(__name__) @@ -16,10 +14,10 @@ class Bluray(Automation, RSS): rss_url = 'http://www.blu-ray.com/rss/newreleasesfeed.xml' def getIMDBids(self): - + if self.isDisabled(): return - + movies = [] RSSMovie = {'name': 'placeholder', 'year' : 'placeholder'} RSSMovies = [] @@ -30,11 +28,11 @@ class Bluray(Automation, RSS): if data: rss_movies = self.getElements(data, 'channel/item') - + for movie in rss_movies: RSSMovie['name'] = self.getTextElement(movie, "title").lower().split("blu-ray")[0].strip("(").rstrip() RSSMovie['year'] = self.getTextElement(movie, "description").split("|")[1].strip("(").strip() - + if not RSSMovie['name'].find("/") == -1: # make sure it is not a double movie release continue @@ -52,13 +50,13 @@ class Bluray(Automation, RSS): log.info('No movies found.') return - log.info("Applying IMDB filter to found movies...") + log.debug("Applying IMDB filter to found movies...") for RSSMovie in RSSMovies: imdb = self.getIMDBFromTitle(RSSMovie['name'] + ' ' + RSSMovie['year']) - + if imdb: if self.isMinimalMovie(imdb): movies.append(imdb['imdb']) - return movies \ No newline at end of file + return movies diff --git a/couchpotato/core/providers/automation/kinepolis/__init__.py b/couchpotato/core/providers/automation/kinepolis/__init__.py index 6590e13c..eea36016 100644 --- a/couchpotato/core/providers/automation/kinepolis/__init__.py +++ b/couchpotato/core/providers/automation/kinepolis/__init__.py @@ -10,7 +10,7 @@ config = [{ 'tab': 'automation', 'name': 'kinepolis_automation', 'label': 'Kinepolis', - 'description': 'imports movies from the current top 10 of kinepolis', + 'description': 'Imports movies from the current top 10 of kinepolis. (uses minimal requirements)', 'options': [ { 'name': 'automation_enabled', @@ -20,4 +20,4 @@ config = [{ ], }, ], -}] \ No newline at end of file +}] diff --git a/couchpotato/core/providers/automation/kinepolis/main.py b/couchpotato/core/providers/automation/kinepolis/main.py index 3b1905b5..031bb444 100644 --- a/couchpotato/core/providers/automation/kinepolis/main.py +++ b/couchpotato/core/providers/automation/kinepolis/main.py @@ -2,12 +2,8 @@ from couchpotato.core.helpers.rss import RSS from couchpotato.core.helpers.variable import md5 from couchpotato.core.logger import CPLog from couchpotato.core.providers.automation.base import Automation -from couchpotato.environment import Env -from dateutil.parser import parse -import time -import traceback -import xml.etree.ElementTree as XMLTree import datetime +import xml.etree.ElementTree as XMLTree log = CPLog(__name__) @@ -18,10 +14,10 @@ class Kinepolis(Automation, RSS): rss_url = 'http://kinepolis.be/nl/top10-box-office/feed' def getIMDBids(self): - + if self.isDisabled(): return - + movies = [] RSSMovie = {'name': 'placeholder', 'year' : 'placeholder'} @@ -29,18 +25,18 @@ class Kinepolis(Automation, RSS): rss_data = self.getCache(cache_key, self.rss_url) data = XMLTree.fromstring(rss_data) - if data: + if data is not None: rss_movies = self.getElements(data, 'channel/item') - + for movie in rss_movies: RSSMovie['name'] = self.getTextElement(movie, "title") currentYear = datetime.datetime.now().strftime("%Y") RSSMovie['year'] = currentYear - log.info('Release found: %s.' % RSSMovie) - imdb = self.getIMDBFromTitle(RSSMovie['name'] + ' ' + RSSMovie['year']) + log.debug('Release found: %s.', RSSMovie) + imdb = self.getIMDBFromTitle(RSSMovie['name'], RSSMovie['year']) if imdb: movies.append(imdb['imdb']) - return movies \ No newline at end of file + return movies