mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 21:33:13 -07:00
Merge pull request #1514 from clinton-hall/feature/cleanup
Code cleanup
This commit is contained in:
commit
22b9a484ae
12 changed files with 42 additions and 44 deletions
|
@ -1,5 +1,5 @@
|
||||||
[bumpversion]
|
[bumpversion]
|
||||||
current_version = 12.0.4
|
current_version = 12.0.5
|
||||||
commit = True
|
commit = True
|
||||||
tag = False
|
tag = False
|
||||||
|
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
nzbToMedia v12.0.4
|
nzbToMedia v12.0.5
|
||||||
==================
|
==================
|
||||||
|
|
||||||
Provides an [efficient](https://github.com/clinton-hall/nzbToMedia/wiki/Efficient-on-demand-post-processing) way to handle postprocessing for [CouchPotatoServer](https://couchpota.to/ "CouchPotatoServer") and [SickBeard](http://sickbeard.com/ "SickBeard") (and its [forks](https://github.com/clinton-hall/nzbToMedia/wiki/Failed-Download-Handling-%28FDH%29#sick-beard-and-its-forks))
|
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))
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
# coding=utf-8
|
# coding=utf-8
|
||||||
|
|
||||||
import cleanup
|
import cleanup
|
||||||
cleanup.clean('core', 'libs')
|
cleanup.clean(cleanup.FOLDER_STRUCTURE)
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
|
@ -52,7 +52,7 @@ from core.utils import (
|
||||||
resume_torrent, remove_dir, remove_read_only, sanitize_name, update_download_info_status,
|
resume_torrent, remove_dir, remove_read_only, sanitize_name, update_download_info_status,
|
||||||
)
|
)
|
||||||
|
|
||||||
__version__ = '12.0.4'
|
__version__ = '12.0.5'
|
||||||
|
|
||||||
# Client Agents
|
# Client Agents
|
||||||
NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual']
|
NZB_CLIENTS = ['sabnzbd', 'nzbget', 'manual']
|
||||||
|
@ -63,7 +63,6 @@ SABNZB_NO_OF_ARGUMENTS = 8
|
||||||
SABNZB_0717_NO_OF_ARGUMENTS = 9
|
SABNZB_0717_NO_OF_ARGUMENTS = 9
|
||||||
|
|
||||||
# sickbeard fork/branch constants
|
# sickbeard fork/branch constants
|
||||||
FORKS = {}
|
|
||||||
FORK_DEFAULT = 'default'
|
FORK_DEFAULT = 'default'
|
||||||
FORK_FAILED = 'failed'
|
FORK_FAILED = 'failed'
|
||||||
FORK_FAILED_TORRENT = 'failed-torrent'
|
FORK_FAILED_TORRENT = 'failed-torrent'
|
||||||
|
@ -73,15 +72,18 @@ FORK_SICKBEARD_API = 'SickBeard-api'
|
||||||
FORK_MEDUSA = 'Medusa'
|
FORK_MEDUSA = 'Medusa'
|
||||||
FORK_SICKGEAR = 'SickGear'
|
FORK_SICKGEAR = 'SickGear'
|
||||||
FORK_STHENO = 'Stheno'
|
FORK_STHENO = 'Stheno'
|
||||||
FORKS[FORK_DEFAULT] = {'dir': None}
|
|
||||||
FORKS[FORK_FAILED] = {'dirName': None, 'failed': None}
|
FORKS = {
|
||||||
FORKS[FORK_FAILED_TORRENT] = {'dir': None, 'failed': None, 'process_method': None}
|
FORK_DEFAULT: {'dir': None},
|
||||||
FORKS[FORK_SICKRAGE] = {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None}
|
FORK_FAILED: {'dirName': None, 'failed': None},
|
||||||
FORKS[FORK_SICKCHILL] = {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'force_next': None}
|
FORK_FAILED_TORRENT: {'dir': None, 'failed': None, 'process_method': None},
|
||||||
FORKS[FORK_SICKBEARD_API] = {'path': None, 'failed': None, 'process_method': None, 'force_replace': None, 'return_data': None, 'type': None, 'delete': None, 'force_next': None}
|
FORK_SICKRAGE: {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None},
|
||||||
FORKS[FORK_MEDUSA] = {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'ignore_subs': None}
|
FORK_SICKCHILL: {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'force_next': None},
|
||||||
FORKS[FORK_SICKGEAR] = {'dir': None, 'failed': None, 'process_method': None, 'force': None}
|
FORK_SICKBEARD_API: {'path': None, 'failed': None, 'process_method': None, 'force_replace': None, 'return_data': None, 'type': None, 'delete': None, 'force_next': None},
|
||||||
FORKS[FORK_STHENO] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs": None}
|
FORK_MEDUSA: {'proc_dir': None, 'failed': None, 'process_method': None, 'force': None, 'delete_on': None, 'ignore_subs': None},
|
||||||
|
FORK_SICKGEAR: {'dir': None, 'failed': None, 'process_method': None, 'force': None},
|
||||||
|
FORK_STHENO: {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs": None}
|
||||||
|
}
|
||||||
ALL_FORKS = {k: None for k in set(list(itertools.chain.from_iterable([FORKS[x].keys() for x in FORKS.keys()])))}
|
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 Exit Codes
|
||||||
|
@ -743,7 +745,6 @@ def initialize(section=None):
|
||||||
if codec in codec_alias:
|
if codec in codec_alias:
|
||||||
extra = [item for item in codec_alias[codec] if item not in ACODEC3_ALLOW]
|
extra = [item for item in codec_alias[codec] if item not in ACODEC3_ALLOW]
|
||||||
ACODEC3_ALLOW.extend(extra)
|
ACODEC3_ALLOW.extend(extra)
|
||||||
codec_alias = {} # clear memory
|
|
||||||
|
|
||||||
PASSWORDSFILE = CFG['passwords']['PassWordFile']
|
PASSWORDSFILE = CFG['passwords']['PassWordFile']
|
||||||
|
|
||||||
|
|
|
@ -163,17 +163,18 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
status_code=0,
|
status_code=0,
|
||||||
)
|
)
|
||||||
|
|
||||||
params = {}
|
params = {
|
||||||
|
'media_folder': remote_dir(dir_name) if remote_path else dir_name,
|
||||||
|
}
|
||||||
|
|
||||||
if download_id and release_id:
|
if download_id and release_id:
|
||||||
params['downloader'] = downloader or client_agent
|
params['downloader'] = downloader or client_agent
|
||||||
params['download_id'] = download_id
|
params['download_id'] = download_id
|
||||||
|
|
||||||
params['media_folder'] = remote_dir(dir_name) if remote_path else dir_name
|
|
||||||
|
|
||||||
if section == 'CouchPotato':
|
if section == 'CouchPotato':
|
||||||
if method == 'manage':
|
if method == 'manage':
|
||||||
command = 'manage.update'
|
command = 'manage.update'
|
||||||
params = {}
|
params.clear()
|
||||||
else:
|
else:
|
||||||
command = 'renamer.scan'
|
command = 'renamer.scan'
|
||||||
|
|
||||||
|
@ -220,7 +221,6 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
res = json.loads(r.content)
|
res = json.loads(r.content)
|
||||||
scan_id = int(res['id'])
|
scan_id = int(res['id'])
|
||||||
logger.debug('Scan started with id: {0}'.format(scan_id), section)
|
logger.debug('Scan started with id: {0}'.format(scan_id), section)
|
||||||
started = True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('No scan id was returned due to: {0}'.format(e), section)
|
logger.warning('No scan id was returned due to: {0}'.format(e), section)
|
||||||
scan_id = None
|
scan_id = None
|
||||||
|
|
|
@ -117,18 +117,12 @@ def process(section, dir_name, input_name=None, status=0, client_agent='manual',
|
||||||
status_code=1,
|
status_code=1,
|
||||||
)
|
)
|
||||||
|
|
||||||
success = False
|
|
||||||
queued = False
|
|
||||||
started = False
|
|
||||||
try:
|
try:
|
||||||
res = json.loads(r.content)
|
res = json.loads(r.content)
|
||||||
scan_id = int(res['id'])
|
scan_id = int(res['id'])
|
||||||
logger.debug('Scan started with id: {0}'.format(scan_id), section)
|
logger.debug('Scan started with id: {0}'.format(scan_id), section)
|
||||||
started = True
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
logger.warning('No scan id was returned due to: {0}'.format(e), section)
|
logger.warning('No scan id was returned due to: {0}'.format(e), section)
|
||||||
scan_id = None
|
|
||||||
started = False
|
|
||||||
return ProcessResult(
|
return ProcessResult(
|
||||||
message='{0}: Failed to post-process - Unable to start scan'.format(section),
|
message='{0}: Failed to post-process - Unable to start scan'.format(section),
|
||||||
status_code=1,
|
status_code=1,
|
||||||
|
|
|
@ -20,8 +20,16 @@ def auto_fork(section, input_category):
|
||||||
apikey = cfg.get('apikey')
|
apikey = cfg.get('apikey')
|
||||||
ssl = int(cfg.get('ssl', 0))
|
ssl = int(cfg.get('ssl', 0))
|
||||||
web_root = cfg.get('web_root', '')
|
web_root = cfg.get('web_root', '')
|
||||||
replace = {'sickrage': 'SickRage', 'sickchill': 'SickChill', 'sickgear': 'SickGear', 'medusa': 'Medusa', 'sickbeard-api': 'SickBeard-api', 'stheno': 'Stheno'}
|
replace = {
|
||||||
f1 = replace[cfg.get('fork', 'auto')] if cfg.get('fork', 'auto') in replace else cfg.get('fork', 'auto')
|
'medusa': 'Medusa',
|
||||||
|
'sickbeard-api': 'SickBeard-api',
|
||||||
|
'sickgear': 'SickGear',
|
||||||
|
'sickchill': 'SickChill',
|
||||||
|
'sickrage': 'SickRage',
|
||||||
|
'stheno': 'Stheno',
|
||||||
|
}
|
||||||
|
_val = cfg.get('fork', 'auto')
|
||||||
|
f1 = replace.get(_val, _val)
|
||||||
try:
|
try:
|
||||||
fork = f1, core.FORKS[f1]
|
fork = f1, core.FORKS[f1]
|
||||||
except KeyError:
|
except KeyError:
|
||||||
|
@ -79,7 +87,6 @@ def auto_fork(section, input_category):
|
||||||
r = []
|
r = []
|
||||||
if r and r.ok:
|
if r and r.ok:
|
||||||
if apikey:
|
if apikey:
|
||||||
optional_parameters = []
|
|
||||||
try:
|
try:
|
||||||
json_data = r.json()
|
json_data = r.json()
|
||||||
except ValueError:
|
except ValueError:
|
||||||
|
|
|
@ -202,17 +202,17 @@ class DBConnection(object):
|
||||||
def table_info(self, table_name):
|
def table_info(self, table_name):
|
||||||
# FIXME ? binding is not supported here, but I cannot find a way to escape a string manually
|
# FIXME ? binding is not supported here, but I cannot find a way to escape a string manually
|
||||||
cursor = self.connection.execute('PRAGMA table_info({0})'.format(table_name))
|
cursor = self.connection.execute('PRAGMA table_info({0})'.format(table_name))
|
||||||
columns = {}
|
return {
|
||||||
for column in cursor:
|
column['name']: {'type': column['type']}
|
||||||
columns[column['name']] = {'type': column['type']}
|
for column in cursor
|
||||||
return columns
|
}
|
||||||
|
|
||||||
# http://stackoverflow.com/questions/3300464/how-can-i-get-dict-from-sqlite-query
|
# http://stackoverflow.com/questions/3300464/how-can-i-get-dict-from-sqlite-query
|
||||||
def _dict_factory(self, cursor, row):
|
def _dict_factory(self, cursor, row):
|
||||||
d = {}
|
return {
|
||||||
for idx, col in enumerate(cursor.description):
|
col[0]: row[idx]
|
||||||
d[col[0]] = row[idx]
|
for idx, col in enumerate(cursor.description)
|
||||||
return d
|
}
|
||||||
|
|
||||||
|
|
||||||
def sanity_check_database(connection, sanity_check):
|
def sanity_check_database(connection, sanity_check):
|
||||||
|
|
|
@ -148,7 +148,6 @@ def rename_script(dirname):
|
||||||
|
|
||||||
|
|
||||||
def par2(dirname):
|
def par2(dirname):
|
||||||
newlist = []
|
|
||||||
sofar = 0
|
sofar = 0
|
||||||
parfile = ''
|
parfile = ''
|
||||||
objects = []
|
objects = []
|
||||||
|
|
|
@ -80,10 +80,7 @@ def get_video_details(videofile, img=None, bitbucket=None):
|
||||||
file = videofile
|
file = videofile
|
||||||
if not core.FFPROBE:
|
if not core.FFPROBE:
|
||||||
return video_details, result
|
return video_details, result
|
||||||
if 'avprobe' in core.FFPROBE:
|
print_format = '-of' if 'avprobe' in core.FFPROBE else '-print_format'
|
||||||
print_format = '-of'
|
|
||||||
else:
|
|
||||||
print_format = '-print_format'
|
|
||||||
try:
|
try:
|
||||||
if img:
|
if img:
|
||||||
videofile = '-'
|
videofile = '-'
|
||||||
|
|
|
@ -624,7 +624,7 @@
|
||||||
from __future__ import print_function
|
from __future__ import print_function
|
||||||
|
|
||||||
import cleanup
|
import cleanup
|
||||||
cleanup.clean('core', 'libs')
|
cleanup.clean(cleanup.FOLDER_STRUCTURE)
|
||||||
|
|
||||||
import datetime
|
import datetime
|
||||||
import os
|
import os
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -18,7 +18,7 @@ def read(*names, **kwargs):
|
||||||
|
|
||||||
setup(
|
setup(
|
||||||
name='nzbToMedia',
|
name='nzbToMedia',
|
||||||
version='12.0.4',
|
version='12.0.5',
|
||||||
license='GPLv3',
|
license='GPLv3',
|
||||||
description='Efficient on demand post processing',
|
description='Efficient on demand post processing',
|
||||||
long_description="""
|
long_description="""
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue