From 649febdedd994de7faa8fd97871dbc5dba17e16b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:19:09 -0500 Subject: [PATCH 01/75] Refactor NZBGET_POSTPROCESS_PARCHECK -> NZBGET_POSTPROCESS_PAR_CHECK --- core/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e7280ded..0423ea62 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -105,7 +105,7 @@ FORKS = { ALL_FORKS = {k: None for k in set(list(itertools.chain.from_iterable([FORKS[x].keys() for x in FORKS.keys()])))} # NZBGet Exit Codes -NZBGET_POSTPROCESS_PARCHECK = 92 +NZBGET_POSTPROCESS_PAR_CHECK = 92 NZBGET_POSTPROCESS_SUCCESS = 93 NZBGET_POSTPROCESS_ERROR = 94 NZBGET_POSTPROCESS_NONE = 95 @@ -252,7 +252,7 @@ __INITIALIZED__ = False def initialize(section=None): - global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PARCHECK, NZBGET_POSTPROCESS_SUCCESS, \ + global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ From 20bd765a4bbd540859240c5de2440fe03648b441 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:20:04 -0500 Subject: [PATCH 02/75] Refactor UTORRENTWEBUI -> UTORRENT_WEB_UI --- core/__init__.py | 6 +++--- core/utils/torrents.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 0423ea62..435da837 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -150,7 +150,7 @@ TORRENT_RESUME_ON_FAILURE = None REMOTEPATHS = [] -UTORRENTWEBUI = None +UTORRENT_WEB_UI = None UTORRENTUSR = None UTORRENTPWD = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENTPWD, UTORRENTUSR, UTORRENTWEBUI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENTPWD, UTORRENTUSR, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -406,7 +406,7 @@ def initialize(section=None): TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure']) TORRENT_RESUME = int(CFG['Torrent']['resume']) - UTORRENTWEBUI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/ + UTORRENT_WEB_UI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/ UTORRENTUSR = CFG['Torrent']['uTorrentUSR'] # mysecretusr UTORRENTPWD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr diff --git a/core/utils/torrents.py b/core/utils/torrents.py index e9786da9..1ecbca95 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -15,8 +15,8 @@ def create_torrent_class(client_agent): if client_agent == 'utorrent': try: - logger.debug('Connecting to {0}: {1}'.format(client_agent, core.UTORRENTWEBUI)) - tc = UTorrentClient(core.UTORRENTWEBUI, core.UTORRENTUSR, core.UTORRENTPWD) + logger.debug('Connecting to {0}: {1}'.format(client_agent, core.UTORRENT_WEB_UI)) + tc = UTorrentClient(core.UTORRENT_WEB_UI, core.UTORRENTUSR, core.UTORRENTPWD) except Exception: logger.error('Failed to connect to uTorrent') From 22d2c1b108002a56c3eb7c0eef8b6adc2b47e6d7 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:20:30 -0500 Subject: [PATCH 03/75] Refactor UTORRENTUSR -> UTORRENT_USER --- core/__init__.py | 6 +++--- core/utils/torrents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 435da837..321c744b 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -151,7 +151,7 @@ TORRENT_RESUME_ON_FAILURE = None REMOTEPATHS = [] UTORRENT_WEB_UI = None -UTORRENTUSR = None +UTORRENT_USER = None UTORRENTPWD = None TRANSMISSIONHOST = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENTPWD, UTORRENTUSR, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENTPWD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -407,7 +407,7 @@ def initialize(section=None): TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure']) TORRENT_RESUME = int(CFG['Torrent']['resume']) UTORRENT_WEB_UI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/ - UTORRENTUSR = CFG['Torrent']['uTorrentUSR'] # mysecretusr + UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr UTORRENTPWD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr TRANSMISSIONHOST = CFG['Torrent']['TransmissionHost'] # localhost diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 1ecbca95..37943258 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -16,7 +16,7 @@ def create_torrent_class(client_agent): if client_agent == 'utorrent': try: logger.debug('Connecting to {0}: {1}'.format(client_agent, core.UTORRENT_WEB_UI)) - tc = UTorrentClient(core.UTORRENT_WEB_UI, core.UTORRENTUSR, core.UTORRENTPWD) + tc = UTorrentClient(core.UTORRENT_WEB_UI, core.UTORRENT_USER, core.UTORRENTPWD) except Exception: logger.error('Failed to connect to uTorrent') From 39974e62cc97c1de6fe909e4637bcacf084603eb Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:20:59 -0500 Subject: [PATCH 04/75] Refactor UTORRENTPWD -> UTORRENT_PASSWORD --- core/__init__.py | 6 +++--- core/utils/torrents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 321c744b..6cb95416 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -152,7 +152,7 @@ REMOTEPATHS = [] UTORRENT_WEB_UI = None UTORRENT_USER = None -UTORRENTPWD = None +UTORRENT_PASSWORD = None TRANSMISSIONHOST = None TRANSMISSIONPORT = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENTPWD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -408,7 +408,7 @@ def initialize(section=None): TORRENT_RESUME = int(CFG['Torrent']['resume']) UTORRENT_WEB_UI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/ UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr - UTORRENTPWD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr + UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr TRANSMISSIONHOST = CFG['Torrent']['TransmissionHost'] # localhost TRANSMISSIONPORT = int(CFG['Torrent']['TransmissionPort']) diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 37943258..b471a297 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -16,7 +16,7 @@ def create_torrent_class(client_agent): if client_agent == 'utorrent': try: logger.debug('Connecting to {0}: {1}'.format(client_agent, core.UTORRENT_WEB_UI)) - tc = UTorrentClient(core.UTORRENT_WEB_UI, core.UTORRENT_USER, core.UTORRENTPWD) + tc = UTorrentClient(core.UTORRENT_WEB_UI, core.UTORRENT_USER, core.UTORRENT_PASSWORD) except Exception: logger.error('Failed to connect to uTorrent') From 5d5eb798c97660daad901e4dc1b00934af79d42d Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:21:34 -0500 Subject: [PATCH 05/75] Refactor TRANSMISSIONHOST -> TRANSMISSION_HOST --- core/__init__.py | 6 +++--- core/utils/torrents.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 6cb95416..7794fa14 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -154,7 +154,7 @@ UTORRENT_WEB_UI = None UTORRENT_USER = None UTORRENT_PASSWORD = None -TRANSMISSIONHOST = None +TRANSMISSION_HOST = None TRANSMISSIONPORT = None TRANSMISSIONUSR = None TRANSMISSIONPWD = None @@ -257,7 +257,7 @@ def initialize(section=None): NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ - TRANSMISSIONHOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ + TRANSMISSION_HOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ @@ -410,7 +410,7 @@ def initialize(section=None): UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr - TRANSMISSIONHOST = CFG['Torrent']['TransmissionHost'] # localhost + TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost TRANSMISSIONPORT = int(CFG['Torrent']['TransmissionPort']) TRANSMISSIONUSR = CFG['Torrent']['TransmissionUSR'] # mysecretusr TRANSMISSIONPWD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr diff --git a/core/utils/torrents.py b/core/utils/torrents.py index b471a297..21e954b5 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -23,8 +23,8 @@ def create_torrent_class(client_agent): if client_agent == 'transmission': try: logger.debug('Connecting to {0}: http://{1}:{2}'.format( - client_agent, core.TRANSMISSIONHOST, core.TRANSMISSIONPORT)) - tc = TransmissionClient(core.TRANSMISSIONHOST, core.TRANSMISSIONPORT, + client_agent, core.TRANSMISSION_HOST, core.TRANSMISSIONPORT)) + tc = TransmissionClient(core.TRANSMISSION_HOST, core.TRANSMISSIONPORT, core.TRANSMISSIONUSR, core.TRANSMISSIONPWD) except Exception: From e66ad2b66d623bc4540d7cfce8930b375a31759f Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:21:58 -0500 Subject: [PATCH 06/75] Refactor TRANSMISSIONPORT -> TRANSMISSION_PORT --- core/__init__.py | 6 +++--- core/utils/torrents.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 7794fa14..21daaffc 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -155,7 +155,7 @@ UTORRENT_USER = None UTORRENT_PASSWORD = None TRANSMISSION_HOST = None -TRANSMISSIONPORT = None +TRANSMISSION_PORT = None TRANSMISSIONUSR = None TRANSMISSIONPWD = None @@ -257,7 +257,7 @@ def initialize(section=None): NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ - TRANSMISSION_HOST, TRANSMISSIONPORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ + TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ @@ -411,7 +411,7 @@ def initialize(section=None): UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost - TRANSMISSIONPORT = int(CFG['Torrent']['TransmissionPort']) + TRANSMISSION_PORT = int(CFG['Torrent']['TransmissionPort']) TRANSMISSIONUSR = CFG['Torrent']['TransmissionUSR'] # mysecretusr TRANSMISSIONPWD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 21e954b5..5d885495 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -23,8 +23,8 @@ def create_torrent_class(client_agent): if client_agent == 'transmission': try: logger.debug('Connecting to {0}: http://{1}:{2}'.format( - client_agent, core.TRANSMISSION_HOST, core.TRANSMISSIONPORT)) - tc = TransmissionClient(core.TRANSMISSION_HOST, core.TRANSMISSIONPORT, + client_agent, core.TRANSMISSION_HOST, core.TRANSMISSION_PORT)) + tc = TransmissionClient(core.TRANSMISSION_HOST, core.TRANSMISSION_PORT, core.TRANSMISSIONUSR, core.TRANSMISSIONPWD) except Exception: From 42dfdf73abcac92349268c9f1d82d7e8a347c78a Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:22:27 -0500 Subject: [PATCH 07/75] Refactor TRANSMISSIONUSR -> TRANSMISSION_USER --- core/__init__.py | 6 +++--- core/utils/torrents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 21daaffc..cd9d6260 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -156,7 +156,7 @@ UTORRENT_PASSWORD = None TRANSMISSION_HOST = None TRANSMISSION_PORT = None -TRANSMISSIONUSR = None +TRANSMISSION_USER = None TRANSMISSIONPWD = None DELUGEHOST = None @@ -257,7 +257,7 @@ def initialize(section=None): NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ - TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSIONPWD, TRANSMISSIONUSR, COMPRESSEDCONTAINER, MEDIACONTAINER, \ + TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSIONPWD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ @@ -412,7 +412,7 @@ def initialize(section=None): TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost TRANSMISSION_PORT = int(CFG['Torrent']['TransmissionPort']) - TRANSMISSIONUSR = CFG['Torrent']['TransmissionUSR'] # mysecretusr + TRANSMISSION_USER = CFG['Torrent']['TransmissionUSR'] # mysecretusr TRANSMISSIONPWD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr DELUGEHOST = CFG['Torrent']['DelugeHost'] # localhost diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 5d885495..0179d93b 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -25,7 +25,7 @@ def create_torrent_class(client_agent): logger.debug('Connecting to {0}: http://{1}:{2}'.format( client_agent, core.TRANSMISSION_HOST, core.TRANSMISSION_PORT)) tc = TransmissionClient(core.TRANSMISSION_HOST, core.TRANSMISSION_PORT, - core.TRANSMISSIONUSR, + core.TRANSMISSION_USER, core.TRANSMISSIONPWD) except Exception: logger.error('Failed to connect to Transmission') From a62415d71120d65b9a3f62ec84de7b1dcc0f6625 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:22:49 -0500 Subject: [PATCH 08/75] Refactor TRANSMISSIONPWD -> TRANSMISSION_PASSWORD --- core/__init__.py | 6 +++--- core/utils/torrents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index cd9d6260..2d0f44db 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -157,7 +157,7 @@ UTORRENT_PASSWORD = None TRANSMISSION_HOST = None TRANSMISSION_PORT = None TRANSMISSION_USER = None -TRANSMISSIONPWD = None +TRANSMISSION_PASSWORD = None DELUGEHOST = None DELUGEPORT = None @@ -257,7 +257,7 @@ def initialize(section=None): NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ - TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSIONPWD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ + TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ @@ -413,7 +413,7 @@ def initialize(section=None): TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost TRANSMISSION_PORT = int(CFG['Torrent']['TransmissionPort']) TRANSMISSION_USER = CFG['Torrent']['TransmissionUSR'] # mysecretusr - TRANSMISSIONPWD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr + TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr DELUGEHOST = CFG['Torrent']['DelugeHost'] # localhost DELUGEPORT = int(CFG['Torrent']['DelugePort']) # 8084 diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 0179d93b..60a2ec5d 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -26,7 +26,7 @@ def create_torrent_class(client_agent): client_agent, core.TRANSMISSION_HOST, core.TRANSMISSION_PORT)) tc = TransmissionClient(core.TRANSMISSION_HOST, core.TRANSMISSION_PORT, core.TRANSMISSION_USER, - core.TRANSMISSIONPWD) + core.TRANSMISSION_PASSWORD) except Exception: logger.error('Failed to connect to Transmission') From 9262ba9cd0fc76f44fcad2e76ab3f109759323bd Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:23:14 -0500 Subject: [PATCH 09/75] Refactor DELUGEHOST -> DELUGE_HOST --- core/__init__.py | 6 +++--- core/utils/torrents.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 2d0f44db..b761fd9e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -159,7 +159,7 @@ TRANSMISSION_PORT = None TRANSMISSION_USER = None TRANSMISSION_PASSWORD = None -DELUGEHOST = None +DELUGE_HOST = None DELUGEPORT = None DELUGEUSR = None DELUGEPWD = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGEHOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -415,7 +415,7 @@ def initialize(section=None): TRANSMISSION_USER = CFG['Torrent']['TransmissionUSR'] # mysecretusr TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr - DELUGEHOST = CFG['Torrent']['DelugeHost'] # localhost + DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost DELUGEPORT = int(CFG['Torrent']['DelugePort']) # 8084 DELUGEUSR = CFG['Torrent']['DelugeUSR'] # mysecretusr DELUGEPWD = CFG['Torrent']['DelugePWD'] # mysecretpwr diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 60a2ec5d..b38da66b 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -32,9 +32,9 @@ def create_torrent_class(client_agent): if client_agent == 'deluge': try: - logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGEHOST, core.DELUGEPORT)) + logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGE_HOST, core.DELUGEPORT)) tc = DelugeClient() - tc.connect(host=core.DELUGEHOST, port=core.DELUGEPORT, username=core.DELUGEUSR, + tc.connect(host=core.DELUGE_HOST, port=core.DELUGEPORT, username=core.DELUGEUSR, password=core.DELUGEPWD) except Exception: logger.error('Failed to connect to Deluge') From df5291fd4fddeaf2e11a975f5809f9342ed60367 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:46:54 -0500 Subject: [PATCH 10/75] Refactor DELUGEPORT -> DELUGE_PORT --- core/__init__.py | 6 +++--- core/utils/torrents.py | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index b761fd9e..1024b16b 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -160,7 +160,7 @@ TRANSMISSION_USER = None TRANSMISSION_PASSWORD = None DELUGE_HOST = None -DELUGEPORT = None +DELUGE_PORT = None DELUGEUSR = None DELUGEPWD = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGEPORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -416,7 +416,7 @@ def initialize(section=None): TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost - DELUGEPORT = int(CFG['Torrent']['DelugePort']) # 8084 + DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084 DELUGEUSR = CFG['Torrent']['DelugeUSR'] # mysecretusr DELUGEPWD = CFG['Torrent']['DelugePWD'] # mysecretpwr diff --git a/core/utils/torrents.py b/core/utils/torrents.py index b38da66b..d72437a9 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -32,9 +32,9 @@ def create_torrent_class(client_agent): if client_agent == 'deluge': try: - logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGE_HOST, core.DELUGEPORT)) + logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGE_HOST, core.DELUGE_PORT)) tc = DelugeClient() - tc.connect(host=core.DELUGE_HOST, port=core.DELUGEPORT, username=core.DELUGEUSR, + tc.connect(host=core.DELUGE_HOST, port=core.DELUGE_PORT, username=core.DELUGEUSR, password=core.DELUGEPWD) except Exception: logger.error('Failed to connect to Deluge') From 74bc6fb5b4b23ffa6c976cafe345f7d69865cede Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:49:00 -0500 Subject: [PATCH 11/75] Refactor DELUGEUSR -> DELUGE_USER --- core/__init__.py | 6 +++--- core/utils/torrents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 1024b16b..203b507a 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -161,7 +161,7 @@ TRANSMISSION_PASSWORD = None DELUGE_HOST = None DELUGE_PORT = None -DELUGEUSR = None +DELUGE_USER = None DELUGEPWD = None QBITTORRENTHOST = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGEUSR, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGEPWD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -417,7 +417,7 @@ def initialize(section=None): DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084 - DELUGEUSR = CFG['Torrent']['DelugeUSR'] # mysecretusr + DELUGE_USER = CFG['Torrent']['DelugeUSR'] # mysecretusr DELUGEPWD = CFG['Torrent']['DelugePWD'] # mysecretpwr QBITTORRENTHOST = CFG['Torrent']['qBittorrenHost'] # localhost diff --git a/core/utils/torrents.py b/core/utils/torrents.py index d72437a9..1138b952 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -34,7 +34,7 @@ def create_torrent_class(client_agent): try: logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGE_HOST, core.DELUGE_PORT)) tc = DelugeClient() - tc.connect(host=core.DELUGE_HOST, port=core.DELUGE_PORT, username=core.DELUGEUSR, + tc.connect(host=core.DELUGE_HOST, port=core.DELUGE_PORT, username=core.DELUGE_USER, password=core.DELUGEPWD) except Exception: logger.error('Failed to connect to Deluge') From 1aa0ea6e75011455f41264a4424a8ea5d2900121 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 22:50:23 -0500 Subject: [PATCH 12/75] Refactor DELUGEPWD -> DELUGE_PASSWORD --- core/__init__.py | 6 +++--- core/utils/torrents.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 203b507a..874632b8 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -162,7 +162,7 @@ TRANSMISSION_PASSWORD = None DELUGE_HOST = None DELUGE_PORT = None DELUGE_USER = None -DELUGEPWD = None +DELUGE_PASSWORD = None QBITTORRENTHOST = None QBITTORRENTPORT = None @@ -256,7 +256,7 @@ def initialize(section=None): NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ - NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGEPWD, VLEVEL, \ + NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ @@ -418,7 +418,7 @@ def initialize(section=None): DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084 DELUGE_USER = CFG['Torrent']['DelugeUSR'] # mysecretusr - DELUGEPWD = CFG['Torrent']['DelugePWD'] # mysecretpwr + DELUGE_PASSWORD = CFG['Torrent']['DelugePWD'] # mysecretpwr QBITTORRENTHOST = CFG['Torrent']['qBittorrenHost'] # localhost QBITTORRENTPORT = int(CFG['Torrent']['qBittorrentPort']) # 8080 diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 1138b952..867df7ee 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -35,7 +35,7 @@ def create_torrent_class(client_agent): logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.DELUGE_HOST, core.DELUGE_PORT)) tc = DelugeClient() tc.connect(host=core.DELUGE_HOST, port=core.DELUGE_PORT, username=core.DELUGE_USER, - password=core.DELUGEPWD) + password=core.DELUGE_PASSWORD) except Exception: logger.error('Failed to connect to Deluge') From 182a542bdaea4048b98faddf29b59be1b9b273ff Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Fri, 18 Jan 2019 23:48:41 -0500 Subject: [PATCH 13/75] Refactor QBITTORENT* --- core/__init__.py | 18 +++++++++--------- core/utils/torrents.py | 6 +++--- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 874632b8..4acda833 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -164,10 +164,10 @@ DELUGE_PORT = None DELUGE_USER = None DELUGE_PASSWORD = None -QBITTORRENTHOST = None -QBITTORRENTPORT = None -QBITTORRENTUSR = None -QBITTORRENTPWD = None +QBITTORRENT_HOST = None +QBITTORRENT_PORT = None +QBITTORRENT_USER = None +QBITTORRENT_PASSWORD = None PLEXSSL = None PLEXHOST = None @@ -269,7 +269,7 @@ def initialize(section=None): DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ - PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC, TORRENT_RESUME, PAR2CMD, QBITTORRENTHOST, QBITTORRENTPORT, QBITTORRENTUSR, QBITTORRENTPWD + PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: return False @@ -420,10 +420,10 @@ def initialize(section=None): DELUGE_USER = CFG['Torrent']['DelugeUSR'] # mysecretusr DELUGE_PASSWORD = CFG['Torrent']['DelugePWD'] # mysecretpwr - QBITTORRENTHOST = CFG['Torrent']['qBittorrenHost'] # localhost - QBITTORRENTPORT = int(CFG['Torrent']['qBittorrentPort']) # 8080 - QBITTORRENTUSR = CFG['Torrent']['qBittorrentUSR'] # mysecretusr - QBITTORRENTPWD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr + QBITTORRENT_HOST = CFG['Torrent']['qBittorrenHost'] # localhost + QBITTORRENT_PORT = int(CFG['Torrent']['qBittorrentPort']) # 8080 + QBITTORRENT_USER = CFG['Torrent']['qBittorrentUSR'] # mysecretusr + QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr REMOTEPATHS = CFG['Network']['mount_points'] or [] if REMOTEPATHS: diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 867df7ee..c20ba97f 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -41,9 +41,9 @@ def create_torrent_class(client_agent): if client_agent == 'qbittorrent': try: - logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.QBITTORRENTHOST, core.QBITTORRENTPORT)) - tc = qBittorrentClient('http://{0}:{1}/'.format(core.QBITTORRENTHOST, core.QBITTORRENTPORT)) - tc.login(core.QBITTORRENTUSR, core.QBITTORRENTPWD) + logger.debug('Connecting to {0}: http://{1}:{2}'.format(client_agent, core.QBITTORRENT_HOST, core.QBITTORRENT_PORT)) + tc = qBittorrentClient('http://{0}:{1}/'.format(core.QBITTORRENT_HOST, core.QBITTORRENT_PORT)) + tc.login(core.QBITTORRENT_USER, core.QBITTORRENT_PASSWORD) except Exception: logger.error('Failed to connect to qBittorrent') From d2346b0ea6407a871742e700b9740a5baec9adb0 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:13:13 -0500 Subject: [PATCH 14/75] Refactor PLEX* --- core/__init__.py | 30 +++++++++++++++--------------- core/utils/notifications.py | 12 ++++++------ 2 files changed, 21 insertions(+), 21 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 4acda833..c234fef3 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -169,11 +169,11 @@ QBITTORRENT_PORT = None QBITTORRENT_USER = None QBITTORRENT_PASSWORD = None -PLEXSSL = None -PLEXHOST = None -PLEXPORT = None -PLEXTOKEN = None -PLEXSEC = [] +PLEX_SSL = None +PLEX_HOST = None +PLEX_PORT = None +PLEX_TOKEN = None +PLEX_SECTION = [] EXTCONTAINER = [] COMPRESSEDCONTAINER = [] @@ -269,7 +269,7 @@ def initialize(section=None): DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ - PLEXSSL, PLEXHOST, PLEXPORT, PLEXTOKEN, PLEXSEC, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD + PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: return False @@ -434,15 +434,15 @@ def initialize(section=None): REMOTEPATHS = [(local.strip(), remote.strip()) for local, remote in REMOTEPATHS] # strip trailing and leading whitespaces - PLEXSSL = int(CFG['Plex']['plex_ssl']) - PLEXHOST = CFG['Plex']['plex_host'] - PLEXPORT = CFG['Plex']['plex_port'] - PLEXTOKEN = CFG['Plex']['plex_token'] - PLEXSEC = CFG['Plex']['plex_sections'] or [] - if PLEXSEC: - if isinstance(PLEXSEC, list): - PLEXSEC = ','.join(PLEXSEC) # fix in case this imported as list. - PLEXSEC = [tuple(item.split(',')) for item in PLEXSEC.split('|')] + PLEX_SSL = int(CFG['Plex']['plex_ssl']) + PLEX_HOST = CFG['Plex']['plex_host'] + PLEX_PORT = CFG['Plex']['plex_port'] + PLEX_TOKEN = CFG['Plex']['plex_token'] + PLEX_SECTION = CFG['Plex']['plex_sections'] or [] + if PLEX_SECTION: + if isinstance(PLEX_SECTION, list): + PLEX_SECTION = ','.join(PLEX_SECTION) # fix in case this imported as list. + PLEX_SECTION = [tuple(item.split(',')) for item in PLEX_SECTION.split('|')] devnull = open(os.devnull, 'w') try: diff --git a/core/utils/notifications.py b/core/utils/notifications.py index ed89f65b..ddad0c1b 100644 --- a/core/utils/notifications.py +++ b/core/utils/notifications.py @@ -8,20 +8,20 @@ def plex_update(category): if core.FAILED: return url = '{scheme}://{host}:{port}/library/sections/'.format( - scheme='https' if core.PLEXSSL else 'http', - host=core.PLEXHOST, - port=core.PLEXPORT, + scheme='https' if core.PLEX_SSL else 'http', + host=core.PLEX_HOST, + port=core.PLEX_PORT, ) section = None - if not core.PLEXSEC: + if not core.PLEX_SECTION: return logger.debug('Attempting to update Plex Library for category {0}.'.format(category), 'PLEX') - for item in core.PLEXSEC: + for item in core.PLEX_SECTION: if item[0] == category: section = item[1] if section: - url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEXTOKEN) + url = '{url}{section}/refresh?X-Plex-Token={token}'.format(url=url, section=section, token=core.PLEX_TOKEN) requests.get(url, timeout=(60, 120), verify=False) logger.debug('Plex Library has been refreshed.', 'PLEX') else: From 28f1bc35c592fe798ef14570825c0d864fa427db Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:13:51 -0500 Subject: [PATCH 15/75] Refactor USELINK -> USE_LINK --- TorrentToMedia.py | 4 ++-- core/__init__.py | 6 +++--- core/auto_process/movies.py | 2 +- core/auto_process/tv.py | 2 +- core/utils/common.py | 2 +- core/utils/torrents.py | 2 +- 6 files changed, 9 insertions(+), 9 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 4971c13d..9042fea1 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -196,7 +196,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp if torrent_no_link == 0: try: - core.copy_link(inputFile, target_file, core.USELINK) + core.copy_link(inputFile, target_file, core.USE_LINK) core.remove_read_only(target_file) except Exception: logger.error('Failed to link: {0} to {1}'.format(inputFile, target_file)) @@ -270,7 +270,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp core.update_download_info_status(input_name, 1) # remove torrent - if core.USELINK == 'move-sym' and not core.DELETE_ORIGINAL == 1: + if core.USE_LINK == 'move-sym' and not core.DELETE_ORIGINAL == 1: logger.debug('Checking for sym-links to re-direct in: {0}'.format(input_directory)) for dirpath, dirs, files in os.walk(input_directory): for file in files: diff --git a/core/__init__.py b/core/__init__.py index c234fef3..99d3b974 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -139,7 +139,7 @@ NZB_DEFAULTDIR = None TORRENT_CLIENTAGENT = None TORRENT_CLASS = None -USELINK = None +USE_LINK = None OUTPUTDIRECTORY = None NOFLATTEN = [] DELETE_ORIGINAL = None @@ -255,7 +255,7 @@ def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USELINK, OUTPUTDIRECTORY, \ + SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USE_LINK, OUTPUTDIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ @@ -393,7 +393,7 @@ def initialize(section=None): GROUPS = None TORRENT_CLIENTAGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other - USELINK = CFG['Torrent']['useLink'] # no | hard | sym + USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUTDIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULTDIR = CFG['Torrent']['default_downloadDirectory'] CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 0c2f5880..ab84627e 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -152,7 +152,7 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', if not release and '.cp(tt' not in video and imdbid: video_name, video_ext = os.path.splitext(video) video2 = '{0}.cp({1}){2}'.format(video_name, imdbid, video_ext) - if not (client_agent in [core.TORRENT_CLIENTAGENT, 'manual'] and core.USELINK == 'move-sym'): + if not (client_agent in [core.TORRENT_CLIENTAGENT, 'manual'] and core.USE_LINK == 'move-sym'): logger.debug('Renaming: {0} to: {1}'.format(video, video2)) os.rename(video, video2) diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 8abfd0df..56323894 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -47,7 +47,7 @@ def process(section, dir_name, input_name=None, failed=False, client_agent='manu delete_failed = int(cfg.get('delete_failed', 0)) nzb_extraction_by = cfg.get('nzbExtractionBy', 'Downloader') process_method = cfg.get('process_method') - if client_agent == core.TORRENT_CLIENTAGENT and core.USELINK == 'move-sym': + if client_agent == core.TORRENT_CLIENTAGENT and core.USE_LINK == 'move-sym': process_method = 'symlink' remote_path = int(cfg.get('remote_path', 0)) wait_for = int(cfg.get('wait_for', 2)) diff --git a/core/utils/common.py b/core/utils/common.py index f352fb87..c2f9ef79 100644 --- a/core/utils/common.py +++ b/core/utils/common.py @@ -100,7 +100,7 @@ def get_dirs(section, subsection, link='hard'): except Exception as e: logger.error('Failed to add directories from {0} for post-processing: {1}'.format(watch_directory, e)) - if core.USELINK == 'move': + if core.USE_LINK == 'move': try: output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection) if os.path.exists(output_directory): diff --git a/core/utils/torrents.py b/core/utils/torrents.py index c20ba97f..810bfc42 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -85,7 +85,7 @@ def resume_torrent(client_agent, input_hash, input_id, input_name): def remove_torrent(client_agent, input_hash, input_id, input_name): - if core.DELETE_ORIGINAL == 1 or core.USELINK == 'move': + if core.DELETE_ORIGINAL == 1 or core.USE_LINK == 'move': logger.debug('Deleting torrent {0} from {1}'.format(input_name, client_agent)) try: if client_agent == 'utorrent' and core.TORRENT_CLASS != '': From a24367113b95b2ddf9b1d5bef393462a20b29cac Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:14:48 -0500 Subject: [PATCH 16/75] Refactor OUTPUTDIRECTORY -> OUTPUT_DIRECTORY --- TorrentToMedia.py | 6 +++--- core/__init__.py | 6 +++--- core/utils/common.py | 4 ++-- 3 files changed, 8 insertions(+), 8 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 9042fea1..2e316d12 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -114,13 +114,13 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp basename = os.path.basename(input_directory) basename = core.sanitize_name(input_name) \ if input_name == basename else os.path.splitext(core.sanitize_name(input_name))[0] - output_destination = os.path.join(core.OUTPUTDIRECTORY, input_category, basename) + output_destination = os.path.join(core.OUTPUT_DIRECTORY, input_category, basename) elif unique_path: output_destination = os.path.normpath( - core.os.path.join(core.OUTPUTDIRECTORY, input_category, core.sanitize_name(input_name).replace(' ', '.'))) + core.os.path.join(core.OUTPUT_DIRECTORY, input_category, core.sanitize_name(input_name).replace(' ', '.'))) else: output_destination = os.path.normpath( - core.os.path.join(core.OUTPUTDIRECTORY, input_category)) + core.os.path.join(core.OUTPUT_DIRECTORY, input_category)) try: output_destination = output_destination.encode(core.SYS_ENCODING) except UnicodeError: diff --git a/core/__init__.py b/core/__init__.py index 99d3b974..5c04fc4e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -140,7 +140,7 @@ NZB_DEFAULTDIR = None TORRENT_CLIENTAGENT = None TORRENT_CLASS = None USE_LINK = None -OUTPUTDIRECTORY = None +OUTPUT_DIRECTORY = None NOFLATTEN = [] DELETE_ORIGINAL = None TORRENT_CHMOD_DIRECTORY = None @@ -255,7 +255,7 @@ def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USE_LINK, OUTPUTDIRECTORY, \ + SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ @@ -394,7 +394,7 @@ def initialize(section=None): TORRENT_CLIENTAGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym - OUTPUTDIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ + OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULTDIR = CFG['Torrent']['default_downloadDirectory'] CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software NOFLATTEN = (CFG['Torrent']['noFlatten']) diff --git a/core/utils/common.py b/core/utils/common.py index c2f9ef79..5ecdf830 100644 --- a/core/utils/common.py +++ b/core/utils/common.py @@ -102,11 +102,11 @@ def get_dirs(section, subsection, link='hard'): if core.USE_LINK == 'move': try: - output_directory = os.path.join(core.OUTPUTDIRECTORY, subsection) + output_directory = os.path.join(core.OUTPUT_DIRECTORY, subsection) if os.path.exists(output_directory): to_return.extend(process_dir(output_directory, link)) except Exception as e: - logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUTDIRECTORY, e)) + logger.error('Failed to add directories from {0} for post-processing: {1}'.format(core.OUTPUT_DIRECTORY, e)) if not to_return: logger.debug('No directories identified in {0}:{1} for post-processing'.format(section, subsection)) From 4bf842b4f4a3aedae16919f15289a5b66c199c0b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:24:40 -0500 Subject: [PATCH 17/75] Refactor TORRENT_DEFAULTDIR -> TORRENT_DEFAULT_DIRECTORY --- TorrentToMedia.py | 2 +- core/__init__.py | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 2e316d12..7de26883 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -131,7 +131,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp logger.info('Output directory set to: {0}'.format(output_destination)) - if core.SAFE_MODE and output_destination == core.TORRENT_DEFAULTDIR: + if core.SAFE_MODE and output_destination == core.TORRENT_DEFAULT_DIRECTORY: logger.error('The output directory:[{0}] is the Download Directory. ' 'Edit outputDirectory in autoProcessMedia.cfg. Exiting'.format (input_directory)) diff --git a/core/__init__.py b/core/__init__.py index 5c04fc4e..51d7fdb3 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -144,7 +144,7 @@ OUTPUT_DIRECTORY = None NOFLATTEN = [] DELETE_ORIGINAL = None TORRENT_CHMOD_DIRECTORY = None -TORRENT_DEFAULTDIR = None +TORRENT_DEFAULT_DIRECTORY = None TORRENT_RESUME = None TORRENT_RESUME_ON_FAILURE = None @@ -268,7 +268,7 @@ def initialize(section=None): NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ - TORRENT_DEFAULTDIR, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: @@ -395,7 +395,7 @@ def initialize(section=None): TORRENT_CLIENTAGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ - TORRENT_DEFAULTDIR = CFG['Torrent']['default_downloadDirectory'] + TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory'] CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software NOFLATTEN = (CFG['Torrent']['noFlatten']) if isinstance(NOFLATTEN, str): From 5bea8f121ecb50d9d3e0d676b671f7502a74541e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:26:08 -0500 Subject: [PATCH 18/75] Refactor SABNZBD* --- core/__init__.py | 14 +++++++------- core/utils/network.py | 8 ++++---- core/utils/nzbs.py | 8 ++++---- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 51d7fdb3..2e735c10 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -132,9 +132,9 @@ SAFE_MODE = None NOEXTRACTFAILED = None NZB_CLIENTAGENT = None -SABNZBDHOST = None -SABNZBDPORT = None -SABNZBDAPIKEY = None +SABNZBD_HOST = None +SABNZBD_PORT = None +SABNZBD_APIKEY = None NZB_DEFAULTDIR = None TORRENT_CLIENTAGENT = None @@ -260,7 +260,7 @@ def initialize(section=None): TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ - GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBDHOST, SABNZBDPORT, SABNZBDAPIKEY, \ + GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ @@ -382,9 +382,9 @@ def initialize(section=None): wake_up() NZB_CLIENTAGENT = CFG['Nzb']['clientAgent'] # sabnzbd - SABNZBDHOST = CFG['Nzb']['sabnzbd_host'] - SABNZBDPORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accomodate NzbGet - SABNZBDAPIKEY = CFG['Nzb']['sabnzbd_apikey'] + SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] + SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accomodate NzbGet + SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey'] NZB_DEFAULTDIR = CFG['Nzb']['default_downloadDirectory'] GROUPS = CFG['Custom']['remove_group'] if isinstance(GROUPS, str): diff --git a/core/utils/network.py b/core/utils/network.py index 99a89e1e..5a7a5758 100644 --- a/core/utils/network.py +++ b/core/utils/network.py @@ -101,13 +101,13 @@ def find_download(client_agent, download_id): if torrent['hash'] == download_id: return True if client_agent == 'sabnzbd': - if 'http' in core.SABNZBDHOST: - base_url = '{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT) + if 'http' in core.SABNZBD_HOST: + base_url = '{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT) else: - base_url = 'http://{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT) + base_url = 'http://{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT) url = base_url params = { - 'apikey': core.SABNZBDAPIKEY, + 'apikey': core.SABNZBD_APIKEY, 'mode': 'get_files', 'output': 'json', 'value': download_id, diff --git a/core/utils/nzbs.py b/core/utils/nzbs.py index ad3b4e04..23061c96 100644 --- a/core/utils/nzbs.py +++ b/core/utils/nzbs.py @@ -10,13 +10,13 @@ def get_nzoid(input_name): nzoid = None slots = [] logger.debug('Searching for nzoid from SAbnzbd ...') - if 'http' in core.SABNZBDHOST: - base_url = '{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT) + if 'http' in core.SABNZBD_HOST: + base_url = '{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT) else: - base_url = 'http://{0}:{1}/api'.format(core.SABNZBDHOST, core.SABNZBDPORT) + base_url = 'http://{0}:{1}/api'.format(core.SABNZBD_HOST, core.SABNZBD_PORT) url = base_url params = { - 'apikey': core.SABNZBDAPIKEY, + 'apikey': core.SABNZBD_APIKEY, 'mode': 'queue', 'output': 'json', } From a0d8940f70d83083933e152fd017567e233142d0 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:26:34 -0500 Subject: [PATCH 19/75] Refactor NZB_CLIENTAGENT -> NZB_CLIENT_AGENT --- core/__init__.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 2e735c10..7adfc38e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -131,7 +131,7 @@ FORCE_CLEAN = None SAFE_MODE = None NOEXTRACTFAILED = None -NZB_CLIENTAGENT = None +NZB_CLIENT_AGENT = None SABNZBD_HOST = None SABNZBD_PORT = None SABNZBD_APIKEY = None @@ -260,7 +260,7 @@ def initialize(section=None): TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ - GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENTAGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ + GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ @@ -381,7 +381,7 @@ def initialize(section=None): if int(CFG['WakeOnLan']['wake']) == 1: wake_up() - NZB_CLIENTAGENT = CFG['Nzb']['clientAgent'] # sabnzbd + NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accomodate NzbGet SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey'] From fafcdb4ed57e4305a5e8c676c7725deebc98030d Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:35:35 -0500 Subject: [PATCH 20/75] Refactor NZB_DEFAULTDIR -> NZB_DEFAULT_DIRECTORY --- core/__init__.py | 6 +++--- nzbToMedia.py | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 7adfc38e..cdeedda9 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -135,7 +135,7 @@ NZB_CLIENT_AGENT = None SABNZBD_HOST = None SABNZBD_PORT = None SABNZBD_APIKEY = None -NZB_DEFAULTDIR = None +NZB_DEFAULT_DIRECTORY = None TORRENT_CLIENTAGENT = None TORRENT_CLASS = None @@ -268,7 +268,7 @@ def initialize(section=None): NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ - TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULTDIR, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: @@ -385,7 +385,7 @@ def initialize(section=None): SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accomodate NzbGet SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey'] - NZB_DEFAULTDIR = CFG['Nzb']['default_downloadDirectory'] + NZB_DEFAULT_DIRECTORY = CFG['Nzb']['default_downloadDirectory'] GROUPS = CFG['Custom']['remove_group'] if isinstance(GROUPS, str): GROUPS = GROUPS.split(',') diff --git a/nzbToMedia.py b/nzbToMedia.py index fceed9cd..526540d1 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -645,7 +645,7 @@ except NameError: # post-processing def process(input_directory, input_name=None, status=0, client_agent='manual', download_id=None, input_category=None, failure_link=None): - if core.SAFE_MODE and input_directory == core.NZB_DEFAULTDIR: + if core.SAFE_MODE and input_directory == core.NZB_DEFAULT_DIRECTORY: logger.error( 'The input directory:[{0}] is the Default Download Directory. Please configure category directories to prevent processing of other media.'.format( input_directory)) From d973f4955fa242ee9c32b46fef7585a57316fe10 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:36:12 -0500 Subject: [PATCH 21/75] Refactor TORRENT_CLIENTAGENT -> TORRENT_CLIENT_AGENT --- TorrentToMedia.py | 2 +- core/__init__.py | 8 ++++---- core/auto_process/movies.py | 2 +- core/auto_process/tv.py | 2 +- 4 files changed, 7 insertions(+), 7 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 7de26883..fe84e5dc 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -291,7 +291,7 @@ def main(args): core.initialize() # clientAgent for Torrents - client_agent = core.TORRENT_CLIENTAGENT + client_agent = core.TORRENT_CLIENT_AGENT logger.info('#########################################################') logger.info('## ..::[{0}]::.. ##'.format(os.path.basename(__file__))) diff --git a/core/__init__.py b/core/__init__.py index cdeedda9..9ea59001 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -137,7 +137,7 @@ SABNZBD_PORT = None SABNZBD_APIKEY = None NZB_DEFAULT_DIRECTORY = None -TORRENT_CLIENTAGENT = None +TORRENT_CLIENT_AGENT = None TORRENT_CLASS = None USE_LINK = None OUTPUT_DIRECTORY = None @@ -255,7 +255,7 @@ def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENTAGENT, USE_LINK, OUTPUT_DIRECTORY, \ + SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ @@ -392,7 +392,7 @@ def initialize(section=None): if GROUPS == ['']: GROUPS = None - TORRENT_CLIENTAGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other + TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory'] @@ -860,7 +860,7 @@ def initialize(section=None): CATEGORIES = list(set(CATEGORIES)) # create torrent class - TORRENT_CLASS = create_torrent_class(TORRENT_CLIENTAGENT) + TORRENT_CLASS = create_torrent_class(TORRENT_CLIENT_AGENT) # finished initalizing return True diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index ab84627e..7b1fb8e5 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -152,7 +152,7 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', if not release and '.cp(tt' not in video and imdbid: video_name, video_ext = os.path.splitext(video) video2 = '{0}.cp({1}){2}'.format(video_name, imdbid, video_ext) - if not (client_agent in [core.TORRENT_CLIENTAGENT, 'manual'] and core.USE_LINK == 'move-sym'): + if not (client_agent in [core.TORRENT_CLIENT_AGENT, 'manual'] and core.USE_LINK == 'move-sym'): logger.debug('Renaming: {0} to: {1}'.format(video, video2)) os.rename(video, video2) diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 56323894..cc31f94e 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -47,7 +47,7 @@ def process(section, dir_name, input_name=None, failed=False, client_agent='manu delete_failed = int(cfg.get('delete_failed', 0)) nzb_extraction_by = cfg.get('nzbExtractionBy', 'Downloader') process_method = cfg.get('process_method') - if client_agent == core.TORRENT_CLIENTAGENT and core.USE_LINK == 'move-sym': + if client_agent == core.TORRENT_CLIENT_AGENT and core.USE_LINK == 'move-sym': process_method = 'symlink' remote_path = int(cfg.get('remote_path', 0)) wait_for = int(cfg.get('wait_for', 2)) From 2ebe96e04930088b5b99f822cf95b25f4a46d134 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 00:50:00 -0500 Subject: [PATCH 22/75] Refactor REMOTEPATHS -> REMOTE_PATHS --- core/__init__.py | 20 ++++++++++---------- core/utils/paths.py | 4 ++-- nzbToMedia.py | 2 +- 3 files changed, 13 insertions(+), 13 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 9ea59001..9c040377 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -148,7 +148,7 @@ TORRENT_DEFAULT_DIRECTORY = None TORRENT_RESUME = None TORRENT_RESUME_ON_FAILURE = None -REMOTEPATHS = [] +REMOTE_PATHS = [] UTORRENT_WEB_UI = None UTORRENT_USER = None @@ -268,7 +268,7 @@ def initialize(section=None): NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ - TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTEPATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: @@ -425,14 +425,14 @@ def initialize(section=None): QBITTORRENT_USER = CFG['Torrent']['qBittorrentUSR'] # mysecretusr QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr - REMOTEPATHS = CFG['Network']['mount_points'] or [] - if REMOTEPATHS: - if isinstance(REMOTEPATHS, list): - REMOTEPATHS = ','.join(REMOTEPATHS) # fix in case this imported as list. - REMOTEPATHS = [tuple(item.split(',')) for item in - REMOTEPATHS.split('|')] # /volume1/Public/,E:\|/volume2/share/,\\NAS\ - REMOTEPATHS = [(local.strip(), remote.strip()) for local, remote in - REMOTEPATHS] # strip trailing and leading whitespaces + REMOTE_PATHS = CFG['Network']['mount_points'] or [] + if REMOTE_PATHS: + if isinstance(REMOTE_PATHS, list): + REMOTE_PATHS = ','.join(REMOTE_PATHS) # fix in case this imported as list. + REMOTE_PATHS = [tuple(item.split(',')) for item in + REMOTE_PATHS.split('|')] # /volume1/Public/,E:\|/volume2/share/,\\NAS\ + REMOTE_PATHS = [(local.strip(), remote.strip()) for local, remote in + REMOTE_PATHS] # strip trailing and leading whitespaces PLEX_SSL = int(CFG['Plex']['plex_ssl']) PLEX_HOST = CFG['Plex']['plex_host'] diff --git a/core/utils/paths.py b/core/utils/paths.py index ec99a246..dba119f5 100644 --- a/core/utils/paths.py +++ b/core/utils/paths.py @@ -48,9 +48,9 @@ def make_dir(path): def remote_dir(path): - if not core.REMOTEPATHS: + if not core.REMOTE_PATHS: return path - for local, remote in core.REMOTEPATHS: + for local, remote in core.REMOTE_PATHS: if local in path: base_dirs = path.replace(local, '').split(os.sep) if '/' in remote: diff --git a/nzbToMedia.py b/nzbToMedia.py index 526540d1..e8daf4da 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -725,7 +725,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d extract = int(cfg.get('extract', 0)) try: - if int(cfg.get('remote_path')) and not core.REMOTEPATHS: + if int(cfg.get('remote_path')) and not core.REMOTE_PATHS: logger.error('Remote Path is enabled for {0}:{1} but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!'.format( section_name, input_category)) return ProcessResult( From 7e52aec4afdd7766193d0ab88a5c870de1134f0d Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 01:17:08 -0500 Subject: [PATCH 23/75] Refactor *CONTAINER --- core/__init__.py | 46 ++++++++++++++++++++++----------------------- core/transcoder.py | 2 +- core/utils/files.py | 14 +++++++------- 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 9c040377..4cce519d 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -175,11 +175,11 @@ PLEX_PORT = None PLEX_TOKEN = None PLEX_SECTION = [] -EXTCONTAINER = [] -COMPRESSEDCONTAINER = [] -MEDIACONTAINER = [] -AUDIOCONTAINER = [] -METACONTAINER = [] +EXT_CONTAINER = [] +COMPRESSED_CONTAINER = [] +MEDIA_CONTAINER = [] +AUDIO_CONTAINER = [] +META_CONTAINER = [] SECTIONS = [] CATEGORIES = [] @@ -257,15 +257,15 @@ def initialize(section=None): NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ - TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSEDCONTAINER, MEDIACONTAINER, \ - METACONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ + TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ + META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, LOG_DIR, LOG_FILE, \ - NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIOCONTAINER, EXTCONTAINER, TORRENT_CLASS, \ + NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ @@ -467,21 +467,21 @@ def initialize(section=None): pass devnull.close() - COMPRESSEDCONTAINER = [re.compile(r'.r\d{2}$', re.I), - re.compile(r'.part\d+.rar$', re.I), - re.compile('.rar$', re.I)] - COMPRESSEDCONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in CFG['Extensions']['compressedExtensions']] - MEDIACONTAINER = CFG['Extensions']['mediaExtensions'] - AUDIOCONTAINER = CFG['Extensions']['audioExtensions'] - METACONTAINER = CFG['Extensions']['metaExtensions'] # .nfo,.sub,.srt - if isinstance(COMPRESSEDCONTAINER, str): - COMPRESSEDCONTAINER = COMPRESSEDCONTAINER.split(',') - if isinstance(MEDIACONTAINER, str): - MEDIACONTAINER = MEDIACONTAINER.split(',') - if isinstance(AUDIOCONTAINER, str): - AUDIOCONTAINER = AUDIOCONTAINER.split(',') - if isinstance(METACONTAINER, str): - METACONTAINER = METACONTAINER.split(',') + COMPRESSED_CONTAINER = [re.compile(r'.r\d{2}$', re.I), + re.compile(r'.part\d+.rar$', re.I), + re.compile('.rar$', re.I)] + COMPRESSED_CONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in CFG['Extensions']['compressedExtensions']] + MEDIA_CONTAINER = CFG['Extensions']['mediaExtensions'] + AUDIO_CONTAINER = CFG['Extensions']['audioExtensions'] + META_CONTAINER = CFG['Extensions']['metaExtensions'] # .nfo,.sub,.srt + if isinstance(COMPRESSED_CONTAINER, str): + COMPRESSED_CONTAINER = COMPRESSED_CONTAINER.split(',') + if isinstance(MEDIA_CONTAINER, str): + MEDIA_CONTAINER = MEDIA_CONTAINER.split(',') + if isinstance(AUDIO_CONTAINER, str): + AUDIO_CONTAINER = AUDIO_CONTAINER.split(',') + if isinstance(META_CONTAINER, str): + META_CONTAINER = META_CONTAINER.split(',') GETSUBS = int(CFG['Transcoder']['getSubs']) TRANSCODE = int(CFG['Transcoder']['transcode']) diff --git a/core/transcoder.py b/core/transcoder.py index e2bfb33d..52a35292 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -22,7 +22,7 @@ def is_video_good(videofile, status): file_name_ext = os.path.basename(videofile) file_name, file_ext = os.path.splitext(file_name_ext) disable = False - if file_ext not in core.MEDIACONTAINER or not core.FFPROBE or not core.CHECK_MEDIA or file_ext in ['.iso'] or (status > 0 and core.NOEXTRACTFAILED): + if file_ext not in core.MEDIA_CONTAINER or not core.FFPROBE or not core.CHECK_MEDIA or file_ext in ['.iso'] or (status > 0 and core.NOEXTRACTFAILED): disable = True else: test_details, res = get_video_details(core.TEST_FILE) diff --git a/core/utils/files.py b/core/utils/files.py index b753af0c..895125e1 100644 --- a/core/utils/files.py +++ b/core/utils/files.py @@ -20,7 +20,7 @@ def move_file(mediafile, path, link): new_path = None file_ext = os.path.splitext(mediafile)[1] try: - if file_ext in core.AUDIOCONTAINER: + if file_ext in core.AUDIO_CONTAINER: f = beets.mediafile.MediaFile(mediafile) # get artist and album info @@ -29,7 +29,7 @@ def move_file(mediafile, path, link): # create new path new_path = os.path.join(path, '{0} - {1}'.format(sanitize_name(artist), sanitize_name(album))) - elif file_ext in core.MEDIACONTAINER: + elif file_ext in core.MEDIA_CONTAINER: f = guessit.guessit(mediafile) # get title @@ -75,7 +75,7 @@ def is_min_size(input_name, min_size): # audio files we need to check directory size not file size input_size = os.path.getsize(input_name) - if file_ext in core.AUDIOCONTAINER: + if file_ext in core.AUDIO_CONTAINER: try: input_size = get_dir_size(os.path.dirname(input_name)) except Exception: @@ -89,7 +89,7 @@ def is_min_size(input_name, min_size): def is_archive_file(filename): """Check if the filename is allowed for the Archive""" - for regext in core.COMPRESSEDCONTAINER: + for regext in core.COMPRESSED_CONTAINER: if regext.search(filename): return regext.split(filename)[0] return False @@ -109,9 +109,9 @@ def is_media_file(mediafile, media=True, audio=True, meta=True, archives=True, o pass return any([ - (media and file_ext.lower() in core.MEDIACONTAINER), - (audio and file_ext.lower() in core.AUDIOCONTAINER), - (meta and file_ext.lower() in core.METACONTAINER), + (media and file_ext.lower() in core.MEDIA_CONTAINER), + (audio and file_ext.lower() in core.AUDIO_CONTAINER), + (meta and file_ext.lower() in core.META_CONTAINER), (archives and is_archive_file(mediafile)), (other and (file_ext.lower() in otherext or 'all' in otherext)), ]) From 0c98912b7607f2f1f491a317086ec0ecb533a86b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 01:20:41 -0500 Subject: [PATCH 24/75] Refactor PASSWORDSFILE -> PASSWORDS_FILE Refactor DOWNLOADINFO -> DOWNLOAD_INFO --- TorrentToMedia.py | 12 ++++++------ core/__init__.py | 10 +++++----- core/extractor/__init__.py | 4 ++-- nzbToMedia.py | 10 +++++----- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index fe84e5dc..31fa152c 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -22,7 +22,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp root = 0 found_file = 0 - if client_agent != 'manual' and not core.DOWNLOADINFO: + if client_agent != 'manual' and not core.DOWNLOAD_INFO: logger.debug('Adding TORRENT download info for directory {0} to database'.format(input_directory)) my_db = main_db.DBConnection() @@ -328,11 +328,11 @@ def main(args): logger.info('Checking database for download info for {0} ...'.format (os.path.basename(dir_name))) - core.DOWNLOADINFO = core.get_download_info(os.path.basename(dir_name), 0) - if core.DOWNLOADINFO: - client_agent = text_type(core.DOWNLOADINFO[0].get('client_agent', 'manual')) - input_hash = text_type(core.DOWNLOADINFO[0].get('input_hash', '')) - input_id = text_type(core.DOWNLOADINFO[0].get('input_id', '')) + core.DOWNLOAD_INFO = core.get_download_info(os.path.basename(dir_name), 0) + if core.DOWNLOAD_INFO: + client_agent = text_type(core.DOWNLOAD_INFO[0].get('client_agent', 'manual')) + input_hash = text_type(core.DOWNLOAD_INFO[0].get('input_hash', '')) + input_id = text_type(core.DOWNLOAD_INFO[0].get('input_id', '')) logger.info('Found download info for {0}, ' 'setting variables now ...'.format(os.path.basename(dir_name))) else: diff --git a/core/__init__.py b/core/__init__.py index 4cce519d..8929a435 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -236,8 +236,8 @@ CHECK_MEDIA = None NICENESS = [] HWACCEL = False -PASSWORDSFILE = None -DOWNLOADINFO = None +PASSWORDS_FILE = None +DOWNLOAD_INFO = None GROUPS = None USER_SCRIPT_MEDIAEXTENSIONS = None @@ -266,8 +266,8 @@ def initialize(section=None): ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, LOG_DIR, LOG_FILE, \ NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ - DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDSFILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ - USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOADINFO, CHECK_MEDIA, SAFE_MODE, \ + DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ + USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, CHECK_MEDIA, SAFE_MODE, \ TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD @@ -763,7 +763,7 @@ def initialize(section=None): extra = [item for item in codec_alias[codec] if item not in ACODEC3_ALLOW] ACODEC3_ALLOW.extend(extra) - PASSWORDSFILE = CFG['passwords']['PassWordFile'] + PASSWORDS_FILE = CFG['passwords']['PassWordFile'] # Setup FFMPEG, FFPROBE and SEVENZIP locations if platform.system() == 'Windows': diff --git a/core/extractor/__init__.py b/core/extractor/__init__.py index b1090ea6..5d1c51a0 100644 --- a/core/extractor/__init__.py +++ b/core/extractor/__init__.py @@ -90,8 +90,8 @@ def extract(file_path, output_destination): # Create outputDestination folder core.make_dir(output_destination) - if core.PASSWORDSFILE and os.path.isfile(os.path.normpath(core.PASSWORDSFILE)): - passwords = [line.strip() for line in open(os.path.normpath(core.PASSWORDSFILE))] + if core.PASSWORDS_FILE and os.path.isfile(os.path.normpath(core.PASSWORDS_FILE)): + passwords = [line.strip() for line in open(os.path.normpath(core.PASSWORDS_FILE))] else: passwords = [] diff --git a/nzbToMedia.py b/nzbToMedia.py index e8daf4da..f6c7e5db 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -657,7 +657,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d if not download_id and client_agent == 'sabnzbd': download_id = get_nzoid(input_name) - if client_agent != 'manual' and not core.DOWNLOADINFO: + if client_agent != 'manual' and not core.DOWNLOAD_INFO: logger.debug('Adding NZB download info for directory {0} to database'.format(input_directory)) my_db = main_db.DBConnection() @@ -899,13 +899,13 @@ def main(args, section=None): logger.info('Starting manual run for {0}:{1} - Folder: {2}'.format(section, subsection, dir_name)) logger.info('Checking database for download info for {0} ...'.format(os.path.basename(dir_name))) - core.DOWNLOADINFO = get_download_info(os.path.basename(dir_name), 0) - if core.DOWNLOADINFO: + core.DOWNLOAD_INFO = get_download_info(os.path.basename(dir_name), 0) + if core.DOWNLOAD_INFO: logger.info('Found download info for {0}, ' 'setting variables now ...'.format (os.path.basename(dir_name))) - client_agent = text_type(core.DOWNLOADINFO[0].get('client_agent', 'manual')) - download_id = text_type(core.DOWNLOADINFO[0].get('input_id', '')) + client_agent = text_type(core.DOWNLOAD_INFO[0].get('client_agent', 'manual')) + download_id = text_type(core.DOWNLOAD_INFO[0].get('input_id', '')) else: logger.info('Unable to locate download info for {0}, ' 'continuing to try and process this release ...'.format From 1404464ef9752b2cb7c6a5d289b549477be62b87 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 02:25:04 -0500 Subject: [PATCH 25/75] Refactor locale configuration --- core/__init__.py | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 8929a435..e5635589 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -251,6 +251,18 @@ USER_SCRIPT_RUNONCE = None __INITIALIZED__ = False +def configure_logging(): + global LOG_FILE + global LOG_DIR + + if 'NTM_LOGFILE' in os.environ: + LOG_FILE = os.environ['NTM_LOGFILE'] + LOG_DIR = os.path.split(LOG_FILE)[0] + + if not make_dir(LOG_DIR): + print('No log folder, logging to screen only') + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ @@ -264,7 +276,7 @@ def initialize(section=None): DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ - SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, LOG_DIR, LOG_FILE, \ + SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, CHECK_MEDIA, SAFE_MODE, \ @@ -274,12 +286,7 @@ def initialize(section=None): if __INITIALIZED__: return False - if 'NTM_LOGFILE' in os.environ: - LOG_FILE = os.environ['NTM_LOGFILE'] - LOG_DIR = os.path.split(LOG_FILE)[0] - - if not make_dir(LOG_DIR): - print('No log folder, logging to screen only') + configure_logging() MYAPP = RunningProcess() while MYAPP.alreadyrunning(): From e0de964fdafa87acf1e26f10794464cecfda1842 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 02:27:22 -0500 Subject: [PATCH 26/75] Refactor process configuration --- core/__init__.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e5635589..d442bdbd 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -263,6 +263,15 @@ def configure_logging(): print('No log folder, logging to screen only') +def configure_process(): + global MYAPP + + MYAPP = RunningProcess() + while MYAPP.alreadyrunning(): + print('Waiting for existing session to end') + time.sleep(30) + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ @@ -287,11 +296,7 @@ def initialize(section=None): return False configure_logging() - - MYAPP = RunningProcess() - while MYAPP.alreadyrunning(): - print('Waiting for existing session to end') - time.sleep(30) + configure_process() try: locale.setlocale(locale.LC_ALL, '') From 13846db0b6f22d988fcbf5187360956fc7bfed90 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 02:28:41 -0500 Subject: [PATCH 27/75] Refactor locale configuration --- core/__init__.py | 55 ++++++++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index d442bdbd..7633646c 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -272,31 +272,8 @@ def configure_process(): time.sleep(30) -def initialize(section=None): - global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ - NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ - NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ - NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ - TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ - META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ - __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ - GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ - DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ - VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ - ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ - SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ - DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ - USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, CHECK_MEDIA, SAFE_MODE, \ - TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ - PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD - - if __INITIALIZED__: - return False - - configure_logging() - configure_process() +def configure_locale(): + global SYS_ENCODING try: locale.setlocale(locale.LC_ALL, '') @@ -325,6 +302,34 @@ def initialize(section=None): else: sys.exit(1) + +def initialize(section=None): + global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ + NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ + NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ + SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ + NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ + TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ + META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ + __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ + GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ + DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ + VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ + ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ + SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ + NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ + DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ + USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, CHECK_MEDIA, SAFE_MODE, \ + TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD + + if __INITIALIZED__: + return False + + configure_logging() + configure_process() + configure_locale() + # init logging logger.ntm_log_instance.init_logging() From a31683f7e58deaffb60d79662cfc37a44b0d635d Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 02:33:28 -0500 Subject: [PATCH 28/75] Refactor migration configuration --- core/__init__.py | 39 +++++++++++++++++++++++---------------- 1 file changed, 23 insertions(+), 16 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 7633646c..9afadb23 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -303,10 +303,31 @@ def configure_locale(): sys.exit(1) +def configure_migration(): + global CONFIG_FILE + global CFG + + # run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options. + if not config.migrate(): + logger.error('Unable to migrate config file {0}, exiting ...'.format(CONFIG_FILE)) + if 'NZBOP_SCRIPTDIR' in os.environ: + pass # We will try and read config from Environment. + else: + sys.exit(-1) + + # run migrate to convert NzbGet data from old cfg style to new cfg style + if 'NZBOP_SCRIPTDIR' in os.environ: + CFG = config.addnzbget() + + else: # load newly migrated config + logger.info('Loading config from [{0}]'.format(CONFIG_FILE)) + CFG = config() + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ - NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, CFG, \ + NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ @@ -333,21 +354,7 @@ def initialize(section=None): # init logging logger.ntm_log_instance.init_logging() - # run migrate to convert old cfg to new style cfg plus fix any cfg missing values/options. - if not config.migrate(): - logger.error('Unable to migrate config file {0}, exiting ...'.format(CONFIG_FILE)) - if 'NZBOP_SCRIPTDIR' in os.environ: - pass # We will try and read config from Environment. - else: - sys.exit(-1) - - # run migrate to convert NzbGet data from old cfg style to new cfg style - if 'NZBOP_SCRIPTDIR' in os.environ: - CFG = config.addnzbget() - - else: # load newly migrated config - logger.info('Loading config from [{0}]'.format(CONFIG_FILE)) - CFG = config() + configure_migration() # Enable/Disable DEBUG Logging LOG_DEBUG = int(CFG['General']['log_debug']) From ca17c7a562c5da38166d61b6e11d1efa66e9a242 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 02:38:00 -0500 Subject: [PATCH 29/75] Refactor logging configuration --- core/__init__.py | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 9afadb23..1e4454b0 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -324,6 +324,23 @@ def configure_migration(): CFG = config() +def configure_logging_part_2(): + global LOG_DB + global LOG_DEBUG + global LOG_ENV + global LOG_GIT + + # Enable/Disable DEBUG Logging + LOG_DB = int(CFG['General']['log_db']) + LOG_DEBUG = int(CFG['General']['log_debug']) + LOG_ENV = int(CFG['General']['log_env']) + LOG_GIT = int(CFG['General']['log_git']) + + if LOG_ENV: + for item in os.environ: + logger.info('{0}: {1}'.format(item, os.environ[item]), 'ENVIRONMENT') + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ @@ -331,17 +348,17 @@ def initialize(section=None): SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ - META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, LOG_GIT, GROUPS, SEVENZIP, CONCAT, VCRF, \ + META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ - VFRAMERATE, LOG_DB, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ + VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - NICENESS, LOG_DEBUG, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ + NICENESS, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, CHECK_MEDIA, SAFE_MODE, \ - TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, LOG_ENV, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: @@ -355,16 +372,7 @@ def initialize(section=None): logger.ntm_log_instance.init_logging() configure_migration() - - # Enable/Disable DEBUG Logging - LOG_DEBUG = int(CFG['General']['log_debug']) - LOG_DB = int(CFG['General']['log_db']) - LOG_ENV = int(CFG['General']['log_env']) - LOG_GIT = int(CFG['General']['log_git']) - - if LOG_ENV: - for item in os.environ: - logger.info('{0}: {1}'.format(item, os.environ[item]), 'ENVIRONMENT') + configure_logging_part_2() # initialize the main SB database main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) From 2512218d4a4a66d1cc5f2d168d9e1314098adeaa Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:25:45 -0500 Subject: [PATCH 30/75] Refactor general configuration --- core/__init__.py | 52 +++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 1e4454b0..e9a22e9f 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -341,23 +341,50 @@ def configure_logging_part_2(): logger.info('{0}: {1}'.format(item, os.environ[item]), 'ENVIRONMENT') +def configure_general(): + global VERSION_NOTIFY + global AUTO_UPDATE + global GIT_REPO + global GIT_PATH + global GIT_USER + global GIT_BRANCH + global FORCE_CLEAN + global FFMPEG_PATH + global CHECK_MEDIA + global SAFE_MODE + global NOEXTRACTFAILED + + # Set Version and GIT variables + VERSION_NOTIFY = int(CFG['General']['version_notify']) + AUTO_UPDATE = int(CFG['General']['auto_update']) + GIT_REPO = 'nzbToMedia' + GIT_PATH = CFG['General']['git_path'] + GIT_USER = CFG['General']['git_user'] or 'clinton-hall' + GIT_BRANCH = CFG['General']['git_branch'] or 'master' + FORCE_CLEAN = int(CFG['General']['force_clean']) + FFMPEG_PATH = CFG['General']['ffmpeg_path'] + CHECK_MEDIA = int(CFG['General']['check_media']) + SAFE_MODE = int(CFG['General']['safe_mode']) + NOEXTRACTFAILED = int(CFG['General']['no_extract_failed']) + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ - NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, NOEXTRACTFAILED, SHOWEXTRACT, \ - NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, VERSION_NOTIFY, SYS_ARGV, \ + NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ + NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, GROUPS, SEVENZIP, CONCAT, VCRF, \ - __INITIALIZED__, AUTO_UPDATE, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, GIT_PATH, GIT_USER, \ - GIT_BRANCH, GIT_REPO, SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ + __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ + SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - NICENESS, FORCE_CLEAN, FFMPEG_PATH, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ + NICENESS, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ - USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, CHECK_MEDIA, SAFE_MODE, \ + USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD @@ -377,18 +404,7 @@ def initialize(section=None): # initialize the main SB database main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) - # Set Version and GIT variables - VERSION_NOTIFY = int(CFG['General']['version_notify']) - AUTO_UPDATE = int(CFG['General']['auto_update']) - GIT_REPO = 'nzbToMedia' - GIT_PATH = CFG['General']['git_path'] - GIT_USER = CFG['General']['git_user'] or 'clinton-hall' - GIT_BRANCH = CFG['General']['git_branch'] or 'master' - FORCE_CLEAN = int(CFG['General']['force_clean']) - FFMPEG_PATH = CFG['General']['ffmpeg_path'] - CHECK_MEDIA = int(CFG['General']['check_media']) - SAFE_MODE = int(CFG['General']['safe_mode']) - NOEXTRACTFAILED = int(CFG['General']['no_extract_failed']) + configure_general() # Check for updates via GitHUB if version_check.CheckVersion().check_for_new_version(): From c9e9d9748b3770d86fc124991e258a2960dbfee0 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:29:58 -0500 Subject: [PATCH 31/75] Refactor updates configuration --- core/__init__.py | 49 ++++++++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e9a22e9f..b6cf596e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -343,7 +343,6 @@ def configure_logging_part_2(): def configure_general(): global VERSION_NOTIFY - global AUTO_UPDATE global GIT_REPO global GIT_PATH global GIT_USER @@ -356,7 +355,6 @@ def configure_general(): # Set Version and GIT variables VERSION_NOTIFY = int(CFG['General']['version_notify']) - AUTO_UPDATE = int(CFG['General']['auto_update']) GIT_REPO = 'nzbToMedia' GIT_PATH = CFG['General']['git_path'] GIT_USER = CFG['General']['git_user'] or 'clinton-hall' @@ -368,6 +366,32 @@ def configure_general(): NOEXTRACTFAILED = int(CFG['General']['no_extract_failed']) +def configure_updates(): + global AUTO_UPDATE + + AUTO_UPDATE = int(CFG['General']['auto_update']) + + # Check for updates via GitHUB + if version_check.CheckVersion().check_for_new_version(): + if AUTO_UPDATE == 1: + logger.info('Auto-Updating nzbToMedia, Please wait ...') + updated = version_check.CheckVersion().update() + if updated: + # restart nzbToMedia + try: + del MYAPP + except Exception: + pass + restart() + else: + logger.error('Update wasn\'t successful, not restarting. Check your log for more information.') + + # Set Current Version + logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format + (version=NZBTOMEDIA_VERSION, branch=GIT_BRANCH, + system=platform.system(), release=platform.release())) + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -405,26 +429,7 @@ def initialize(section=None): main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) configure_general() - - # Check for updates via GitHUB - if version_check.CheckVersion().check_for_new_version(): - if AUTO_UPDATE == 1: - logger.info('Auto-Updating nzbToMedia, Please wait ...') - updated = version_check.CheckVersion().update() - if updated: - # restart nzbToMedia - try: - del MYAPP - except Exception: - pass - restart() - else: - logger.error('Update wasn\'t successful, not restarting. Check your log for more information.') - - # Set Current Version - logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format - (version=NZBTOMEDIA_VERSION, branch=GIT_BRANCH, - system=platform.system(), release=platform.release())) + configure_updates() if int(CFG['WakeOnLan']['wake']) == 1: wake_up() From 750c203216b635a99842ed312ede0cfdcef07258 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:32:18 -0500 Subject: [PATCH 32/75] Fix CheckVersion instance creation --- core/__init__.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index b6cf596e..f36767dc 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -370,12 +370,13 @@ def configure_updates(): global AUTO_UPDATE AUTO_UPDATE = int(CFG['General']['auto_update']) + version_checker = version_check.CheckVersion() # Check for updates via GitHUB - if version_check.CheckVersion().check_for_new_version(): + if version_checker.check_for_new_version(): if AUTO_UPDATE == 1: logger.info('Auto-Updating nzbToMedia, Please wait ...') - updated = version_check.CheckVersion().update() + updated = version_checker.update() if updated: # restart nzbToMedia try: From bd4c8303136a295a3a33d6478381b55c6defca8b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:32:47 -0500 Subject: [PATCH 33/75] Fix version check conditional --- core/__init__.py | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index f36767dc..3875a5b2 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -373,19 +373,17 @@ def configure_updates(): version_checker = version_check.CheckVersion() # Check for updates via GitHUB - if version_checker.check_for_new_version(): - if AUTO_UPDATE == 1: - logger.info('Auto-Updating nzbToMedia, Please wait ...') - updated = version_checker.update() - if updated: - # restart nzbToMedia - try: - del MYAPP - except Exception: - pass - restart() - else: - logger.error('Update wasn\'t successful, not restarting. Check your log for more information.') + if version_checker.check_for_new_version() and AUTO_UPDATE: + logger.info('Auto-Updating nzbToMedia, Please wait ...') + if version_checker.update(): + # restart nzbToMedia + try: + del MYAPP + except Exception: + pass + restart() + else: + logger.error('Update wasn\'t successful, not restarting. Check your log for more information.') # Set Current Version logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format From 2c963f1ffe9f59818c5f346a4d558ff386e395d4 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:35:11 -0500 Subject: [PATCH 34/75] Fix error log --- core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/__init__.py b/core/__init__.py index 3875a5b2..d6757e73 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -383,7 +383,7 @@ def configure_updates(): pass restart() else: - logger.error('Update wasn\'t successful, not restarting. Check your log for more information.') + logger.error('Update failed, not restarting. Check your log for more information.') # Set Current Version logger.info('nzbToMedia Version:{version} Branch:{branch} ({system} {release})'.format From feffa0da41005adb78f0f8407748edc036cfb29e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:36:50 -0500 Subject: [PATCH 35/75] Refactor wake on lan configuration --- core/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index d6757e73..fdbed9e8 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -391,6 +391,11 @@ def configure_updates(): system=platform.system(), release=platform.release())) +def configure_wake_on_lan(): + if int(CFG['WakeOnLan']['wake']): + wake_up() + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -429,9 +434,7 @@ def initialize(section=None): configure_general() configure_updates() - - if int(CFG['WakeOnLan']['wake']) == 1: - wake_up() + configure_wake_on_lan() NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] From b3870e0d07a19c41605181b7a59c26367ce6c949 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:42:51 -0500 Subject: [PATCH 36/75] Refactor nzbs configuration --- core/__init__.py | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index fdbed9e8..e633826f 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -396,6 +396,20 @@ def configure_wake_on_lan(): wake_up() +def configure_nzbs(): + global NZB_CLIENT_AGENT + global SABNZBD_HOST + global SABNZBD_PORT + global SABNZBD_APIKEY + global NZB_DEFAULT_DIRECTORY + + NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd + SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] + SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accommodate NzbGet + SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey'] + NZB_DEFAULT_DIRECTORY = CFG['Nzb']['default_downloadDirectory'] + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -405,7 +419,7 @@ def initialize(section=None): TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, GROUPS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ - SYS_ENCODING, NZB_CLIENT_AGENT, SABNZBD_HOST, SABNZBD_PORT, SABNZBD_APIKEY, \ + SYS_ENCODING, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ @@ -413,7 +427,7 @@ def initialize(section=None): NICENESS, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ - TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, NZB_DEFAULT_DIRECTORY, REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD if __INITIALIZED__: @@ -435,12 +449,8 @@ def initialize(section=None): configure_general() configure_updates() configure_wake_on_lan() + configure_nzbs() - NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd - SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] - SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accomodate NzbGet - SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey'] - NZB_DEFAULT_DIRECTORY = CFG['Nzb']['default_downloadDirectory'] GROUPS = CFG['Custom']['remove_group'] if isinstance(GROUPS, str): GROUPS = GROUPS.split(',') From 62aca7ed3c572b208c85c0efd3d4b780cbbae48e Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 03:45:13 -0500 Subject: [PATCH 37/75] Refactor groups configuration --- core/__init__.py | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e633826f..43e3a29c 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -410,6 +410,18 @@ def configure_nzbs(): NZB_DEFAULT_DIRECTORY = CFG['Nzb']['default_downloadDirectory'] +def configure_groups(): + global GROUPS + + GROUPS = CFG['Custom']['remove_group'] + + if isinstance(GROUPS, str): + GROUPS = GROUPS.split(',') + + if GROUPS == ['']: + GROUPS = None + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -417,7 +429,7 @@ def initialize(section=None): SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ - META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, GROUPS, SEVENZIP, CONCAT, VCRF, \ + META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ SYS_ENCODING, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ @@ -451,12 +463,6 @@ def initialize(section=None): configure_wake_on_lan() configure_nzbs() - GROUPS = CFG['Custom']['remove_group'] - if isinstance(GROUPS, str): - GROUPS = GROUPS.split(',') - if GROUPS == ['']: - GROUPS = None - TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ From 003d181bb0a79aba14f66809292456957f99093c Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 11:10:27 -0500 Subject: [PATCH 38/75] Refactor torrents configuration --- core/__init__.py | 109 ++++++++++++++++++++++++++++++----------------- 1 file changed, 69 insertions(+), 40 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 43e3a29c..308f4059 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -422,46 +422,32 @@ def configure_groups(): GROUPS = None -def initialize(section=None): - global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ - NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ - NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, TORRENT_CLIENT_AGENT, USE_LINK, OUTPUT_DIRECTORY, \ - NOFLATTEN, UTORRENT_PASSWORD, UTORRENT_USER, UTORRENT_WEB_UI, DELUGE_HOST, DELUGE_PORT, DELUGE_USER, DELUGE_PASSWORD, VLEVEL, \ - TRANSMISSION_HOST, TRANSMISSION_PORT, TRANSMISSION_PASSWORD, TRANSMISSION_USER, COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ - META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, SEVENZIP, CONCAT, VCRF, \ - __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ - SYS_ENCODING, \ - DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ - VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ - ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ - SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - NICENESS, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ - DELETE_ORIGINAL, TORRENT_CHMOD_DIRECTORY, PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ - USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ - TORRENT_DEFAULT_DIRECTORY, TORRENT_RESUME_ON_FAILURE, REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ - PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, TORRENT_RESUME, PAR2CMD, QBITTORRENT_HOST, QBITTORRENT_PORT, QBITTORRENT_USER, QBITTORRENT_PASSWORD - - if __INITIALIZED__: - return False - - configure_logging() - configure_process() - configure_locale() - - # init logging - logger.ntm_log_instance.init_logging() - - configure_migration() - configure_logging_part_2() - - # initialize the main SB database - main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) - - configure_general() - configure_updates() - configure_wake_on_lan() - configure_nzbs() +def configure_torrents(): + global TORRENT_CLIENT_AGENT + global USE_LINK + global OUTPUT_DIRECTORY + global TORRENT_DEFAULT_DIRECTORY + global CATEGORIES + global NOFLATTEN + global DELETE_ORIGINAL + global TORRENT_CHMOD_DIRECTORY + global TORRENT_RESUME_ON_FAILURE + global TORRENT_RESUME + global UTORRENT_WEB_UI + global UTORRENT_USER + global UTORRENT_PASSWORD + global TRANSMISSION_HOST + global TRANSMISSION_PORT + global TRANSMISSION_USER + global TRANSMISSION_PASSWORD + global DELUGE_HOST + global DELUGE_PORT + global DELUGE_USER + global DELUGE_PASSWORD + global QBITTORRENT_HOST + global QBITTORRENT_PORT + global QBITTORRENT_USER + global QBITTORRENT_PASSWORD TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym @@ -496,6 +482,49 @@ def initialize(section=None): QBITTORRENT_USER = CFG['Torrent']['qBittorrentUSR'] # mysecretusr QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr + +def initialize(section=None): + global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ + NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ + NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ + SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, \ + VLEVEL, \ + COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ + META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, SEVENZIP, CONCAT, VCRF, \ + __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ + SYS_ENCODING, \ + DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ + VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ + ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ + SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ + NICENESS, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ + PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ + USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ + REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, PAR2CMD + + if __INITIALIZED__: + return False + + configure_logging() + configure_process() + configure_locale() + + # init logging + logger.ntm_log_instance.init_logging() + + configure_migration() + configure_logging_part_2() + + # initialize the main SB database + main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) + + configure_general() + configure_updates() + configure_wake_on_lan() + configure_nzbs() + configure_torrents() + REMOTE_PATHS = CFG['Network']['mount_points'] or [] if REMOTE_PATHS: if isinstance(REMOTE_PATHS, list): From c587a137a570a23f47f552ba19b852d5dbce8479 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 11:41:38 -0500 Subject: [PATCH 39/75] Refactor remote paths configuration --- core/__init__.py | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 308f4059..a1e47591 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -483,6 +483,20 @@ def configure_torrents(): QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr +def configure_remote_paths(): + global REMOTE_PATHS + + REMOTE_PATHS = CFG['Network']['mount_points'] or [] + + if REMOTE_PATHS: + if isinstance(REMOTE_PATHS, list): + REMOTE_PATHS = ','.join(REMOTE_PATHS) # fix in case this imported as list. + REMOTE_PATHS = [tuple(item.split(',')) for item in + REMOTE_PATHS.split('|')] # /volume1/Public/,E:\|/volume2/share/,\\NAS\ + REMOTE_PATHS = [(local.strip(), remote.strip()) for local, remote in + REMOTE_PATHS] # strip trailing and leading whitespaces + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -500,7 +514,7 @@ def initialize(section=None): NICENESS, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ - REMOTE_PATHS, PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ + PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, PAR2CMD if __INITIALIZED__: @@ -524,15 +538,7 @@ def initialize(section=None): configure_wake_on_lan() configure_nzbs() configure_torrents() - - REMOTE_PATHS = CFG['Network']['mount_points'] or [] - if REMOTE_PATHS: - if isinstance(REMOTE_PATHS, list): - REMOTE_PATHS = ','.join(REMOTE_PATHS) # fix in case this imported as list. - REMOTE_PATHS = [tuple(item.split(',')) for item in - REMOTE_PATHS.split('|')] # /volume1/Public/,E:\|/volume2/share/,\\NAS\ - REMOTE_PATHS = [(local.strip(), remote.strip()) for local, remote in - REMOTE_PATHS] # strip trailing and leading whitespaces + configure_remote_paths() PLEX_SSL = int(CFG['Plex']['plex_ssl']) PLEX_HOST = CFG['Plex']['plex_host'] From a5d51d6e5a752754b4d7fda70d19b3e3308a5917 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 11:45:38 -0500 Subject: [PATCH 40/75] Use generator exp for remote paths --- core/__init__.py | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index a1e47591..b3d02541 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -491,10 +491,18 @@ def configure_remote_paths(): if REMOTE_PATHS: if isinstance(REMOTE_PATHS, list): REMOTE_PATHS = ','.join(REMOTE_PATHS) # fix in case this imported as list. - REMOTE_PATHS = [tuple(item.split(',')) for item in - REMOTE_PATHS.split('|')] # /volume1/Public/,E:\|/volume2/share/,\\NAS\ - REMOTE_PATHS = [(local.strip(), remote.strip()) for local, remote in - REMOTE_PATHS] # strip trailing and leading whitespaces + + REMOTE_PATHS = ( + # /volume1/Public/,E:\|/volume2/share/,\\NAS\ + tuple(item.split(',')) + for item in REMOTE_PATHS.split('|') + ) + + REMOTE_PATHS = [ + # strip trailing and leading whitespaces + (local.strip(), remote.strip()) + for local, remote in REMOTE_PATHS + ] def initialize(section=None): From f67f8a32aa8fc80371705d7d158b7f0b8b0e0f17 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 11:48:49 -0500 Subject: [PATCH 41/75] Refactor plex configuration --- core/__init__.py | 35 ++++++++++++++++++++++++----------- 1 file changed, 24 insertions(+), 11 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index b3d02541..fbdfeb21 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -505,6 +505,28 @@ def configure_remote_paths(): ] +def configure_plex(): + global PLEX_SSL + global PLEX_HOST + global PLEX_PORT + global PLEX_TOKEN + global PLEX_SECTION + + PLEX_SSL = int(CFG['Plex']['plex_ssl']) + PLEX_HOST = CFG['Plex']['plex_host'] + PLEX_PORT = CFG['Plex']['plex_port'] + PLEX_TOKEN = CFG['Plex']['plex_token'] + PLEX_SECTION = CFG['Plex']['plex_sections'] or [] + + if PLEX_SECTION: + if isinstance(PLEX_SECTION, list): + PLEX_SECTION = ','.join(PLEX_SECTION) # fix in case this imported as list. + PLEX_SECTION = [ + tuple(item.split(',')) + for item in PLEX_SECTION.split('|') + ] + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -523,7 +545,7 @@ def initialize(section=None): PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ - PLEX_SSL, PLEX_HOST, PLEX_PORT, PLEX_TOKEN, PLEX_SECTION, PAR2CMD + PAR2CMD if __INITIALIZED__: return False @@ -547,16 +569,7 @@ def initialize(section=None): configure_nzbs() configure_torrents() configure_remote_paths() - - PLEX_SSL = int(CFG['Plex']['plex_ssl']) - PLEX_HOST = CFG['Plex']['plex_host'] - PLEX_PORT = CFG['Plex']['plex_port'] - PLEX_TOKEN = CFG['Plex']['plex_token'] - PLEX_SECTION = CFG['Plex']['plex_sections'] or [] - if PLEX_SECTION: - if isinstance(PLEX_SECTION, list): - PLEX_SECTION = ','.join(PLEX_SECTION) # fix in case this imported as list. - PLEX_SECTION = [tuple(item.split(',')) for item in PLEX_SECTION.split('|')] + configure_plex() devnull = open(os.devnull, 'w') try: From e0c55c4f844acb641c7e428582e26a6ae6833507 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 11:51:14 -0500 Subject: [PATCH 42/75] Refactor niceness configuration --- core/__init__.py | 53 ++++++++++++++++++++++++++---------------------- 1 file changed, 29 insertions(+), 24 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index fbdfeb21..c5cfd7a1 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -527,6 +527,33 @@ def configure_plex(): ] +def configure_niceness(): + global NICENESS + + devnull = open(os.devnull, 'w') + try: + subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate() + NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))]) + except Exception: + pass + try: + subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate() + try: + NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))]) + except Exception: + pass + try: + if 'ionice' in NICENESS: + NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) + else: + NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) + except Exception: + pass + except Exception: + pass + devnull.close() + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ @@ -541,7 +568,7 @@ def initialize(section=None): VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - NICENESS, FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ + FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ @@ -570,29 +597,7 @@ def initialize(section=None): configure_torrents() configure_remote_paths() configure_plex() - - devnull = open(os.devnull, 'w') - try: - subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate() - NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))]) - except Exception: - pass - try: - subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate() - try: - NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))]) - except Exception: - pass - try: - if 'ionice' in NICENESS: - NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) - else: - NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) - except Exception: - pass - except Exception: - pass - devnull.close() + configure_niceness() COMPRESSED_CONTAINER = [re.compile(r'.r\d{2}$', re.I), re.compile(r'.part\d+.rar$', re.I), From ddf15247e341e14cac97bba24d0301d526498958 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 11:53:29 -0500 Subject: [PATCH 43/75] Use context manager instead of assignment --- core/__init__.py | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index c5cfd7a1..730068a4 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -530,28 +530,27 @@ def configure_plex(): def configure_niceness(): global NICENESS - devnull = open(os.devnull, 'w') - try: - subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate() - NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))]) - except Exception: - pass - try: - subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate() + with open(os.devnull, 'w') as devnull: try: - NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))]) + subprocess.Popen(['nice'], stdout=devnull, stderr=devnull).communicate() + NICENESS.extend(['nice', '-n{0}'.format(int(CFG['Posix']['niceness']))]) except Exception: pass try: - if 'ionice' in NICENESS: - NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) - else: - NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) + subprocess.Popen(['ionice'], stdout=devnull, stderr=devnull).communicate() + try: + NICENESS.extend(['ionice', '-c{0}'.format(int(CFG['Posix']['ionice_class']))]) + except Exception: + pass + try: + if 'ionice' in NICENESS: + NICENESS.extend(['-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) + else: + NICENESS.extend(['ionice', '-n{0}'.format(int(CFG['Posix']['ionice_classdata']))]) + except Exception: + pass except Exception: pass - except Exception: - pass - devnull.close() def initialize(section=None): From 10710ffd4cc35e11d794f1f523d98568aac27e98 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:00:00 -0500 Subject: [PATCH 44/75] Refactor container configuration --- core/__init__.py | 50 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 730068a4..f7c7f867 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -553,21 +553,48 @@ def configure_niceness(): pass +def configure_containers(): + global COMPRESSED_CONTAINER + global MEDIA_CONTAINER + global AUDIO_CONTAINER + global META_CONTAINER + + COMPRESSED_CONTAINER = [re.compile(r'.r\d{2}$', re.I), + re.compile(r'.part\d+.rar$', re.I), + re.compile('.rar$', re.I)] + COMPRESSED_CONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in + CFG['Extensions']['compressedExtensions']] + MEDIA_CONTAINER = CFG['Extensions']['mediaExtensions'] + AUDIO_CONTAINER = CFG['Extensions']['audioExtensions'] + META_CONTAINER = CFG['Extensions']['metaExtensions'] # .nfo,.sub,.srt + + if isinstance(COMPRESSED_CONTAINER, str): + COMPRESSED_CONTAINER = COMPRESSED_CONTAINER.split(',') + + if isinstance(MEDIA_CONTAINER, str): + MEDIA_CONTAINER = MEDIA_CONTAINER.split(',') + + if isinstance(AUDIO_CONTAINER, str): + AUDIO_CONTAINER = AUDIO_CONTAINER.split(',') + + if isinstance(META_CONTAINER, str): + META_CONTAINER = META_CONTAINER.split(',') + + def initialize(section=None): global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, \ VLEVEL, \ - COMPRESSED_CONTAINER, MEDIA_CONTAINER, \ - META_CONTAINER, SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, SEVENZIP, CONCAT, VCRF, \ + SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, SEVENZIP, CONCAT, VCRF, \ __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ SYS_ENCODING, \ DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - FFMPEG, FFPROBE, AUDIO_CONTAINER, EXT_CONTAINER, TORRENT_CLASS, \ + FFMPEG, FFPROBE, EXT_CONTAINER, TORRENT_CLASS, \ PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ @@ -597,22 +624,7 @@ def initialize(section=None): configure_remote_paths() configure_plex() configure_niceness() - - COMPRESSED_CONTAINER = [re.compile(r'.r\d{2}$', re.I), - re.compile(r'.part\d+.rar$', re.I), - re.compile('.rar$', re.I)] - COMPRESSED_CONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in CFG['Extensions']['compressedExtensions']] - MEDIA_CONTAINER = CFG['Extensions']['mediaExtensions'] - AUDIO_CONTAINER = CFG['Extensions']['audioExtensions'] - META_CONTAINER = CFG['Extensions']['metaExtensions'] # .nfo,.sub,.srt - if isinstance(COMPRESSED_CONTAINER, str): - COMPRESSED_CONTAINER = COMPRESSED_CONTAINER.split(',') - if isinstance(MEDIA_CONTAINER, str): - MEDIA_CONTAINER = MEDIA_CONTAINER.split(',') - if isinstance(AUDIO_CONTAINER, str): - AUDIO_CONTAINER = AUDIO_CONTAINER.split(',') - if isinstance(META_CONTAINER, str): - META_CONTAINER = META_CONTAINER.split(',') + configure_containers() GETSUBS = int(CFG['Transcoder']['getSubs']) TRANSCODE = int(CFG['Transcoder']['transcode']) From 2d0b5e706b73a9036cde8c7946a3b588c4c80243 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:19:54 -0500 Subject: [PATCH 45/75] Refactor transcoder configuration --- core/__init__.py | 130 +++++++++++++++++++++++++++++++---------------- 1 file changed, 86 insertions(+), 44 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index f7c7f867..c84d94f1 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -581,50 +581,49 @@ def configure_containers(): META_CONTAINER = META_CONTAINER.split(',') -def initialize(section=None): - global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ - NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ - NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, \ - VLEVEL, \ - SECTIONS, ALL_FORKS, TEST_FILE, GENERALOPTS, SEVENZIP, CONCAT, VCRF, \ - __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, TRANSCODE, DEFAULTS, \ - SYS_ENCODING, \ - DUPLICATE, IGNOREEXTENSIONS, VEXTENSION, OUTPUTVIDEOPATH, PROCESSOUTPUT, VCODEC, VCODEC_ALLOW, VPRESET, \ - VFRAMERATE, VBITRATE, VRESOLUTION, ALANGUAGE, AINCLUDE, ACODEC, ACODEC_ALLOW, ABITRATE, FAILED, \ - ACODEC2, ACODEC2_ALLOW, ABITRATE2, ACODEC3, ACODEC3_ALLOW, ABITRATE3, ALLOWSUBS, SEXTRACT, SEMBED, SLANGUAGES, \ - SINCLUDE, SUBSDIR, SCODEC, OUTPUTFASTSTART, OUTPUTQUALITYPERCENT, BURN, GETSUBS, HWACCEL, \ - FFMPEG, FFPROBE, EXT_CONTAINER, TORRENT_CLASS, \ - PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ - USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ - PID_FILE, MYAPP, ACHANNELS, ACHANNELS2, ACHANNELS3, \ - PAR2CMD - - if __INITIALIZED__: - return False - - configure_logging() - configure_process() - configure_locale() - - # init logging - logger.ntm_log_instance.init_logging() - - configure_migration() - configure_logging_part_2() - - # initialize the main SB database - main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) - - configure_general() - configure_updates() - configure_wake_on_lan() - configure_nzbs() - configure_torrents() - configure_remote_paths() - configure_plex() - configure_niceness() - configure_containers() +def configure_transcoder(): + global GETSUBS + global TRANSCODE + global DUPLICATE + global CONCAT + global IGNOREEXTENSIONS + global OUTPUTFASTSTART + global GENERALOPTS + global OUTPUTQUALITYPERCENT + global OUTPUTVIDEOPATH + global PROCESSOUTPUT + global ALANGUAGE + global AINCLUDE + global SLANGUAGES + global SINCLUDE + global SEXTRACT + global SEMBED + global SUBSDIR + global VEXTENSION + global VCODEC + global VPRESET + global VFRAMERATE + global VBITRATE + global VRESOLUTION + global VCRF + global VLEVEL + global VCODEC_ALLOW + global ACODEC + global ACODEC_ALLOW + global ACHANNELS + global ABITRATE + global ACODEC2 + global ACODEC2_ALLOW + global ACHANNELS2 + global ABITRATE2 + global ACODEC3 + global ACODEC3_ALLOW + global ACHANNELS3 + global ABITRATE3 + global SCODEC + global BURN + global HWACCEL + global ALLOWSUBS GETSUBS = int(CFG['Transcoder']['getSubs']) TRANSCODE = int(CFG['Transcoder']['transcode']) @@ -906,6 +905,49 @@ def initialize(section=None): extra = [item for item in codec_alias[codec] if item not in ACODEC3_ALLOW] ACODEC3_ALLOW.extend(extra) + +def initialize(section=None): + global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ + NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ + NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ + SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, \ + SECTIONS, ALL_FORKS, TEST_FILE, SEVENZIP, \ + __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, DEFAULTS, \ + SYS_ENCODING, \ + FAILED, \ + FFMPEG, FFPROBE, EXT_CONTAINER, TORRENT_CLASS, \ + PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ + USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ + PID_FILE, MYAPP, \ + PAR2CMD + + if __INITIALIZED__: + return False + + configure_logging() + configure_process() + configure_locale() + + # init logging + logger.ntm_log_instance.init_logging() + + configure_migration() + configure_logging_part_2() + + # initialize the main SB database + main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) + + configure_general() + configure_updates() + configure_wake_on_lan() + configure_nzbs() + configure_torrents() + configure_remote_paths() + configure_plex() + configure_niceness() + configure_containers() + configure_transcoder() + PASSWORDS_FILE = CFG['passwords']['PassWordFile'] # Setup FFMPEG, FFPROBE and SEVENZIP locations From 819cf7b225e2c77aa48da271a82f3a193f1b3e22 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:33:10 -0500 Subject: [PATCH 46/75] Fix global declarations --- core/__init__.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index c84d94f1..82c5def2 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -368,6 +368,7 @@ def configure_general(): def configure_updates(): global AUTO_UPDATE + global MYAPP AUTO_UPDATE = int(CFG['General']['auto_update']) version_checker = version_check.CheckVersion() @@ -624,6 +625,7 @@ def configure_transcoder(): global BURN global HWACCEL global ALLOWSUBS + global DEFAULTS GETSUBS = int(CFG['Transcoder']['getSubs']) TRANSCODE = int(CFG['Transcoder']['transcode']) @@ -907,19 +909,18 @@ def configure_transcoder(): def initialize(section=None): - global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PAR_CHECK, NZBGET_POSTPROCESS_SUCCESS, \ - NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SHOWEXTRACT, \ - NZBTOMEDIA_BRANCH, NZBTOMEDIA_VERSION, NEWEST_VERSION, NEWEST_VERSION_STRING, SYS_ARGV, \ - SABNZB_NO_OF_ARGUMENTS, SABNZB_0717_NO_OF_ARGUMENTS, CATEGORIES, \ - SECTIONS, ALL_FORKS, TEST_FILE, SEVENZIP, \ - __INITIALIZED__, APP_FILENAME, USER_DELAY, APP_NAME, DEFAULTS, \ - SYS_ENCODING, \ - FAILED, \ - FFMPEG, FFPROBE, EXT_CONTAINER, TORRENT_CLASS, \ - PASSWORDS_FILE, USER_DELAY, USER_SCRIPT, USER_SCRIPT_CLEAN, USER_SCRIPT_MEDIAEXTENSIONS, \ - USER_SCRIPT_PARAM, USER_SCRIPT_RUNONCE, USER_SCRIPT_SUCCESSCODES, DOWNLOAD_INFO, \ - PID_FILE, MYAPP, \ - PAR2CMD + global SHOWEXTRACT + global CATEGORIES + global SECTIONS + global SEVENZIP + global __INITIALIZED__ + global USER_DELAY + global SYS_ENCODING + global FFMPEG + global FFPROBE + global TORRENT_CLASS + global PASSWORDS_FILE + global PAR2CMD if __INITIALIZED__: return False From e85b92f1db6d67bb7b9bb2dbd3f885babd3b6e27 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:35:14 -0500 Subject: [PATCH 47/75] Refactor passwords file configuration --- core/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 82c5def2..4885c763 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -908,6 +908,12 @@ def configure_transcoder(): ACODEC3_ALLOW.extend(extra) +def configure_passwords_file(): + global PASSWORDS_FILE + + PASSWORDS_FILE = CFG['passwords']['PassWordFile'] + + def initialize(section=None): global SHOWEXTRACT global CATEGORIES @@ -948,8 +954,7 @@ def initialize(section=None): configure_niceness() configure_containers() configure_transcoder() - - PASSWORDS_FILE = CFG['passwords']['PassWordFile'] + configure_passwords_file() # Setup FFMPEG, FFPROBE and SEVENZIP locations if platform.system() == 'Windows': From 4f828e0a77624d2177c9b6cea55c3f35534c8607 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:37:57 -0500 Subject: [PATCH 48/75] Refactor torrent class configuration --- core/__init__.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 4885c763..be1fa13e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -914,6 +914,13 @@ def configure_passwords_file(): PASSWORDS_FILE = CFG['passwords']['PassWordFile'] +def configure_torrent_class(): + global TORRENT_CLASS + + # create torrent class + TORRENT_CLASS = create_torrent_class(TORRENT_CLIENT_AGENT) + + def initialize(section=None): global SHOWEXTRACT global CATEGORIES @@ -1050,8 +1057,7 @@ def initialize(section=None): CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()]) CATEGORIES = list(set(CATEGORIES)) - # create torrent class - TORRENT_CLASS = create_torrent_class(TORRENT_CLIENT_AGENT) + configure_torrent_class() # finished initalizing return True From 0a58b6b6a02764cab0a5ddac8ad9e41898015432 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:40:02 -0500 Subject: [PATCH 49/75] Refactor section configuration --- core/__init__.py | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index be1fa13e..d6e61db1 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -921,6 +921,19 @@ def configure_torrent_class(): TORRENT_CLASS = create_torrent_class(TORRENT_CLIENT_AGENT) +def configure_sections(section): + global SECTIONS + global CATEGORIES + # check for script-defied section and if None set to allow sections + SECTIONS = CFG[ + tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) + if not section else (section,) + ] + for section, subsections in SECTIONS.items(): + CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()]) + CATEGORIES = list(set(CATEGORIES)) + + def initialize(section=None): global SHOWEXTRACT global CATEGORIES @@ -1051,12 +1064,7 @@ def initialize(section=None): logger.warning('Failed to locate ffprobe. Video corruption detection disabled!') logger.warning('Install ffmpeg with x264 support to enable this feature ...') - # check for script-defied section and if None set to allow sections - SECTIONS = CFG[tuple(x for x in CFG if CFG[x].sections and CFG[x].isenabled()) if not section else (section,)] - for section, subsections in SECTIONS.items(): - CATEGORIES.extend([subsection for subsection in subsections if CFG[section][subsection].isenabled()]) - CATEGORIES = list(set(CATEGORIES)) - + configure_sections(section) configure_torrent_class() # finished initalizing From 3d2070e106ce7d89424048401188d9c446d3c30f Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:43:02 -0500 Subject: [PATCH 50/75] Refactor utility location configuration --- core/__init__.py | 69 +++++++++++++++++++++++------------------------- 1 file changed, 33 insertions(+), 36 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index d6e61db1..2213276e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -934,48 +934,13 @@ def configure_sections(section): CATEGORIES = list(set(CATEGORIES)) -def initialize(section=None): +def configure_utility_locations(): global SHOWEXTRACT - global CATEGORIES - global SECTIONS global SEVENZIP - global __INITIALIZED__ - global USER_DELAY - global SYS_ENCODING global FFMPEG global FFPROBE - global TORRENT_CLASS - global PASSWORDS_FILE global PAR2CMD - if __INITIALIZED__: - return False - - configure_logging() - configure_process() - configure_locale() - - # init logging - logger.ntm_log_instance.init_logging() - - configure_migration() - configure_logging_part_2() - - # initialize the main SB database - main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) - - configure_general() - configure_updates() - configure_wake_on_lan() - configure_nzbs() - configure_torrents() - configure_remote_paths() - configure_plex() - configure_niceness() - configure_containers() - configure_transcoder() - configure_passwords_file() - # Setup FFMPEG, FFPROBE and SEVENZIP locations if platform.system() == 'Windows': FFMPEG = os.path.join(FFMPEG_PATH, 'ffmpeg.exe') @@ -1064,6 +1029,38 @@ def initialize(section=None): logger.warning('Failed to locate ffprobe. Video corruption detection disabled!') logger.warning('Install ffmpeg with x264 support to enable this feature ...') + +def initialize(section=None): + global __INITIALIZED__ + + if __INITIALIZED__: + return False + + configure_logging() + configure_process() + configure_locale() + + # init logging + logger.ntm_log_instance.init_logging() + + configure_migration() + configure_logging_part_2() + + # initialize the main SB database + main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) + + configure_general() + configure_updates() + configure_wake_on_lan() + configure_nzbs() + configure_torrents() + configure_remote_paths() + configure_plex() + configure_niceness() + configure_containers() + configure_transcoder() + configure_passwords_file() + configure_utility_locations() configure_sections(section) configure_torrent_class() From 287e3aa17b55912c773d8130195b996a1ddc7bfa Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 12:48:55 -0500 Subject: [PATCH 51/75] Fix initializing constant --- core/__init__.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 2213276e..2ad98d34 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1064,5 +1064,7 @@ def initialize(section=None): configure_sections(section) configure_torrent_class() - # finished initalizing - return True + __INITIALIZED__ = True + + # finished initializing + return __INITIALIZED__ From f961c476aefbc99abaa8ae50799efc97b177661f Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:06:06 -0500 Subject: [PATCH 52/75] Refactor transmission configuration --- core/__init__.py | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 2ad98d34..a8fd8d89 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -423,6 +423,18 @@ def configure_groups(): GROUPS = None +def configure_transmission(): + global TRANSMISSION_HOST + global TRANSMISSION_PORT + global TRANSMISSION_USER + global TRANSMISSION_PASSWORD + + TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost + TRANSMISSION_PORT = int(CFG['Torrent']['TransmissionPort']) + TRANSMISSION_USER = CFG['Torrent']['TransmissionUSR'] # mysecretusr + TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK @@ -437,10 +449,6 @@ def configure_torrents(): global UTORRENT_WEB_UI global UTORRENT_USER global UTORRENT_PASSWORD - global TRANSMISSION_HOST - global TRANSMISSION_PORT - global TRANSMISSION_USER - global TRANSMISSION_PASSWORD global DELUGE_HOST global DELUGE_PORT global DELUGE_USER @@ -468,10 +476,7 @@ def configure_torrents(): UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr - TRANSMISSION_HOST = CFG['Torrent']['TransmissionHost'] # localhost - TRANSMISSION_PORT = int(CFG['Torrent']['TransmissionPort']) - TRANSMISSION_USER = CFG['Torrent']['TransmissionUSR'] # mysecretusr - TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr + configure_transmission() DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084 From 44df360fbea37202225c3f668349f536b38137d0 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:07:30 -0500 Subject: [PATCH 53/75] Refactor utorrent configuration --- core/__init__.py | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index a8fd8d89..d598f0a4 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -423,6 +423,16 @@ def configure_groups(): GROUPS = None +def configure_utorrent(): + global UTORRENT_WEB_UI + global UTORRENT_USER + global UTORRENT_PASSWORD + + UTORRENT_WEB_UI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/ + UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr + UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr + + def configure_transmission(): global TRANSMISSION_HOST global TRANSMISSION_PORT @@ -446,9 +456,6 @@ def configure_torrents(): global TORRENT_CHMOD_DIRECTORY global TORRENT_RESUME_ON_FAILURE global TORRENT_RESUME - global UTORRENT_WEB_UI - global UTORRENT_USER - global UTORRENT_PASSWORD global DELUGE_HOST global DELUGE_PORT global DELUGE_USER @@ -472,10 +479,8 @@ def configure_torrents(): TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure']) TORRENT_RESUME = int(CFG['Torrent']['resume']) - UTORRENT_WEB_UI = CFG['Torrent']['uTorrentWEBui'] # http://localhost:8090/gui/ - UTORRENT_USER = CFG['Torrent']['uTorrentUSR'] # mysecretusr - UTORRENT_PASSWORD = CFG['Torrent']['uTorrentPWD'] # mysecretpwr + configure_utorrent() configure_transmission() DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost From 22dfadd65c4027ca747187915cb382af906f7b77 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:08:28 -0500 Subject: [PATCH 54/75] Refactor deluge configuration --- core/__init__.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index d598f0a4..f0a1afc9 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -445,6 +445,18 @@ def configure_transmission(): TRANSMISSION_PASSWORD = CFG['Torrent']['TransmissionPWD'] # mysecretpwr +def configure_deluge(): + global DELUGE_HOST + global DELUGE_PORT + global DELUGE_USER + global DELUGE_PASSWORD + + DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost + DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084 + DELUGE_USER = CFG['Torrent']['DelugeUSR'] # mysecretusr + DELUGE_PASSWORD = CFG['Torrent']['DelugePWD'] # mysecretpwr + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK @@ -456,10 +468,6 @@ def configure_torrents(): global TORRENT_CHMOD_DIRECTORY global TORRENT_RESUME_ON_FAILURE global TORRENT_RESUME - global DELUGE_HOST - global DELUGE_PORT - global DELUGE_USER - global DELUGE_PASSWORD global QBITTORRENT_HOST global QBITTORRENT_PORT global QBITTORRENT_USER @@ -482,11 +490,7 @@ def configure_torrents(): configure_utorrent() configure_transmission() - - DELUGE_HOST = CFG['Torrent']['DelugeHost'] # localhost - DELUGE_PORT = int(CFG['Torrent']['DelugePort']) # 8084 - DELUGE_USER = CFG['Torrent']['DelugeUSR'] # mysecretusr - DELUGE_PASSWORD = CFG['Torrent']['DelugePWD'] # mysecretpwr + configure_deluge() QBITTORRENT_HOST = CFG['Torrent']['qBittorrenHost'] # localhost QBITTORRENT_PORT = int(CFG['Torrent']['qBittorrentPort']) # 8080 From 9c105061d649e6e6720df3c61c593dd64677db1c Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:09:49 -0500 Subject: [PATCH 55/75] Refactor qbittorrent configuration --- core/__init__.py | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index f0a1afc9..a4289541 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -457,6 +457,18 @@ def configure_deluge(): DELUGE_PASSWORD = CFG['Torrent']['DelugePWD'] # mysecretpwr +def configure_qbittorrent(): + global QBITTORRENT_HOST + global QBITTORRENT_PORT + global QBITTORRENT_USER + global QBITTORRENT_PASSWORD + + QBITTORRENT_HOST = CFG['Torrent']['qBittorrenHost'] # localhost + QBITTORRENT_PORT = int(CFG['Torrent']['qBittorrentPort']) # 8080 + QBITTORRENT_USER = CFG['Torrent']['qBittorrentUSR'] # mysecretusr + QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK @@ -468,10 +480,6 @@ def configure_torrents(): global TORRENT_CHMOD_DIRECTORY global TORRENT_RESUME_ON_FAILURE global TORRENT_RESUME - global QBITTORRENT_HOST - global QBITTORRENT_PORT - global QBITTORRENT_USER - global QBITTORRENT_PASSWORD TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym @@ -491,11 +499,7 @@ def configure_torrents(): configure_utorrent() configure_transmission() configure_deluge() - - QBITTORRENT_HOST = CFG['Torrent']['qBittorrenHost'] # localhost - QBITTORRENT_PORT = int(CFG['Torrent']['qBittorrentPort']) # 8080 - QBITTORRENT_USER = CFG['Torrent']['qBittorrentUSR'] # mysecretusr - QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr + configure_qbittorrent() def configure_remote_paths(): From 218e082ec78a63099e7afa382fed31acb99a0890 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:19:13 -0500 Subject: [PATCH 56/75] Refactor sabnzbd configuration --- core/__init__.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index a4289541..e100f20e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -397,19 +397,25 @@ def configure_wake_on_lan(): wake_up() -def configure_nzbs(): - global NZB_CLIENT_AGENT +def configure_sabnzbd(): global SABNZBD_HOST global SABNZBD_PORT global SABNZBD_APIKEY - global NZB_DEFAULT_DIRECTORY - NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd SABNZBD_HOST = CFG['Nzb']['sabnzbd_host'] SABNZBD_PORT = int(CFG['Nzb']['sabnzbd_port'] or 8080) # defaults to accommodate NzbGet SABNZBD_APIKEY = CFG['Nzb']['sabnzbd_apikey'] + + +def configure_nzbs(): + global NZB_CLIENT_AGENT + global NZB_DEFAULT_DIRECTORY + + NZB_CLIENT_AGENT = CFG['Nzb']['clientAgent'] # sabnzbd NZB_DEFAULT_DIRECTORY = CFG['Nzb']['default_downloadDirectory'] + configure_sabnzbd() + def configure_groups(): global GROUPS From 1906d626648fe3277d2c1eaed3738dd876449e14 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:20:53 -0500 Subject: [PATCH 57/75] Refactor flatenning configuration --- core/__init__.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e100f20e..a1e6512e 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -475,13 +475,20 @@ def configure_qbittorrent(): QBITTORRENT_PASSWORD = CFG['Torrent']['qBittorrentPWD'] # mysecretpwr +def configure_flattening(): + global NOFLATTEN + + NOFLATTEN = (CFG['Torrent']['noFlatten']) + if isinstance(NOFLATTEN, str): + NOFLATTEN = NOFLATTEN.split(',') + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK global OUTPUT_DIRECTORY global TORRENT_DEFAULT_DIRECTORY global CATEGORIES - global NOFLATTEN global DELETE_ORIGINAL global TORRENT_CHMOD_DIRECTORY global TORRENT_RESUME_ON_FAILURE @@ -492,9 +499,9 @@ def configure_torrents(): OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory'] CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software - NOFLATTEN = (CFG['Torrent']['noFlatten']) - if isinstance(NOFLATTEN, str): - NOFLATTEN = NOFLATTEN.split(',') + + configure_flattening() + if isinstance(CATEGORIES, str): CATEGORIES = CATEGORIES.split(',') DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) From cf0fc1296ffd56535b3e9e4f6a37a9d26e248e95 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:22:59 -0500 Subject: [PATCH 58/75] Refactor torrent categories configuration --- core/__init__.py | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index a1e6512e..b95c0183 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -483,12 +483,19 @@ def configure_flattening(): NOFLATTEN = NOFLATTEN.split(',') +def configure_torrent_categories(): + global CATEGORIES + + CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software + if isinstance(CATEGORIES, str): + CATEGORIES = CATEGORIES.split(',') + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK global OUTPUT_DIRECTORY global TORRENT_DEFAULT_DIRECTORY - global CATEGORIES global DELETE_ORIGINAL global TORRENT_CHMOD_DIRECTORY global TORRENT_RESUME_ON_FAILURE @@ -498,12 +505,8 @@ def configure_torrents(): USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory'] - CATEGORIES = (CFG['Torrent']['categories']) # music,music_videos,pictures,software - configure_flattening() - - if isinstance(CATEGORIES, str): - CATEGORIES = CATEGORIES.split(',') + configure_torrent_categories() DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure']) From f23eccc050d248aba18142a56e9791e54e629047 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:24:06 -0500 Subject: [PATCH 59/75] Refactor torrent resuming configuration --- core/__init__.py | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index b95c0183..e53999ec 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -491,6 +491,14 @@ def configure_torrent_categories(): CATEGORIES = CATEGORIES.split(',') +def configure_torrent_resuming(): + global TORRENT_RESUME + global TORRENT_RESUME_ON_FAILURE + + TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure']) + TORRENT_RESUME = int(CFG['Torrent']['resume']) + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK @@ -498,8 +506,6 @@ def configure_torrents(): global TORRENT_DEFAULT_DIRECTORY global DELETE_ORIGINAL global TORRENT_CHMOD_DIRECTORY - global TORRENT_RESUME_ON_FAILURE - global TORRENT_RESUME TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym @@ -509,9 +515,7 @@ def configure_torrents(): configure_torrent_categories() DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) - TORRENT_RESUME_ON_FAILURE = int(CFG['Torrent']['resumeOnFailure']) - TORRENT_RESUME = int(CFG['Torrent']['resume']) - + configure_torrent_resuming() configure_utorrent() configure_transmission() configure_deluge() From 521d2b7a050593d1898aac31fbbcc9187666bb04 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:25:25 -0500 Subject: [PATCH 60/75] Refactor torrent permission configuration --- core/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index e53999ec..3104d779 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -499,13 +499,18 @@ def configure_torrent_resuming(): TORRENT_RESUME = int(CFG['Torrent']['resume']) +def configure_torrent_permissions(): + global TORRENT_CHMOD_DIRECTORY + + TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK global OUTPUT_DIRECTORY global TORRENT_DEFAULT_DIRECTORY global DELETE_ORIGINAL - global TORRENT_CHMOD_DIRECTORY TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym @@ -514,7 +519,7 @@ def configure_torrents(): configure_flattening() configure_torrent_categories() DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) - TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) + configure_torrent_permissions() configure_torrent_resuming() configure_utorrent() configure_transmission() From 9a1be36e8bae0353e820a01a20cb50a9b71a0745 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:26:32 -0500 Subject: [PATCH 61/75] Refactor torrent deletion configuration --- core/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 3104d779..4f7afff9 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -505,20 +505,25 @@ def configure_torrent_permissions(): TORRENT_CHMOD_DIRECTORY = int(str(CFG['Torrent']['chmodDirectory']), 8) +def configure_torrent_deltetion(): + global DELETE_ORIGINAL + + DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) + + def configure_torrents(): global TORRENT_CLIENT_AGENT global USE_LINK global OUTPUT_DIRECTORY global TORRENT_DEFAULT_DIRECTORY - global DELETE_ORIGINAL TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory'] configure_flattening() + configure_torrent_deltetion() configure_torrent_categories() - DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) configure_torrent_permissions() configure_torrent_resuming() configure_utorrent() From 81a6d9c4fa56f8055416e20a9faad48910605038 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 19 Jan 2019 14:27:32 -0500 Subject: [PATCH 62/75] Refactor torrent linking configuration --- core/__init__.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index 4f7afff9..317809a2 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -511,16 +511,21 @@ def configure_torrent_deltetion(): DELETE_ORIGINAL = int(CFG['Torrent']['deleteOriginal']) +def configure_torrent_linking(): + global USE_LINK + + USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym + + def configure_torrents(): global TORRENT_CLIENT_AGENT - global USE_LINK global OUTPUT_DIRECTORY global TORRENT_DEFAULT_DIRECTORY TORRENT_CLIENT_AGENT = CFG['Torrent']['clientAgent'] # utorrent | deluge | transmission | rtorrent | vuze | qbittorrent |other - USE_LINK = CFG['Torrent']['useLink'] # no | hard | sym OUTPUT_DIRECTORY = CFG['Torrent']['outputDirectory'] # /abs/path/to/complete/ TORRENT_DEFAULT_DIRECTORY = CFG['Torrent']['default_downloadDirectory'] + configure_torrent_linking() configure_flattening() configure_torrent_deltetion() configure_torrent_categories() From 00877c2d97ec242e2182457dd829bf90406d0b44 Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 20 Jan 2019 10:09:03 -0500 Subject: [PATCH 63/75] Add Medusa API --- core/__init__.py | 2 ++ core/forks.py | 1 + 2 files changed, 3 insertions(+) diff --git a/core/__init__.py b/core/__init__.py index 317809a2..136e4193 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -88,6 +88,7 @@ FORK_SICKRAGE = 'SickRage' FORK_SICKCHILL = 'SickChill' FORK_SICKBEARD_API = 'SickBeard-api' FORK_MEDUSA = 'Medusa' +FORK_MEDUSA_API = 'Medusa-api' FORK_SICKGEAR = 'SickGear' FORK_STHENO = 'Stheno' @@ -99,6 +100,7 @@ FORKS = { 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_MEDUSA_API: {'path': None, 'failed': None, 'process_method': None, 'force_replace': None, 'return_data': None, 'type': None, 'delete_files': None, 'is_priority': 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} } diff --git a/core/forks.py b/core/forks.py index ede32f9c..be81a965 100644 --- a/core/forks.py +++ b/core/forks.py @@ -22,6 +22,7 @@ def auto_fork(section, input_category): web_root = cfg.get('web_root', '') replace = { 'medusa': 'Medusa', + 'medusa-api': 'Medusa-api', 'sickbeard-api': 'SickBeard-api', 'sickgear': 'SickGear', 'sickchill': 'SickChill', From de86259bb0e42cea2fb5d7de38d9b7092510cf09 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sun, 27 Jan 2019 22:45:04 +1300 Subject: [PATCH 64/75] fix first return parsing from HeadPhones. Fixes #1536 --- core/auto_process/music.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 58e63714..4f10c64e 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -77,7 +77,7 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', } res = force_process(params, url, apikey, input_name, dir_name, section, wait_for) - if res[0] in [0, 1]: + if res.status_code in [0, 1]: return res params = { From f6e620a3fdade741b96e64e01c1c74e32a8d6c0f Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sun, 3 Feb 2019 11:14:51 -0500 Subject: [PATCH 65/75] Add Python End-of-Life detection --- TorrentToMedia.py | 3 + core/__init__.py | 26 +++++++ eol.py | 179 ++++++++++++++++++++++++++++++++++++++++++++++ nzbToMedia.py | 3 + 4 files changed, 211 insertions(+) create mode 100644 eol.py diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 31fa152c..7704f9fc 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -1,6 +1,9 @@ #!/usr/bin/env python # coding=utf-8 +import eol +eol.check() + import cleanup cleanup.clean(cleanup.FOLDER_STRUCTURE) diff --git a/core/__init__.py b/core/__init__.py index 136e4193..fbd471f7 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -13,6 +13,7 @@ import time import libs.autoload import libs.util +import eol if not libs.autoload.completed: sys.exit('Could not load vendored libraries.') @@ -1085,6 +1086,28 @@ def configure_utility_locations(): logger.warning('Install ffmpeg with x264 support to enable this feature ...') +def check_python(): + """Check End-of-Life status for Python version.""" + # Raise if end of life + eol.check() + + # Warn if within grace period + grace_period = 365 # days + eol.warn_for_status(grace_period=-grace_period) + + # Log warning if within grace period + days_left = eol.lifetime() + logger.info( + 'Python v{major}.{minor} will reach end of life in {x} days.'.format( + major=sys.version_info[0], + minor=sys.version_info[1], + x=days_left, + ) + ) + if days_left <= grace_period: + logger.warning('Please upgrade to a more recent Python version.') + + def initialize(section=None): global __INITIALIZED__ @@ -1101,6 +1124,9 @@ def initialize(section=None): configure_migration() configure_logging_part_2() + # check python version + check_python() + # initialize the main SB database main_db.upgrade_database(main_db.DBConnection(), databases.InitialSchema) diff --git a/eol.py b/eol.py new file mode 100644 index 00000000..a67bfc9e --- /dev/null +++ b/eol.py @@ -0,0 +1,179 @@ +#!/usr/bin/env python + +import datetime +import sys +import warnings + +__version__ = '1.0.0' + + +def date(string, fmt='%Y-%m-%d'): + """ + Convert date string to date. + + :param string: A date string + :param fmt: Format to use when parsing the date string + :return: A datetime.date + """ + return datetime.datetime.strptime(string, fmt).date() + + +# https://devguide.python.org/ +# https://devguide.python.org/devcycle/#devcycle +PYTHON_EOL = { + (3, 7): date('2023-06-27'), + (3, 6): date('2021-12-23'), + (3, 5): date('2020-09-13'), + (3, 4): date('2019-03-16'), + (3, 3): date('2017-09-29'), + (3, 2): date('2016-02-20'), + (3, 1): date('2012-04-09'), + (3, 0): date('2009-01-13'), + (2, 7): date('2020-01-01'), + (2, 6): date('2013-10-29'), +} + + +class Error(Exception): + """An error has occurred.""" + + +class LifetimeError(Error): + """Lifetime has been exceeded and upgrade is required.""" + + +class LifetimeWarning(Warning): + """Lifetime has been exceeded and is no longer supported.""" + + +def lifetime(version=None): + """ + Calculate days left till End-of-Life for a version. + + :param version: An optional tuple with version information + If a version is not provided, the current system version will be used. + :return: Days left until End-of-Life + """ + if version is None: + version = sys.version_info + major = version[0] + minor = version[1] + now = datetime.datetime.now().date() + time_left = PYTHON_EOL[(major, minor)] - now + return time_left.days + + +def expiration(version=None, grace_period=0): + """ + Calculate expiration date for a version given a grace period. + + :param version: An optional tuple with version information + If a version is not provided, the current system version will be used. + :param grace_period: An optional number of days grace period + :return: Total days till expiration + """ + days_left = lifetime(version) + return days_left + grace_period + + +def check(version=None, grace_period=0): + """ + Raise an exception if end of life has been reached and recommend upgrade. + + :param version: An optional tuple with version information + If a version is not provided, the current system version will be used. + :param grace_period: An optional number of days grace period + If a grace period is not provided, a default 60 days grace period will + be used. + :return: None + """ + try: + raise_for_status(version, grace_period) + except LifetimeError as error: + print('Please use a newer version of Python.') + print_statuses() + sys.exit(error) + + +def raise_for_status(version=None, grace_period=0): + """ + Raise an exception if end of life has been reached. + + :param version: An optional tuple with version information + If a version is not provided, the current system version will be used. + :param grace_period: An optional number of days grace period + If a grace period is not provided, a default 60 days grace period will + be used. + :return: None + """ + if version is None: + version = sys.version_info + days_left = lifetime(version) + expires = days_left + grace_period + if expires <= 0: + msg = 'Python {major}.{minor} is no longer supported.'.format( + major=version[0], + minor=version[1], + ) + raise LifetimeError(msg) + + +def warn_for_status(version=None, grace_period=0): + """ + Warn if end of life has been reached. + + :param version: An optional tuple with version information + If a version is not provided, the current system version will be used. + :param grace_period: An optional number of days grace period + :return: None + """ + if version is None: + version = sys.version_info + days_left = lifetime(version) + expires = days_left + grace_period + if expires <= 0: + msg = 'Python {major}.{minor} is no longer supported.'.format( + major=version[0], + minor=version[1], + ) + warnings.warn(msg, LifetimeWarning) + + +def print_statuses(show_expired=False): + """ + Print end-of-life statuses of known python versions. + + :param show_expired: If true also print expired python version statuses + """ + lifetimes = sorted( + (lifetime(python_version), python_version) + for python_version in PYTHON_EOL + ) + print('Python End-of-Life for current versions:') + for days_left, python_version in lifetimes: + if days_left >= 0: + print( + 'v{major}.{minor} in {remaining:>4} days'.format( + major=python_version[0], + minor=python_version[1], + remaining=days_left, + ) + ) + if not show_expired: + return + + print() + print('Python End-of-Life for expired versions:') + for days_left, python_version in lifetimes: + if days_left < 0: + print( + 'v{major}.{minor} {remaining:>4} days ago'.format( + major=python_version[0], + minor=python_version[1], + remaining=-days_left, + ) + ) + + +if __name__ == '__main__': + print_statuses(show_expired=True) diff --git a/nzbToMedia.py b/nzbToMedia.py index f6c7e5db..a353e430 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -623,6 +623,9 @@ from __future__ import print_function +import eol +eol.check() + import cleanup cleanup.clean(cleanup.FOLDER_STRUCTURE) From f47f68f699c0ba427227d2b3f885272da8e16828 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 5 Feb 2019 22:01:20 +1300 Subject: [PATCH 66/75] convert byte to string from Popen. Fix Sick* failed processing. Fixes #1545 --- core/__init__.py | 16 ++++++++-------- core/auto_process/tv.py | 6 ++++-- core/transcoder.py | 4 ++-- tests/general.py | 15 +++++++++------ 4 files changed, 23 insertions(+), 18 deletions(-) diff --git a/core/__init__.py b/core/__init__.py index fbd471f7..4d935def 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1017,17 +1017,17 @@ def configure_utility_locations(): else: try: - SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip() + SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not SEVENZIP: try: - SEVENZIP = subprocess.Popen(['which', '7zr'], stdout=subprocess.PIPE).communicate()[0].strip() + SEVENZIP = subprocess.Popen(['which', '7zr'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not SEVENZIP: try: - SEVENZIP = subprocess.Popen(['which', '7za'], stdout=subprocess.PIPE).communicate()[0].strip() + SEVENZIP = subprocess.Popen(['which', '7za'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not SEVENZIP: @@ -1035,7 +1035,7 @@ def configure_utility_locations(): logger.warning( 'Failed to locate 7zip. Transcoding of disk images and extraction of .7z files will not be possible!') try: - PAR2CMD = subprocess.Popen(['which', 'par2'], stdout=subprocess.PIPE).communicate()[0].strip() + PAR2CMD = subprocess.Popen(['which', 'par2'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not PAR2CMD: @@ -1050,12 +1050,12 @@ def configure_utility_locations(): FFMPEG = os.path.join(FFMPEG_PATH, 'avconv') else: try: - FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip() + FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not FFMPEG: try: - FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip() + FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not FFMPEG: @@ -1071,12 +1071,12 @@ def configure_utility_locations(): FFPROBE = os.path.join(FFMPEG_PATH, 'avprobe') else: try: - FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip() + FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not FFPROBE: try: - FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip() + FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: pass if not FFPROBE: diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index cc31f94e..8d082aec 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -168,13 +168,15 @@ def process(section, dir_name, input_name=None, failed=False, client_agent='manu for param in copy.copy(fork_params): if param == 'failed': fork_params[param] = failed - del fork_params['proc_type'] + if 'proc_type' in fork_params: + del fork_params['proc_type'] if 'type' in fork_params: del fork_params['type'] if param == 'return_data': fork_params[param] = 0 - del fork_params['quiet'] + if 'quiet' in fork_params: + del fork_params['quiet'] if param == 'type': fork_params[param] = 'manual' diff --git a/core/transcoder.py b/core/transcoder.py index 52a35292..375d9d3a 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -95,7 +95,7 @@ def get_video_details(videofile, img=None, bitbucket=None): proc = subprocess.Popen(command, stdout=subprocess.PIPE) out, err = proc.communicate() result = proc.returncode - video_details = json.loads(out) + video_details = json.loads(out.decode()) except Exception: pass if not video_details: @@ -109,7 +109,7 @@ def get_video_details(videofile, img=None, bitbucket=None): proc = subprocess.Popen(command, stdout=subprocess.PIPE) out, err = proc.communicate() result = proc.returncode - video_details = json.loads(out) + video_details = json.loads(out.decode()) except Exception: logger.error('Checking [{0}] has failed'.format(file), 'TRANSCODER') return video_details, result diff --git a/tests/general.py b/tests/general.py index ed0ef06c..ddcc7aa0 100755 --- a/tests/general.py +++ b/tests/general.py @@ -1,15 +1,18 @@ #! /usr/bin/env python2 from __future__ import print_function -from babelfish import Language -import guessit -import requests -import subliminal +import datetime +import os +import sys import core -from core import transcoder +from core import logger, main_db, transcoder +from core.auto_process import comics, games, movies, music, tv +from core.auto_process.common import ProcessResult +from core.user_scripts import external_script from core.forks import auto_fork -from core.utils import server_responding +from core.utils import char_replace, clean_dir, convert_to_ascii, extract_files, get_dirs, get_download_info, get_nzoid, plex_update, update_download_info_status, server_responding + # Initialize the config core.initialize() From 8a637918d65cf46ea14354b88933271a1e5f9315 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Tue, 5 Feb 2019 22:15:05 +1300 Subject: [PATCH 67/75] use list for python3 compatibility. Fixes #1545 --- core/auto_process/tv.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 8d082aec..bfc1a8d9 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -216,7 +216,7 @@ def process(section, dir_name, input_name=None, failed=False, client_agent='manu fork_params[param] = 1 # delete any unused params so we don't pass them to SB by mistake - [fork_params.pop(k) for k, v in fork_params.items() if v is None] + [fork_params.pop(k) for k, v in list(fork_params.items()) if v is None] if status == 0: if section == 'NzbDrone' and not apikey: From 45baf797537b8efda0884e941683e38b5ed91c4e Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 9 Feb 2019 11:08:33 +1300 Subject: [PATCH 68/75] log sucessful when returning failed download to Radarr. Fixes #1546 --- core/auto_process/movies.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 7b1fb8e5..c0f1ace4 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -238,11 +238,11 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual', report_nzb(failure_link, client_agent) if section == 'Radarr': - logger.postprocess('FAILED: The download failed. Sending failed download to {0} for CDH processing'.format(section), section) + logger.postprocess('SUCCESS: Sending failed download to {0} for CDH processing'.format(section), section) return ProcessResult( - message='{0}: Download Failed. Sending back to {0}'.format(section), + message='{0}: Sending failed download back to {0}'.format(section), status_code=1, # Return as failed to flag this in the downloader. - ) + ) # Return failed flag, but log the event as successful. if delete_failed and os.path.isdir(dir_name) and not os.path.dirname(dir_name) == dir_name: logger.postprocess('Deleting failed files and folder {0}'.format(dir_name), section) From fd8452b5c6e27ce2c8a6a5bb5378be2abf34392b Mon Sep 17 00:00:00 2001 From: Labrys of Knossos Date: Sat, 16 Feb 2019 10:17:01 -0500 Subject: [PATCH 69/75] Add exception handling for failure to return to original directory Fixes #1552 --- cleanup.py | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/cleanup.py b/cleanup.py index b78df372..dcef7789 100644 --- a/cleanup.py +++ b/cleanup.py @@ -33,7 +33,17 @@ class WorkingDirectory(object): return self def __exit__(self, exc_type, exc_val, exc_tb): - os.chdir(self.original_directory) + try: + os.chdir(self.original_directory) + except OSError as error: + print( + 'Unable to return to {original_directory}: {error}\n' + 'Continuing in {working_directory}'.format( + original_directory=self.original_directory, + error=error, + working_directory=self.working_directory, + ) + ) def module_path(module=__file__, parent=False): From 27cfc3457719163015fcb30db3464d6da721c425 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Mon, 25 Feb 2019 19:53:54 +1300 Subject: [PATCH 70/75] add sys path config to find executables not in path. Fixes #830 --- autoProcessMedia.cfg.spec | 2 ++ core/__init__.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/autoProcessMedia.cfg.spec b/autoProcessMedia.cfg.spec index ef3c362b..767d937c 100644 --- a/autoProcessMedia.cfg.spec +++ b/autoProcessMedia.cfg.spec @@ -22,6 +22,8 @@ log_env = 0 # Enable/Disable logging git output to debug nzbtomedia.log (helpful to track down update failures.) log_git = 0 + # Set to the directory to search for executables if not in default system path + sys_path = # Set to the directory where your ffmpeg/ffprobe executables are located ffmpeg_path = # Enable/Disable media file checking using ffprobe. diff --git a/core/__init__.py b/core/__init__.py index 4d935def..8d638dc4 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -191,6 +191,7 @@ GETSUBS = False TRANSCODE = None CONCAT = None FFMPEG_PATH = None +SYS_PATH = None DUPLICATE = None IGNOREEXTENSIONS = [] VEXTENSION = None @@ -352,6 +353,7 @@ def configure_general(): global GIT_BRANCH global FORCE_CLEAN global FFMPEG_PATH + global SYS_PATH global CHECK_MEDIA global SAFE_MODE global NOEXTRACTFAILED @@ -364,6 +366,7 @@ def configure_general(): GIT_BRANCH = CFG['General']['git_branch'] or 'master' FORCE_CLEAN = int(CFG['General']['force_clean']) FFMPEG_PATH = CFG['General']['ffmpeg_path'] + SYS_PATH = CFG['General']['sys_path'] CHECK_MEDIA = int(CFG['General']['check_media']) SAFE_MODE = int(CFG['General']['safe_mode']) NOEXTRACTFAILED = int(CFG['General']['no_extract_failed']) @@ -1016,6 +1019,8 @@ def configure_utility_locations(): logger.warning('Install ffmpeg with x264 support to enable this feature ...') else: + if SYS_PATH: + sys.path.append(SYS_PATH) try: SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: From 3f3e1415c9be0f3b1c5eada55238747d92833829 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 2 Mar 2019 09:03:21 +1300 Subject: [PATCH 71/75] change method of writing to system PATH. Fixes #830 --- core/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/__init__.py b/core/__init__.py index 8d638dc4..2f4645b2 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -1020,7 +1020,7 @@ def configure_utility_locations(): else: if SYS_PATH: - sys.path.append(SYS_PATH) + os.environ['PATH'] += ':'+SYS_PATH try: SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip().decode() except Exception: From f82fe0ee81fde101f1658a990bd6d32f98effb34 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Fri, 8 Mar 2019 23:03:24 +1300 Subject: [PATCH 72/75] decode 7zip outut. Fixes #1561 --- core/transcoder.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/core/transcoder.py b/core/transcoder.py index 375d9d3a..4c650dcc 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -645,7 +645,7 @@ def rip_iso(item, new_dir, bitbucket): logger.debug('Attempting to extract .vob from image file {0}'.format(item), 'TRANSCODER') print_cmd(cmd) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) - out, err = proc.communicate() + out, err = proc.communicate().decode() file_list = [re.match(r'.+(VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb])', line).groups()[0] for line in out.splitlines() if re.match(r'.+VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]', line)] combined = [] From 64862ece10e63098632fe2d27801584e18814947 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sat, 9 Mar 2019 20:30:25 +1300 Subject: [PATCH 73/75] fix python3 parsing of .iso files. Fixes #1561 --- core/transcoder.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/core/transcoder.py b/core/transcoder.py index 4c650dcc..42bf528e 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -645,9 +645,9 @@ def rip_iso(item, new_dir, bitbucket): logger.debug('Attempting to extract .vob from image file {0}'.format(item), 'TRANSCODER') print_cmd(cmd) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) - out, err = proc.communicate().decode() - file_list = [re.match(r'.+(VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb])', line).groups()[0] for line in - out.splitlines() if re.match(r'.+VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]', line)] + out, err = proc.communicate() + file_list = [re.match(r'.+(VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb])', line.decode()).groups()[0] for line in + out.splitlines() if re.match(r'.+VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]', line.decode())] combined = [] for n in range(99): concat = [] From 392967780c861d1e6f13ac82f7e29918d95c743d Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sun, 10 Mar 2019 08:34:56 +1300 Subject: [PATCH 74/75] don't load torrent clients for nzbs. Fixes #1563 --- core/utils/torrents.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/core/utils/torrents.py b/core/utils/torrents.py index 810bfc42..4c152e47 100644 --- a/core/utils/torrents.py +++ b/core/utils/torrents.py @@ -12,6 +12,8 @@ from core import logger def create_torrent_class(client_agent): # Hardlink solution for Torrents tc = None + if not core.APP_NAME == 'TorrentToMedia.py': #Skip loading Torrent for NZBs. + return tc if client_agent == 'utorrent': try: From d4786e10d7317f94037caf8a0d5d43daa0a2df02 Mon Sep 17 00:00:00 2001 From: clinton-hall Date: Sun, 10 Mar 2019 20:37:57 +1300 Subject: [PATCH 75/75] rev up to 12.0.8 --- .bumpversion.cfg | 2 +- README.md | 2 +- changelog.txt | 13 +++++++++++++ core/__init__.py | 2 +- setup.py | 2 +- 5 files changed, 17 insertions(+), 4 deletions(-) diff --git a/.bumpversion.cfg b/.bumpversion.cfg index a1d61c63..96d2148f 100644 --- a/.bumpversion.cfg +++ b/.bumpversion.cfg @@ -1,5 +1,5 @@ [bumpversion] -current_version = 12.0.7 +current_version = 12.0.8 commit = True tag = False diff --git a/README.md b/README.md index c78ffe83..63b8626b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -nzbToMedia v12.0.7 +nzbToMedia v12.0.8 ================== 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/changelog.txt b/changelog.txt index b197e7fa..b269e118 100644 --- a/changelog.txt +++ b/changelog.txt @@ -1,5 +1,18 @@ Change_LOG / History +V12.0.8 + +Refactor and Rename Modules +Add Medusa API +Fix return parsing from HeadPhones +Add Python end of life detection and reporting +Fix Py3 return from Popen (Transcoder and executable path detection) +Add variable sys_path to config (allows user to specify separate path for binary detection) +Various Py3 compatability fixes +Log successful when returning to Radarr CDH +Add exception handling when failing to return to original directory (due to permissions) +Don't load Torrent Clients when calling NZB processing + V12.0.7 Refactor utils diff --git a/core/__init__.py b/core/__init__.py index 2f4645b2..15d78bfd 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -71,7 +71,7 @@ from core.utils import ( wake_up, ) -__version__ = '12.0.7' +__version__ = '12.0.8' # Client Agents NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual'] diff --git a/setup.py b/setup.py index 941b4477..9c366acf 100644 --- a/setup.py +++ b/setup.py @@ -18,7 +18,7 @@ def read(*names, **kwargs): setup( name='nzbToMedia', - version='12.0.7', + version='12.0.8', license='GPLv3', description='Efficient on demand post processing', long_description="""