From d9b9447242a6e35c4c6f5d64dc53f555c1c521be Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 17 Jan 2014 22:37:01 +0100 Subject: [PATCH 1/4] Change cachekey if info not extended --- couchpotato/core/providers/info/themoviedb/main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/providers/info/themoviedb/main.py b/couchpotato/core/providers/info/themoviedb/main.py index 9587ba41..dd0dc1ef 100644 --- a/couchpotato/core/providers/info/themoviedb/main.py +++ b/couchpotato/core/providers/info/themoviedb/main.py @@ -66,7 +66,7 @@ class TheMovieDb(MovieProvider): if not identifier: return {} - cache_key = 'tmdb.cache.%s' % identifier + cache_key = 'tmdb.cache.%s%s' % (identifier, '.ex' if extended else '') result = self.getCache(cache_key) if not result: @@ -88,7 +88,7 @@ class TheMovieDb(MovieProvider): def parseMovie(self, movie, extended = True): - cache_key = 'tmdb.cache.%s' % movie.id + cache_key = 'tmdb.cache.%s%s' % (movie.id, '.ex' if extended else '') movie_data = self.getCache(cache_key) if not movie_data: From 082da6e3a6929ca73a7505f0144efda321e8bc81 Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 17 Jan 2014 22:38:02 +0100 Subject: [PATCH 2/4] Don't return .text in urlopen --- couchpotato/core/plugins/base.py | 4 ++-- couchpotato/core/plugins/file/main.py | 2 +- couchpotato/core/providers/base.py | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index c7ec517e..b4688e49 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -127,7 +127,7 @@ class Plugin(object): return False # http request - def urlopen(self, url, timeout = 30, data = None, headers = None, files = None, show_error = True, return_raw = False): + def urlopen(self, url, timeout = 30, data = None, headers = None, files = None, show_error = True): url = urllib2.quote(ss(url), safe = "%/:=&?~#+!$,;'@()*[]") if not headers: headers = {} @@ -172,7 +172,7 @@ class Plugin(object): log.info('Opening url: %s %s, data: %s', (method, url, [x for x in data.iterkeys()] if isinstance(data, dict) else 'with data')) response = r.request(method, url, verify = False, **kwargs) - data = response.content if return_raw else response.text + data = response.content self.http_failed_request[host] = 0 except (IOError, MaxRetryError, Timeout): diff --git a/couchpotato/core/plugins/file/main.py b/couchpotato/core/plugins/file/main.py index 2d73d0e2..fc63aca8 100644 --- a/couchpotato/core/plugins/file/main.py +++ b/couchpotato/core/plugins/file/main.py @@ -93,7 +93,7 @@ class FileManager(Plugin): return dest try: - filedata = self.urlopen(url, return_raw = True, **urlopen_kwargs) + filedata = self.urlopen(url, **urlopen_kwargs) except: log.error('Failed downloading file %s: %s', (url, traceback.format_exc())) return False diff --git a/couchpotato/core/providers/base.py b/couchpotato/core/providers/base.py index e30cc242..89967df1 100644 --- a/couchpotato/core/providers/base.py +++ b/couchpotato/core/providers/base.py @@ -164,7 +164,7 @@ class YarrProvider(Provider): try: if not self.login(): log.error('Failed downloading from %s', self.getName()) - return self.urlopen(url, return_raw = True) + return self.urlopen(url) except: log.error('Failed downloading from %s: %s', (self.getName(), traceback.format_exc())) @@ -173,7 +173,7 @@ class YarrProvider(Provider): def download(self, url = '', nzb_id = ''): try: - return self.urlopen(url, headers = {'User-Agent': Env.getIdentifier()}, show_error = False, return_raw = True) + return self.urlopen(url, headers = {'User-Agent': Env.getIdentifier()}, show_error = False) except: log.error('Failed getting nzb from %s: %s', (self.getName(), traceback.format_exc())) From b3f1f938be82ff120c15ca90398b312237477cee Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 17 Jan 2014 22:38:38 +0100 Subject: [PATCH 3/4] Speedup automation getinfo --- couchpotato/core/providers/automation/imdb/main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/couchpotato/core/providers/automation/imdb/main.py b/couchpotato/core/providers/automation/imdb/main.py index 76afb24c..25f2fee8 100644 --- a/couchpotato/core/providers/automation/imdb/main.py +++ b/couchpotato/core/providers/automation/imdb/main.py @@ -25,7 +25,7 @@ class IMDBBase(Automation, RSS): interval = 1800 def getInfo(self, imdb_id): - return fireEvent('movie.info', identifier = imdb_id, merge = True) + return fireEvent('movie.info', identifier = imdb_id, extended = False, merge = True) class IMDBWatchlist(IMDBBase): From 161e3086fac12c29fb4738542076cc292c566dbd Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 17 Jan 2014 23:00:15 +0100 Subject: [PATCH 4/4] Force year as int on tmdb info. fix #2725 --- couchpotato/core/providers/info/themoviedb/main.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/providers/info/themoviedb/main.py b/couchpotato/core/providers/info/themoviedb/main.py index dd0dc1ef..fa6896b2 100644 --- a/couchpotato/core/providers/info/themoviedb/main.py +++ b/couchpotato/core/providers/info/themoviedb/main.py @@ -1,5 +1,6 @@ from couchpotato.core.event import addEvent from couchpotato.core.helpers.encoding import simplifyString, toUnicode +from couchpotato.core.helpers.variable import tryInt from couchpotato.core.logger import CPLog from couchpotato.core.providers.info.base import MovieProvider import tmdb3 @@ -137,7 +138,7 @@ class TheMovieDb(MovieProvider): 'imdb': movie.imdb, 'runtime': movie.runtime, 'released': str(movie.releasedate), - 'year': year, + 'year': tryInt(year, None), 'plot': movie.overview, 'genres': genres, 'collection': getattr(movie.collection, 'name', None),