From ada78a14f85136b4ad88c0161405d0e6200a2e93 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 6 Jan 2019 00:47:01 -0500 Subject: [PATCH 1/5] hotfix --- TorrentToMedia.py | 2 +- nzbToMedia.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 5536bbab..0e14e60d 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -2,7 +2,7 @@ # coding=utf-8 import cleanup -cleanup.clean('core', 'libs') +cleanup.clean(cleanup.FOLDER_STRUCTURE) import datetime import os diff --git a/nzbToMedia.py b/nzbToMedia.py index 2fc8c80c..fceed9cd 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -624,7 +624,7 @@ from __future__ import print_function import cleanup -cleanup.clean('core', 'libs') +cleanup.clean(cleanup.FOLDER_STRUCTURE) import datetime import os From 0fd570cd85959d2a78e84e615f464706b1a21925 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 6 Jan 2019 00:48:08 -0500 Subject: [PATCH 2/5] =?UTF-8?q?Bump=20version:=2012.0.4=20=E2=86=92=2012.0?= =?UTF-8?q?.5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .bumpversion.cfg | 2 +- README.md | 2 +- core/__init__.py | 2 +- setup.py | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index c26fb34f..feb03ca3 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 12.0.4 +current_version = 12.0.5 commit = True tag = False diff --git a/README.md b/README.md index 3ddaccd5..a9bc945d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -nzbToMedia v12.0.4 +nzbToMedia v12.0.5 ================== Provides an [efficient](https://github.com/clinton-hall/nzbToMedia/wiki/Efficient-on-demand-post-processing) way to handle postprocessing for [CouchPotatoServer](https://couchpota.to/ "CouchPotatoServer") and [SickBeard](http://sickbeard.com/ "SickBeard") (and its [forks](https://github.com/clinton-hall/nzbToMedia/wiki/Failed-Download-Handling-%28FDH%29#sick-beard-and-its-forks)) diff --git a/core/__init__.py b/core/__init__.py index 43799161..b55ea684 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -52,7 +52,7 @@ from core.utils import ( resume_torrent, remove_dir, remove_read_only, sanitize_name, update_download_info_status, ) -__version__ = '12.0.4' +__version__ = '12.0.5' # Client Agents NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual'] diff --git a/setup.py b/setup.py index e61e2fc3..e8cb7477 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def read(*names, **kwargs): setup( name='nzbToMedia', - version='12.0.4', + version='12.0.5', license='GPLv3', description='Efficient on demand post processing', long_description=""" From 6d0d2d3f7e9e4ccbf7f2681d83ac2bea95cc31ac Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Mon, 31 Dec 2018 12:21:16 -0500 Subject: [PATCH 3/5] Use dict literal or comprehension for dict creation --- core/__init__.py | 22 ++++++++++++---------- core/auto_process/movies.py | 9 +++++---- core/forks.py | 12 ++++++++++-- core/main_db.py | 16 ++++++++-------- 4 files changed, 35 insertions(+), 24 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index b55ea684..6487e716 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -63,7 +63,6 @@ SABNZB_NO_OF_ARGUMENTS = 8 SABNZB_0717_NO_OF_ARGUMENTS = 9 # sickbeard fork/branch constants -FORKS = {} FORK_DEFAULT = 'default' FORK_FAILED = 'failed' FORK_FAILED_TORRENT = 'failed-torrent' @@ -73,15 +72,18 @@ FORK_SICKBEARD_API = 'SickBeard-api' FORK_MEDUSA = 'Medusa' FORK_SICKGEAR = 'SickGear' FORK_STHENO = 'Stheno' -FORKS[FORK_DEFAULT] = {'dir': None} -FORKS[FORK_FAILED] = {'dirName': None, 'failed': None} -FORKS[FORK_FAILED_TORRENT] = {'dir': None, 'failed': None, 'process_method': None} -FORKS[FORK_SICKRAGE] = {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None} -FORKS[FORK_SICKCHILL] = {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'force_next': None} -FORKS[FORK_SICKBEARD_API] = {'path': None, 'failed': None, 'process_method': None, 'force_replace': None, 'return_data': None, 'type': None, 'delete': None, 'force_next': None} -FORKS[FORK_MEDUSA] = {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'ignore_subs': None} -FORKS[FORK_SICKGEAR] = {'dir': None, 'failed': None, 'process_method': None, 'force': None} -FORKS[FORK_STHENO] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs": None} + +FORKS = { + FORK_DEFAULT: {'dir': None}, + FORK_FAILED: {'dirName': None, 'failed': None}, + FORK_FAILED_TORRENT: {'dir': None, 'failed': None, 'process_method': None}, + FORK_SICKRAGE: {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None}, + FORK_SICKCHILL: {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'force_next': None}, + FORK_SICKBEARD_API: {'path': None, 'failed': None, 'process_method': None, 'force_replace': None, 'return_data': None, 'type': None, 'delete': None, 'force_next': None}, + FORK_MEDUSA: {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'ignore_subs': None}, + FORK_SICKGEAR: {'dir': None, 'failed': None, 'process_method': None, 'force': None}, + FORK_STHENO: {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs": None} +} ALL_FORKS = {k: None for k in set(list(itertools.chain.from_iterable([FORKS[x].keys() for x in FORKS.keys()])))} # NZBGet Exit Codes diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index f3097b6f..7c7b8f02 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -163,17 +163,18 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', status_code=0, ) - params = {} + params = { + 'media_folder': remote_dir(dir_name) if remote_path else dir_name, + } + if download_id and release_id: params['downloader'] = downloader or client_agent params['download_id'] = download_id - params['media_folder'] = remote_dir(dir_name) if remote_path else dir_name - if section == 'CouchPotato': if method == 'manage': command = 'manage.update' - params = {} + params.clear() else: command = 'renamer.scan' diff --git a/core/forks.py b/core/forks.py index 8ff389fe..65610ad0 100644 --- a/core/forks.py +++ b/core/forks.py @@ -20,8 +20,16 @@ def auto_fork(section, input_category): apikey = cfg.get('apikey') ssl = int(cfg.get('ssl', 0)) web_root = cfg.get('web_root', '') - replace = {'sickrage': 'SickRage', 'sickchill': 'SickChill', 'sickgear': 'SickGear', 'medusa': 'Medusa', 'sickbeard-api': 'SickBeard-api', 'stheno': 'Stheno'} - f1 = replace[cfg.get('fork', 'auto')] if cfg.get('fork', 'auto') in replace else cfg.get('fork', 'auto') + replace = { + 'medusa': 'Medusa', + 'sickbeard-api': 'SickBeard-api', + 'sickgear': 'SickGear', + 'sickchill': 'SickChill', + 'sickrage': 'SickRage', + 'stheno': 'Stheno', + } + _val = cfg.get('fork', 'auto') + f1 = replace.get(_val, _val) try: fork = f1, core.FORKS[f1] except KeyError: diff --git a/core/main_db.py b/core/main_db.py index 6d2b6b95..12c21c7e 100644 --- a/core/main_db.py +++ b/core/main_db.py @@ -202,17 +202,17 @@ class DBConnection(object): def table_info(self, table_name): # FIXME ? binding is not supported here, but I cannot find a way to escape a string manually cursor = self.connection.execute('PRAGMA table_info({0})'.format(table_name)) - columns = {} - for column in cursor: - columns[column['name']] = {'type': column['type']} - return columns + return { + column['name']: {'type': column['type']} + for column in cursor + } # http://stackoverflow.com/questions/3300464/how-can-i-get-dict-from-sqlite-query def _dict_factory(self, cursor, row): - d = {} - for idx, col in enumerate(cursor.description): - d[col[0]] = row[idx] - return d + return { + col[0]: row[idx] + for idx, col in enumerate(cursor.description) + } def sanity_check_database(connection, sanity_check): From 93ec74f1c738bc5b8a93bdf5e35c5d8c35161ca5 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Mon, 31 Dec 2018 12:28:15 -0500 Subject: [PATCH 4/5] Fix conditional assignment --- core/transcoder.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/core/transcoder.py b/core/transcoder.py index 38973a33..e2bfb33d 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -80,10 +80,7 @@ def get_video_details(videofile, img=None, bitbucket=None): file = videofile if not core.FFPROBE: return video_details, result - if 'avprobe' in core.FFPROBE: - print_format = '-of' - else: - print_format = '-print_format' + print_format = '-of' if 'avprobe' in core.FFPROBE else '-print_format' try: if img: videofile = '-' From a289eef88ec47ec8c4e9ac8fe94dbdf0d507ac17 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Mon, 31 Dec 2018 12:23:01 -0500 Subject: [PATCH 5/5] Remove unused variable --- core/__init__.py | 1 - core/auto_process/movies.py | 1 - core/auto_process/music.py | 6 ------ core/forks.py | 1 - core/scene_exceptions.py | 1 - 5 files changed, 10 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 6487e716..68d4a95c 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -745,7 +745,6 @@ def initialize(section=None): if codec in codec_alias: extra = [item for item in codec_alias[codec] if item not in ACODEC3_ALLOW] ACODEC3_ALLOW.extend(extra) - codec_alias = {} # clear memory PASSWORDSFILE = CFG['passwords']['PassWordFile'] diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 7c7b8f02..0c2f5880 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -221,7 +221,6 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', res = json.loads(r.content) scan_id = int(res['id']) logger.debug('Scan started with id: {0}'.format(scan_id), section) - started = True except Exception as e: logger.warning('No scan id was returned due to: {0}'.format(e), section) scan_id = None diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 9c5f7048..58e63714 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -117,18 +117,12 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', status_code=1, ) - success = False - queued = False - started = False try: res = json.loads(r.content) scan_id = int(res['id']) logger.debug('Scan started with id: {0}'.format(scan_id), section) - started = True except Exception as e: logger.warning('No scan id was returned due to: {0}'.format(e), section) - scan_id = None - started = False return ProcessResult( message='{0}: Failed to post-process - Unable to start scan'.format(section), status_code=1, diff --git a/core/forks.py b/core/forks.py index 65610ad0..ede32f9c 100644 --- a/core/forks.py +++ b/core/forks.py @@ -87,7 +87,6 @@ def auto_fork(section, input_category): r = [] if r and r.ok: if apikey: - optional_parameters = [] try: json_data = r.json() except ValueError: diff --git a/core/scene_exceptions.py b/core/scene_exceptions.py index 5d830012..f2c53c45 100644 --- a/core/scene_exceptions.py +++ b/core/scene_exceptions.py @@ -148,7 +148,6 @@ def rename_script(dirname): def par2(dirname): - newlist = [] sofar = 0 parfile = '' objects = []