diff --git a/core/auto_process/books.py b/core/auto_process/books.py index 6d4f8ed3..b35cc7e3 100644 --- a/core/auto_process/books.py +++ b/core/auto_process/books.py @@ -46,17 +46,25 @@ def process( input_category: str = '', failure_link: str = '', ) -> ProcessResult: + # Get configuration + cfg = core.CFG[section][input_category] - cfg = dict(core.CFG[section][input_category]) - + # Base URL + ssl = int(cfg.get('ssl', 0)) + scheme = 'https' if ssl else 'http' host = cfg['host'] port = cfg['port'] - apikey = cfg['apikey'] - ssl = int(cfg.get('ssl', 0)) web_root = cfg.get('web_root', '') - scheme = 'https' if ssl else 'http' + + # Authentication + apikey = cfg.get('apikey', '') + + # Params remote_path = int(cfg.get('remote_path', 0)) + # Misc + + # Begin processing url = core.utils.common.create_url(scheme, host, port, web_root) if not server_responding(url): logger.error('Server did not respond. Exiting', section) @@ -71,6 +79,7 @@ def process( 'cmd': 'forceProcess', 'dir': remote_dir(dir_name) if remote_path else dir_name, } + logger.debug('Opening URL: {0} with params: {1}'.format(url, params), section) try: diff --git a/core/auto_process/comics.py b/core/auto_process/comics.py index eda7b0f4..395a2f4c 100644 --- a/core/auto_process/comics.py +++ b/core/auto_process/comics.py @@ -46,19 +46,27 @@ def process( input_category: str = '', failure_link: str = '', ) -> ProcessResult: + # Get configuration + cfg = core.CFG[section][input_category] + + # Base URL + ssl = int(cfg.get('ssl', 0)) + scheme = 'https' if ssl else 'http' + host = cfg['host'] + port = cfg['port'] + web_root = cfg.get('web_root', '') + + # Authentication + apikey = cfg.get('apikey', '') + + # Params + remote_path = int(cfg.get('remote_path', 0)) + + # Misc apc_version = '2.04' comicrn_version = '1.01' - cfg = dict(core.CFG[section][input_category]) - - host = cfg['host'] - port = cfg['port'] - apikey = cfg['apikey'] - ssl = int(cfg.get('ssl', 0)) - web_root = cfg.get('web_root', '') - remote_path = int(cfg.get('remote_path'), 0) - scheme = 'https' if ssl else 'http' - + # Begin processing url = core.utils.common.create_url(scheme, host, port, web_root) if not server_responding(url): logger.error('Server did not respond. Exiting', section) diff --git a/core/auto_process/games.py b/core/auto_process/games.py index f813a307..6a76fa25 100644 --- a/core/auto_process/games.py +++ b/core/auto_process/games.py @@ -46,17 +46,25 @@ def process( input_category: str = '', failure_link: str = '', ) -> ProcessResult: + # Get configuration + cfg = core.CFG[section][input_category] - cfg = dict(core.CFG[section][input_category]) - + # Base URL + ssl = int(cfg.get('ssl', 0)) + scheme = 'https' if ssl else 'http' host = cfg['host'] port = cfg['port'] - apikey = cfg['apikey'] - library = cfg.get('library') - ssl = int(cfg.get('ssl', 0)) web_root = cfg.get('web_root', '') - scheme = 'https' if ssl else 'http' + # Authentication + apikey = cfg.get('apikey', '') + + # Params + + # Misc + library = cfg.get('library') + + # Begin processing url = core.utils.common.create_url(scheme, host, port, web_root) if not server_responding(url): logger.error('Server did not respond. Exiting', section) diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index 33905e9a..ce31d53c 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -46,35 +46,40 @@ def process( input_category: str = '', failure_link: str = '', ) -> ProcessResult: + # Get configuration + cfg = core.CFG[section][input_category] - cfg = dict(core.CFG[section][input_category]) - + # Base URL + ssl = int(cfg.get('ssl', 0)) + scheme = 'https' if ssl else 'http' host = cfg['host'] port = cfg['port'] - apikey = cfg['apikey'] - if section == 'CouchPotato': - method = cfg['method'] - else: - method = None - # added importMode for Radarr config - if section == 'Radarr': - import_mode = cfg.get('importMode', 'Move') - else: - import_mode = None - delete_failed = int(cfg['delete_failed']) - wait_for = int(cfg['wait_for']) - ssl = int(cfg.get('ssl', 0)) web_root = cfg.get('web_root', '') - remote_path = int(cfg.get('remote_path', 0)) - scheme = 'https' if ssl else 'http' + + # Authentication + apikey = cfg.get('apikey', '') omdbapikey = cfg.get('omdbapikey', '') - no_status_check = int(cfg.get('no_status_check', 0)) - status = int(status) + + # Params + delete_failed = int(cfg.get('delete_failed', 0)) + remote_path = int(cfg.get('remote_path', 0)) + wait_for = int(cfg.get('wait_for', 2)) + + # Misc if status > 0 and core.NOEXTRACTFAILED: extract = 0 else: extract = int(cfg.get('extract', 0)) + chmod_directory = int(str(cfg.get('chmodDirectory', '0')), 8) + import_mode = cfg.get('importMode', 'Move') + if section != 'Radarr': + import_mode = None + no_status_check = int(cfg.get('no_status_check', 0)) + method = cfg.get('method', None) + if section != 'CouchPotato': + method = None + # Begin processing imdbid = find_imdbid(dir_name, input_name, omdbapikey) if section == 'CouchPotato': route = f'{web_root}/api/{apikey}/' @@ -181,7 +186,6 @@ def process( logger.debug('Transcoding succeeded for files in {0}'.format(dir_name), section) dir_name = new_dir_name - chmod_directory = int(str(cfg.get('chmodDirectory', '0')), 8) logger.debug('Config setting \'chmodDirectory\' currently set to {0}'.format(oct(chmod_directory)), section) if chmod_directory: logger.info('Attempting to set the octal permission of \'{0}\' on directory \'{1}\''.format(oct(chmod_directory), dir_name), section) diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 777546e3..a19b112b 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -46,24 +46,31 @@ def process( input_category: str = '', failure_link: str = '', ) -> ProcessResult: + # Get configuration + cfg = core.CFG[section][input_category] - cfg = dict(core.CFG[section][input_category]) - + # Base URL + ssl = int(cfg.get('ssl', 0)) + scheme = 'https' if ssl else 'http' host = cfg['host'] port = cfg['port'] - apikey = cfg['apikey'] - wait_for = int(cfg['wait_for']) - ssl = int(cfg.get('ssl', 0)) - delete_failed = int(cfg['delete_failed']) web_root = cfg.get('web_root', '') + + # Authentication + apikey = cfg.get('apikey', '') + + # Params + delete_failed = int(cfg.get('delete_failed', 0)) remote_path = int(cfg.get('remote_path', 0)) - scheme = 'https' if ssl else 'http' - status = int(status) + wait_for = int(cfg.get('wait_for', 2)) + + # Misc if status > 0 and core.NOEXTRACTFAILED: extract = 0 else: extract = int(cfg.get('extract', 0)) + # Begin processing route = f'{web_root}/api/v1' if section == 'Lidarr' else f'{web_root}/api' url = core.utils.common.create_url(scheme, host, port, route) if not server_responding(url): diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 48cf4d1f..ad95cf6f 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -46,21 +46,45 @@ def process( input_category: str = '', failure_link: str = '', ) -> ProcessResult: + # Get configuration + cfg = core.CFG[section][input_category] - cfg = dict(core.CFG[section][input_category]) - + # Base URL + ssl = int(cfg.get('ssl', 0)) + scheme = 'https' if ssl else 'http' host = cfg['host'] port = cfg['port'] - ssl = int(cfg.get('ssl', 0)) web_root = cfg.get('web_root', '') - scheme = 'https' if ssl else 'http' + + # Authentication + apikey = cfg.get('apikey', '') username = cfg.get('username', '') password = cfg.get('password', '') - apikey = cfg.get('apikey', '') api_version = int(cfg.get('api_version', 2)) sso_username = cfg.get('sso_username', '') sso_password = cfg.get('sso_password', '') + # Params + delete_failed = int(cfg.get('delete_failed', 0)) + remote_path = int(cfg.get('remote_path', 0)) + wait_for = int(cfg.get('wait_for', 2)) + + # Misc + if status > 0 and core.NOEXTRACTFAILED: + extract = 0 + else: + extract = int(cfg.get('extract', 0)) + chmod_directory = int(str(cfg.get('chmodDirectory', '0')), 8) + import_mode = cfg.get('importMode', 'Move') + nzb_extraction_by = cfg.get('nzbExtractionBy', 'Downloader') + process_method = cfg.get('process_method') + force = int(cfg.get('force', 0)) + delete_on = int(cfg.get('delete_on', 0)) + ignore_subs = int(cfg.get('ignore_subs', 0)) + status = int(failed) + + # Begin processing + # Refactor into an OO structure. # For now let's do botch the OO and the serialized code, until everything has been migrated. init_sickbeard = InitSickBeard(cfg, section, input_category) @@ -80,24 +104,8 @@ def process( f'{section}: Failed to post-process - {section} did not respond.' ) - 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_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)) - force = int(cfg.get('force', 0)) - delete_on = int(cfg.get('delete_on', 0)) - ignore_subs = int(cfg.get('ignore_subs', 0)) - status = int(failed) - if status > 0 and core.NOEXTRACTFAILED: - extract = 0 - else: - extract = int(cfg.get('extract', 0)) - # get importmode, default to 'Move' for consistency with legacy - import_mode = cfg.get('importMode', 'Move') - if not os.path.isdir(dir_name) and os.path.isfile(dir_name): # If the input directory is a file, assume single file download and split dir/name. dir_name = os.path.split(os.path.normpath(dir_name))[0] @@ -190,7 +198,6 @@ def process( logger.debug('SUCCESS: Transcoding succeeded for files in {0}'.format(dir_name), section) dir_name = new_dir_name - chmod_directory = int(str(cfg.get('chmodDirectory', '0')), 8) logger.debug('Config setting \'chmodDirectory\' currently set to {0}'.format(oct(chmod_directory)), section) if chmod_directory: logger.info('Attempting to set the octal permission of \'{0}\' on directory \'{1}\''.format(oct(chmod_directory), dir_name), section)