From b69f8b7ed520930dcab53dc27c1eb58a0c2afbf4 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 19 Mar 2014 22:33:14 +0100 Subject: [PATCH 1/5] Files not properly send to sabnzbd --- couchpotato/core/helpers/variable.py | 2 +- couchpotato/core/plugins/base.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/couchpotato/core/helpers/variable.py b/couchpotato/core/helpers/variable.py index 8be6f299..66166738 100644 --- a/couchpotato/core/helpers/variable.py +++ b/couchpotato/core/helpers/variable.py @@ -290,7 +290,7 @@ def isSubFolder(sub_folder, base_folder): return base_folder and sub_folder and ss(os.path.normpath(base_folder).rstrip(os.path.sep) + os.path.sep) in ss(os.path.normpath(sub_folder).rstrip(os.path.sep) + os.path.sep) # From SABNZBD -re_password = [re.compile(r'([^/\\]+)[/\\](.+)'), re.compile(r'(.+){{([^{}]+)}}$'), re.compile(r'(.+)\s+password\s*=\s*(.+)$', re.I)] +re_password = [re.compile(r'(.+){{([^{}]+)}}$'), re.compile(r'(.+)\s+password\s*=\s*(.+)$', re.I)] def scanForPassword(name): m = None for reg in re_password: diff --git a/couchpotato/core/plugins/base.py b/couchpotato/core/plugins/base.py index d7487a10..20ae8506 100644 --- a/couchpotato/core/plugins/base.py +++ b/couchpotato/core/plugins/base.py @@ -296,7 +296,7 @@ class Plugin(object): return '%s%s' % (toSafeString(toUnicode(release_name)[:max_length]), tag) def createFileName(self, data, filedata, media): - name = sp(os.path.join(self.createNzbName(data, media))) + name = self.createNzbName(data, media) if data.get('protocol') == 'nzb' and 'DOCTYPE nzb' not in filedata and '' not in filedata: return '%s.%s' % (name, 'rar') return '%s.%s' % (name, data.get('protocol')) From 240283405e5389a77642ccfd68d619313142635e Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 7 May 2014 11:50:36 +0200 Subject: [PATCH 2/5] variable 'year' referenced before assignment --- couchpotato/core/plugins/scanner/main.py | 1 + 1 file changed, 1 insertion(+) diff --git a/couchpotato/core/plugins/scanner/main.py b/couchpotato/core/plugins/scanner/main.py index 3031236f..4304bdd2 100644 --- a/couchpotato/core/plugins/scanner/main.py +++ b/couchpotato/core/plugins/scanner/main.py @@ -843,6 +843,7 @@ class Scanner(Plugin): cleaned = ' '.join(re.split('\W+', simplifyString(release_name))) cleaned = re.sub(self.clean, ' ', cleaned) + year = None for year_str in [file_name, release_name, cleaned]: if not year_str: continue year = self.findYear(year_str) From e11b07b55916988451d096865c81066b1ef7459d Mon Sep 17 00:00:00 2001 From: Ruud Date: Fri, 6 Jun 2014 17:26:45 +0200 Subject: [PATCH 3/5] Don't save profile order twice --- .../core/plugins/profile/static/profile.css | 6 +++--- .../core/plugins/quality/static/quality.js | 20 +++++++++++++------ 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/couchpotato/core/plugins/profile/static/profile.css b/couchpotato/core/plugins/profile/static/profile.css index 073fa573..f8a1b422 100644 --- a/couchpotato/core/plugins/profile/static/profile.css +++ b/couchpotato/core/plugins/profile/static/profile.css @@ -159,9 +159,6 @@ } #profile_ordering li { - cursor: -webkit-grab; - cursor: -moz-grab; - cursor: grab; border-bottom: 1px solid rgba(255,255,255,0.2); padding: 0 5px; } @@ -183,6 +180,9 @@ background: url('../../images/handle.png') center; width: 20px; float: right; + cursor: -webkit-grab; + cursor: -moz-grab; + cursor: grab; } #profile_ordering .formHint { diff --git a/couchpotato/core/plugins/quality/static/quality.js b/couchpotato/core/plugins/quality/static/quality.js index 285ed1d9..601438d3 100644 --- a/couchpotato/core/plugins/quality/static/quality.js +++ b/couchpotato/core/plugins/quality/static/quality.js @@ -135,20 +135,28 @@ var QualityBase = new Class({ }); // Sortable + var sorted_changed = false; self.profile_sortable = new Sortables(profile_list, { 'revert': true, - 'handle': '', + 'handle': '.handle', 'opacity': 0.5, - 'onComplete': self.saveProfileOrdering.bind(self) + 'onSort': function(){ + sorted_changed = true; + }, + 'onComplete': function(){ + if(sorted_changed){ + self.saveProfileOrdering(); + sorted_changed = false; + } + } }); }, saveProfileOrdering: function(){ - var self = this; - - var ids = []; - var hidden = []; + var self = this, + ids = [], + hidden = []; self.profile_sortable.list.getElements('li').each(function(el, nr){ ids.include(el.get('data-id')); From 07a7f8cbcf566127c7c70efb7f1fead91daa5dd2 Mon Sep 17 00:00:00 2001 From: Ruud Date: Wed, 16 Jul 2014 10:32:02 +0200 Subject: [PATCH 4/5] Change fanart api url --- .../core/media/movie/providers/info/fanarttv.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/couchpotato/core/media/movie/providers/info/fanarttv.py b/couchpotato/core/media/movie/providers/info/fanarttv.py index 8bfa92c8..fcd3891b 100644 --- a/couchpotato/core/media/movie/providers/info/fanarttv.py +++ b/couchpotato/core/media/movie/providers/info/fanarttv.py @@ -14,7 +14,7 @@ autoload = 'FanartTV' class FanartTV(MovieProvider): urls = { - 'api': 'http://api.fanart.tv/webservice/movie/b28b14e9be662e027cfbc7c3dd600405/%s/JSON/all/1/2' + 'api': 'http://webservice.fanart.tv/v3/movies/%s?api_key=b28b14e9be662e027cfbc7c3dd600405' } MAX_EXTRAFANART = 20 @@ -36,9 +36,8 @@ class FanartTV(MovieProvider): fanart_data = self.getJsonData(url) if fanart_data: - name, resource = fanart_data.items()[0] - log.debug('Found images for %s', name) - images = self._parseMovie(resource) + log.debug('Found images for %s', fanart_data.get('name')) + images = self._parseMovie(fanart_data) except: log.error('Failed getting extra art for %s: %s', @@ -95,7 +94,7 @@ class FanartTV(MovieProvider): for image in images: if tryInt(image.get('likes')) > highscore: highscore = tryInt(image.get('likes')) - image_url = image.get('url') + image_url = image.get('url') or image.get('href') return image_url @@ -118,7 +117,9 @@ class FanartTV(MovieProvider): if tryInt(image.get('likes')) > highscore: highscore = tryInt(image.get('likes')) best = image - image_urls.append(best.get('url')) + url = best.get('url') or best.get('href') + if url: + image_urls.append(url) pool.remove(best) return image_urls From e75a8529c99996a0ba20fdcf83d424b6597bc3f8 Mon Sep 17 00:00:00 2001 From: Ruud Date: Thu, 17 Jul 2014 22:24:48 +0200 Subject: [PATCH 5/5] Try fix migration failure from 2.5.1 --- couchpotato/core/database.py | 30 +++++++++++++++++++++++++++++- couchpotato/runner.py | 7 +++++++ 2 files changed, 36 insertions(+), 1 deletion(-) diff --git a/couchpotato/core/database.py b/couchpotato/core/database.py index c7051f5c..47be7f53 100644 --- a/couchpotato/core/database.py +++ b/couchpotato/core/database.py @@ -3,10 +3,11 @@ import os import time import traceback +from CodernityDB.database import RecordNotFound from CodernityDB.index import IndexException, IndexNotFoundException, IndexConflict from couchpotato import CPLog from couchpotato.api import addApiView -from couchpotato.core.event import addEvent, fireEvent +from couchpotato.core.event import addEvent, fireEvent, fireEventAsync from couchpotato.core.helpers.encoding import toUnicode, sp from couchpotato.core.helpers.variable import getImdb, tryInt @@ -226,6 +227,33 @@ class Database(object): from couchpotato import Env db = self.getDB() + + # Try fix for migration failures on desktop + if Env.get('desktop'): + try: + list(db.all('profile', with_doc = True)) + except RecordNotFound: + + failed_location = '%s_failed' % db.path + old_db = os.path.join(Env.get('data_dir'), 'couchpotato.db.old') + + if not os.path.isdir(failed_location) and os.path.isfile(old_db): + db.close() + + # Rename database folder + os.rename(db.path, '%s_failed' % db.path) + + # Rename .old database to try another migrate + os.rename(old_db, old_db[:-4]) + + fireEventAsync('app.restart') + else: + log.error('Migration failed and couldn\'t recover database. Please report on GitHub, with this message.') + db.reindex() + + return + + # Check size and compact if needed size = db.get_db_details().get('size') prop_name = 'last_db_compact' last_check = int(Env.prop(prop_name, default = 0)) diff --git a/couchpotato/runner.py b/couchpotato/runner.py index e5f9bcab..5d3f62b0 100644 --- a/couchpotato/runner.py +++ b/couchpotato/runner.py @@ -87,6 +87,13 @@ def runCouchPotato(options, base_path, args, data_dir = None, log_dir = None, En # Do db stuff db_path = sp(os.path.join(data_dir, 'database')) + old_db_path = os.path.join(data_dir, 'couchpotato.db') + + # Remove database folder if both exists + if os.path.isdir(db_path) and os.path.isfile(old_db_path): + db = SuperThreadSafeDatabase(db_path) + db.open() + db.destroy() # Check if database exists db = SuperThreadSafeDatabase(db_path)