From 52c6096b6a28429a1ac17b4f05821464f2c36179 Mon Sep 17 00:00:00 2001 From: Labrys Date: Tue, 25 Dec 2018 16:04:58 -0500 Subject: [PATCH] Fix PEP8 whitespace violations --- TorrentToMedia.py | 15 ++- core/__init__.py | 232 ++++++++++++++++----------------- core/auto_process/movies.py | 8 +- core/auto_process/music.py | 6 +- core/auto_process/tv.py | 8 +- core/configuration.py | 70 +++++----- core/forks.py | 4 +- core/scene_exceptions.py | 1 + core/transcoder.py | 26 ++-- core/utils.py | 19 ++- libs/custom/utorrent/client.py | 23 ++-- libs/custom/utorrent/upload.py | 29 ++--- nzbToMedia.py | 15 ++- tests/general.py | 6 +- 14 files changed, 237 insertions(+), 225 deletions(-) diff --git a/TorrentToMedia.py b/TorrentToMedia.py index 70bbcf95..0e521575 100755 --- a/TorrentToMedia.py +++ b/TorrentToMedia.py @@ -35,13 +35,14 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp pass control_value_dict = {"input_directory": text_type(input_directory1)} - new_value_dict = {"input_name": text_type(input_name1), - "input_hash": text_type(input_hash), - "input_id": text_type(input_id), - "client_agent": text_type(client_agent), - "status": 0, - "last_update": datetime.date.today().toordinal() - } + new_value_dict = { + "input_name": text_type(input_name1), + "input_hash": text_type(input_hash), + "input_id": text_type(input_id), + "client_agent": text_type(client_agent), + "status": 0, + "last_update": datetime.date.today().toordinal(), + } my_db.upsert("downloads", new_value_dict, control_value_dict) logger.debug("Received Directory: {0} | Name: {1} | Category: {2}".format(input_directory, input_name, input_category)) diff --git a/core/__init__.py b/core/__init__.py index cfc75199..0e73b883 100644 --- a/core/__init__.py +++ b/core/__init__.py @@ -77,9 +77,9 @@ FORKS[FORK_FAILED_TORRENT] = {"dir": None, "failed": None, "process_method": Non FORKS[FORK_SICKRAGE] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None} FORKS[FORK_SICKCHILL] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "force_next": None} FORKS[FORK_SICKBEARD_API] = {"path": None, "failed": None, "process_method": None, "force_replace": None, "return_data": None, "type": None, "delete": None, "force_next": None} -FORKS[FORK_MEDUSA] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs":None} +FORKS[FORK_MEDUSA] = {"proc_dir": None, "failed": None, "process_method": None, "force": None, "delete_on": None, "ignore_subs": None} FORKS[FORK_SICKGEAR] = {"dir": None, "failed": None, "process_method": None, "force": None} -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_POSTPROCESS_PARCHECK = 92 @@ -361,7 +361,7 @@ def initialize(section=None): NZB_CLIENTAGENT = CFG["Nzb"]["clientAgent"] # sabnzbd SABNZBDHOST = CFG["Nzb"]["sabnzbd_host"] - SABNZBDPORT = int(CFG["Nzb"]["sabnzbd_port"] or 8080) # defaults to accomodate NzbGet + SABNZBDPORT = int(CFG["Nzb"]["sabnzbd_port"] or 8080) # defaults to accomodate NzbGet SABNZBDAPIKEY = CFG["Nzb"]["sabnzbd_apikey"] NZB_DEFAULTDIR = CFG["Nzb"]["default_downloadDirectory"] GROUPS = CFG["Custom"]["remove_group"] @@ -398,7 +398,7 @@ def initialize(section=None): DELUGEUSR = CFG["Torrent"]["DelugeUSR"] # mysecretusr DELUGEPWD = CFG["Torrent"]["DelugePWD"] # mysecretpwr - QBITTORRENTHOST = CFG["Torrent"]["qBittorrenHost"] # localhost + QBITTORRENTHOST = CFG["Torrent"]["qBittorrenHost"] # localhost QBITTORRENTPORT = int(CFG["Torrent"]["qBittorrentPort"]) # 8080 QBITTORRENTUSR = CFG["Torrent"]["qBittorrentUSR"] # mysecretusr QBITTORRENTPWD = CFG["Torrent"]["qBittorrentPWD"] # mysecretpwr @@ -574,118 +574,118 @@ def initialize(section=None): 'libfaac': ['libfaac', 'aac', 'faac'] } transcode_defaults = { - 'iPad':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':None, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'iPad-1080p':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':'1920:1080','VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':None, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'iPad-720p':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':'1280:720','VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':None, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'Apple-TV':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':'1280:720','VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'ac3','ACODEC_ALLOW':['ac3'],'ABITRATE':None, 'ACHANNELS':6, - 'ACODEC2':'aac','ACODEC2_ALLOW':['libfaac'],'ABITRATE2':None, 'ACHANNELS2':2, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'iPod':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':'1280:720','VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, - 'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'iPhone':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':'460:320','VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, - 'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'PS3':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'ac3','ACODEC_ALLOW':['ac3'],'ABITRATE':None, 'ACHANNELS':6, - 'ACODEC2':'aac','ACODEC2_ALLOW':['libfaac'],'ABITRATE2':None, 'ACHANNELS2':2, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'xbox':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'ac3','ACODEC_ALLOW':['ac3'],'ABITRATE':None, 'ACHANNELS':6, - 'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'Roku-480p':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'Roku-720p':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'Roku-1080p':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':160000, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - }, - 'mkv':{ - 'VEXTENSION':'.mkv','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4', 'mpeg2video'], - 'ACODEC':'dts','ACODEC_ALLOW':['libfaac', 'dts', 'ac3', 'mp2', 'mp3'],'ABITRATE':None, 'ACHANNELS':8, - 'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, - 'ACODEC3':'ac3','ACODEC3_ALLOW':['libfaac', 'dts', 'ac3', 'mp2', 'mp3'],'ABITRATE3':None, 'ACHANNELS3':8, - 'SCODEC':'mov_text' - }, - 'mp4-scene-release':{ - 'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':19,'VLEVEL':'3.1', - 'VRESOLUTION':None,'VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4', 'mpeg2video'], - 'ACODEC':'dts','ACODEC_ALLOW':['libfaac', 'dts', 'ac3', 'mp2', 'mp3'],'ABITRATE':None, 'ACHANNELS':8, - 'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, - 'ACODEC3':'ac3','ACODEC3_ALLOW':['libfaac', 'dts', 'ac3', 'mp2', 'mp3'],'ABITRATE3':None, 'ACHANNELS3':8, - 'SCODEC':'mov_text' - }, - 'MKV-SD':{ - 'VEXTENSION':'.mkv','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':'1200k','VCRF':None,'VLEVEL':None, - 'VRESOLUTION':'720:-1','VCODEC_ALLOW':['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], - 'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, - 'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, - 'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, - 'SCODEC':'mov_text' - } + 'iPad': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': None, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'iPad-1080p': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': '1920:1080', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': None, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'iPad-720p': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': '1280:720', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': None, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'Apple-TV': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': '1280:720', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'ac3', 'ACODEC_ALLOW': ['ac3'], 'ABITRATE': None, 'ACHANNELS': 6, + 'ACODEC2': 'aac', 'ACODEC2_ALLOW': ['libfaac'], 'ABITRATE2': None, 'ACHANNELS2': 2, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'iPod': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': '1280:720', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2, + 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'iPhone': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': '460:320', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2, + 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'PS3': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'ac3', 'ACODEC_ALLOW': ['ac3'], 'ABITRATE': None, 'ACHANNELS': 6, + 'ACODEC2': 'aac', 'ACODEC2_ALLOW': ['libfaac'], 'ABITRATE2': None, 'ACHANNELS2': 2, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'xbox': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'ac3', 'ACODEC_ALLOW': ['ac3'], 'ABITRATE': None, 'ACHANNELS': 6, + 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'Roku-480p': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'Roku-720p': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'Roku-1080p': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 160000, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + }, + 'mkv': { + 'VEXTENSION': '.mkv', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4', 'mpeg2video'], + 'ACODEC': 'dts', 'ACODEC_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE': None, 'ACHANNELS': 8, + 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None, + 'ACODEC3': 'ac3', 'ACODEC3_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE3': None, 'ACHANNELS3': 8, + 'SCODEC': 'mov_text' + }, + 'mp4-scene-release': { + 'VEXTENSION': '.mp4', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': None, 'VCRF': 19, 'VLEVEL': '3.1', + 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4', 'mpeg2video'], + 'ACODEC': 'dts', 'ACODEC_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE': None, 'ACHANNELS': 8, + 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None, + 'ACODEC3': 'ac3', 'ACODEC3_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE3': None, 'ACHANNELS3': 8, + 'SCODEC': 'mov_text' + }, + 'MKV-SD': { + 'VEXTENSION': '.mkv', 'VCODEC': 'libx264', 'VPRESET': None, 'VFRAMERATE': None, 'VBITRATE': '1200k', 'VCRF': None, 'VLEVEL': None, + 'VRESOLUTION': '720: -1', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'], + 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2, + 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6, + 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None, + 'SCODEC': 'mov_text' + } } if DEFAULTS and DEFAULTS in transcode_defaults: VEXTENSION = transcode_defaults[DEFAULTS]['VEXTENSION'] diff --git a/core/auto_process/movies.py b/core/auto_process/movies.py index dde29946..9717c01d 100644 --- a/core/auto_process/movies.py +++ b/core/auto_process/movies.py @@ -26,9 +26,9 @@ class Movie(object): method = cfg["method"] else: method = None - #added importMode for Radarr config + # added importMode for Radarr config if section == "Radarr": - import_mode = cfg.get("importMode","Move") + import_mode = cfg.get("importMode", "Move") else: import_mode = None delete_failed = int(cfg["delete_failed"]) @@ -147,7 +147,7 @@ class Movie(object): logger.debug('Renaming: {0} to: {1}'.format(video, video2)) os.rename(video, video2) - if not apikey: #If only using Transcoder functions, exit here. + if not apikey: # If only using Transcoder functions, exit here. logger.info('No CouchPotato or Radarr apikey entered. Processing completed.') return [0, "{0}: Successfully post-processed {1}".format(section, input_name)] @@ -170,7 +170,7 @@ class Movie(object): logger.postprocess("Starting {0} scan for {1}".format(method, input_name), section) if section == "Radarr": - payload = {'name': 'DownloadedMoviesScan', 'path': params['media_folder'], 'downloadClientId': download_id,'importMode' : import_mode} + payload = {'name': 'DownloadedMoviesScan', 'path': params['media_folder'], 'downloadClientId': download_id, 'importMode': import_mode} if not download_id: payload.pop("downloadClientId") logger.debug("Opening URL: {0} with PARAMS: {1}".format(base_url, payload), section) diff --git a/core/auto_process/music.py b/core/auto_process/music.py index 0e5daeca..1275087d 100644 --- a/core/auto_process/music.py +++ b/core/auto_process/music.py @@ -61,9 +61,9 @@ class Music(object): core.extract_files(dir_name) input_name, dir_name = convert_to_ascii(input_name, dir_name) - #if listMediaFiles(dir_name, media=False, audio=True, meta=False, archives=False) and status: - # logger.info("Status shown as failed from Downloader, but valid video files found. Setting as successful.", section) - # status = 0 + # if listMediaFiles(dir_name, media=False, audio=True, meta=False, archives=False) and status: + # logger.info("Status shown as failed from Downloader, but valid video files found. Setting as successful.", section) + # status = 0 if status == 0 and section == "HeadPhones": diff --git a/core/auto_process/tv.py b/core/auto_process/tv.py index 930823ab..33cae750 100644 --- a/core/auto_process/tv.py +++ b/core/auto_process/tv.py @@ -44,7 +44,7 @@ class TV(object): 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.USELINK == "move-sym": process_method = "symlink" remote_path = int(cfg.get("remote_path", 0)) wait_for = int(cfg.get("wait_for", 2)) @@ -56,8 +56,8 @@ class TV(object): extract = 0 else: extract = int(cfg.get("extract", 0)) - #get importmode, default to "Move" for consistency with legacy - import_mode = cfg.get("importMode","Move") + # 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] @@ -256,7 +256,7 @@ class TV(object): if not apikey and username and password: login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root) login_params = {'username': username, 'password': password} - r = s.get(login, verify=False, timeout=(30,60)) + r = s.get(login, verify=False, timeout=(30, 60)) if r.status_code == 401 and r.cookies.get('_xsrf'): login_params['_xsrf'] = r.cookies.get('_xsrf') s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60)) diff --git a/core/configuration.py b/core/configuration.py index 6ac42645..64a04c6d 100644 --- a/core/configuration.py +++ b/core/configuration.py @@ -239,7 +239,7 @@ class ConfigObj(configobj.ConfigObj, Section): process_section(section, subsection) # create a backup of our old config - CFG_OLD.filename ="{config}.old".format(config=core.CONFIG_FILE) + CFG_OLD.filename = "{config}.old".format(config=core.CONFIG_FILE) CFG_OLD.write() # write our new config to autoProcessMedia.cfg @@ -299,9 +299,9 @@ class ConfigObj(configobj.ConfigObj, Section): section = "CouchPotato" env_cat_key = 'NZBPO_CPSCATEGORY' env_keys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'METHOD', 'DELETE_FAILED', 'REMOTE_PATH', - 'WAIT_FOR', 'WATCH_DIR', 'OMDBAPIKEY'] + 'WAIT_FOR', 'WATCH_DIR', 'OMDBAPIKEY'] cfg_keys = ['enabled', 'apikey', 'host', 'port', 'ssl', 'web_root', 'method', 'delete_failed', 'remote_path', - 'wait_for', 'watch_dir', 'omdbapikey'] + 'wait_for', 'watch_dir', 'omdbapikey'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_CPS{index}'.format(index=env_keys[index]) @@ -318,9 +318,9 @@ class ConfigObj(configobj.ConfigObj, Section): section = "SickBeard" env_cat_key = 'NZBPO_SBCATEGORY' env_keys = ['ENABLED', 'HOST', 'PORT', 'APIKEY', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', - 'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'REMOTE_PATH', 'PROCESS_METHOD'] + 'DELETE_FAILED', 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'REMOTE_PATH', 'PROCESS_METHOD'] cfg_keys = ['enabled', 'host', 'port', 'apikey', 'username', 'password', 'ssl', 'web_root', 'watch_dir', 'fork', - 'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy', 'remote_path', 'process_method'] + 'delete_failed', 'Torrent_NoLink', 'nzbExtractionBy', 'remote_path', 'process_method'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_SB{index}'.format(index=env_keys[index]) @@ -354,9 +354,9 @@ class ConfigObj(configobj.ConfigObj, Section): section = "Mylar" env_cat_key = 'NZBPO_MYCATEGORY' env_keys = ['ENABLED', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'APIKEY', 'SSL', 'WEB_ROOT', 'WATCH_DIR', - 'REMOTE_PATH'] + 'REMOTE_PATH'] cfg_keys = ['enabled', 'host', 'port', 'username', 'password', 'apikey', 'ssl', 'web_root', 'watch_dir', - 'remote_path'] + 'remote_path'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_MY{index}'.format(index=env_keys[index]) @@ -386,10 +386,10 @@ class ConfigObj(configobj.ConfigObj, Section): section = "NzbDrone" env_cat_key = 'NZBPO_NDCATEGORY' env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', - 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH', 'IMPORTMODE'] - #new cfgKey added for importMode + 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH', 'IMPORTMODE'] + # new cfgKey added for importMode cfg_keys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', - 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path','importMode'] + 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path', 'importMode'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_ND{index}'.format(index=env_keys[index]) @@ -406,10 +406,10 @@ class ConfigObj(configobj.ConfigObj, Section): section = "Radarr" env_cat_key = 'NZBPO_RACATEGORY' env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', - 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH', 'OMDBAPIKEY', 'IMPORTMODE'] - #new cfgKey added for importMode + 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH', 'OMDBAPIKEY', 'IMPORTMODE'] + # new cfgKey added for importMode cfg_keys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', - 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path', 'omdbapikey','importMode'] + 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path', 'omdbapikey', 'importMode'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_RA{index}'.format(index=env_keys[index]) @@ -426,9 +426,9 @@ class ConfigObj(configobj.ConfigObj, Section): section = "Lidarr" env_cat_key = 'NZBPO_LICATEGORY' env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', - 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH'] + 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH'] cfg_keys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', - 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path'] + 'Torrent_NoLink', 'nzbExtractionBy', 'wait_for', 'delete_failed', 'remote_path'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_LI{index}'.format(index=env_keys[index]) @@ -464,25 +464,25 @@ class ConfigObj(configobj.ConfigObj, Section): section = "Transcoder" env_keys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTFASTSTART', 'OUTPUTVIDEOPATH', - 'PROCESSOUTPUT', 'AUDIOLANGUAGE', 'ALLAUDIOLANGUAGES', 'SUBLANGUAGES', - 'ALLSUBLANGUAGES', 'EMBEDSUBS', 'BURNINSUBTITLE', 'EXTRACTSUBS', 'EXTERNALSUBDIR', - 'OUTPUTDEFAULT', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'VIDEOCODECALLOW', - 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', - 'AUDIOCODECALLOW', 'OUTPUTAUDIOBITRATE', 'OUTPUTQUALITYPERCENT', 'GETSUBS', - 'OUTPUTAUDIOTRACK2CODEC', 'AUDIOCODEC2ALLOW', 'OUTPUTAUDIOTRACK2BITRATE', - 'OUTPUTAUDIOOTHERCODEC', 'AUDIOOTHERCODECALLOW', 'OUTPUTAUDIOOTHERBITRATE', - 'OUTPUTSUBTITLECODEC', 'OUTPUTAUDIOCHANNELS', 'OUTPUTAUDIOTRACK2CHANNELS', - 'OUTPUTAUDIOOTHERCHANNELS','OUTPUTVIDEORESOLUTION'] + 'PROCESSOUTPUT', 'AUDIOLANGUAGE', 'ALLAUDIOLANGUAGES', 'SUBLANGUAGES', + 'ALLSUBLANGUAGES', 'EMBEDSUBS', 'BURNINSUBTITLE', 'EXTRACTSUBS', 'EXTERNALSUBDIR', + 'OUTPUTDEFAULT', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'VIDEOCODECALLOW', + 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', + 'AUDIOCODECALLOW', 'OUTPUTAUDIOBITRATE', 'OUTPUTQUALITYPERCENT', 'GETSUBS', + 'OUTPUTAUDIOTRACK2CODEC', 'AUDIOCODEC2ALLOW', 'OUTPUTAUDIOTRACK2BITRATE', + 'OUTPUTAUDIOOTHERCODEC', 'AUDIOOTHERCODECALLOW', 'OUTPUTAUDIOOTHERBITRATE', + 'OUTPUTSUBTITLECODEC', 'OUTPUTAUDIOCHANNELS', 'OUTPUTAUDIOTRACK2CHANNELS', + 'OUTPUTAUDIOOTHERCHANNELS', 'OUTPUTVIDEORESOLUTION'] cfg_keys = ['transcode', 'duplicate', 'ignoreExtensions', 'outputFastStart', 'outputVideoPath', - 'processOutput', 'audioLanguage', 'allAudioLanguages', 'subLanguages', - 'allSubLanguages', 'embedSubs', 'burnInSubtitle', 'extractSubs', 'externalSubDir', - 'outputDefault', 'outputVideoExtension', 'outputVideoCodec', 'VideoCodecAllow', - 'outputVideoPreset', 'outputVideoFramerate', 'outputVideoBitrate', 'outputAudioCodec', - 'AudioCodecAllow', 'outputAudioBitrate', 'outputQualityPercent', 'getSubs', - 'outputAudioTrack2Codec', 'AudioCodec2Allow', 'outputAudioTrack2Bitrate', - 'outputAudioOtherCodec', 'AudioOtherCodecAllow', 'outputAudioOtherBitrate', - 'outputSubtitleCodec', 'outputAudioChannels', 'outputAudioTrack2Channels', - 'outputAudioOtherChannels', 'outputVideoResolution'] + 'processOutput', 'audioLanguage', 'allAudioLanguages', 'subLanguages', + 'allSubLanguages', 'embedSubs', 'burnInSubtitle', 'extractSubs', 'externalSubDir', + 'outputDefault', 'outputVideoExtension', 'outputVideoCodec', 'VideoCodecAllow', + 'outputVideoPreset', 'outputVideoFramerate', 'outputVideoBitrate', 'outputAudioCodec', + 'AudioCodecAllow', 'outputAudioBitrate', 'outputQualityPercent', 'getSubs', + 'outputAudioTrack2Codec', 'AudioCodec2Allow', 'outputAudioTrack2Bitrate', + 'outputAudioOtherCodec', 'AudioOtherCodecAllow', 'outputAudioOtherBitrate', + 'outputSubtitleCodec', 'outputAudioChannels', 'outputAudioTrack2Channels', + 'outputAudioOtherChannels', 'outputVideoResolution'] for index in range(len(env_keys)): key = 'NZBPO_{index}'.format(index=env_keys[index]) if key in os.environ: @@ -503,9 +503,9 @@ class ConfigObj(configobj.ConfigObj, Section): section = "UserScript" env_cat_key = 'NZBPO_USCATEGORY' env_keys = ['USER_SCRIPT_MEDIAEXTENSIONS', 'USER_SCRIPT_PATH', 'USER_SCRIPT_PARAM', 'USER_SCRIPT_RUNONCE', - 'USER_SCRIPT_SUCCESSCODES', 'USER_SCRIPT_CLEAN', 'USDELAY', 'USREMOTE_PATH'] + 'USER_SCRIPT_SUCCESSCODES', 'USER_SCRIPT_CLEAN', 'USDELAY', 'USREMOTE_PATH'] cfg_keys = ['user_script_mediaExtensions', 'user_script_path', 'user_script_param', 'user_script_runOnce', - 'user_script_successCodes', 'user_script_clean', 'delay', 'remote_path'] + 'user_script_successCodes', 'user_script_clean', 'delay', 'remote_path'] if env_cat_key in os.environ: for index in range(len(env_keys)): key = 'NZBPO_{index}'.format(index=env_keys[index]) diff --git a/core/forks.py b/core/forks.py index ca8df914..c15879c2 100644 --- a/core/forks.py +++ b/core/forks.py @@ -20,7 +20,7 @@ def auto_fork(section, input_category): apikey = cfg.get("apikey") ssl = int(cfg.get("ssl", 0)) web_root = cfg.get("web_root", "") - replace = {'sickrage':'SickRage', 'sickchill':'SickChill', 'sickgear':'SickGear', 'medusa':'Medusa', 'sickbeard-api':'SickBeard-api'} + replace = {'sickrage': 'SickRage', 'sickchill': 'SickChill', 'sickgear': 'SickGear', 'medusa': 'Medusa', 'sickbeard-api': 'SickBeard-api'} f1 = replace[cfg.get("fork", "auto")] if cfg.get("fork", "auto") in replace else cfg.get("fork", "auto") try: fork = f1, core.FORKS[f1] @@ -68,7 +68,7 @@ def auto_fork(section, input_category): login = "{protocol}{host}:{port}{root}/login".format( protocol=protocol, host=host, port=port, root=web_root) login_params = {'username': username, 'password': password} - r = s.get(login, verify=False, timeout=(30,60)) + r = s.get(login, verify=False, timeout=(30, 60)) if r.status_code == 401 and r.cookies.get('_xsrf'): login_params['_xsrf'] = r.cookies.get('_xsrf') s.post(login, data=login_params, stream=True, verify=False) diff --git a/core/scene_exceptions.py b/core/scene_exceptions.py index 90e745de..dafc2b6a 100644 --- a/core/scene_exceptions.py +++ b/core/scene_exceptions.py @@ -146,6 +146,7 @@ def rename_script(dirname): except Exception as error: logger.error("Unable to rename file due to: {error}".format(error=error), "EXCEPTION") + def par2(dirname): newlist = [] sofar = 0 diff --git a/core/transcoder.py b/core/transcoder.py index 223b1c20..b3727ee1 100644 --- a/core/transcoder.py +++ b/core/transcoder.py @@ -208,8 +208,8 @@ def build_commands(file, new_dir, movie_name, bitbucket): sub_streams = [item for item in video_details["streams"] if item["codec_type"] == "subtitle"] if core.VEXTENSION not in ['.mkv', '.mpegts']: sub_streams = [item for item in video_details["streams"] if - item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ - "codec_name"] != "pgssub"] + item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ + "codec_name"] != "pgssub"] for video in video_streams: codec = video["codec_name"] @@ -262,7 +262,7 @@ def build_commands(file, new_dir, movie_name, bitbucket): if audio_streams: for i, val in reversed(list(enumerate(audio_streams))): try: - if "Commentary" in val.get("tags").get("title"): # Split out commentry tracks. + if "Commentary" in val.get("tags").get("title"): # Split out commentry tracks. commentary.append(val) del audio_streams[i] except: @@ -380,13 +380,13 @@ def build_commands(file, new_dir, movie_name, bitbucket): if audio_cmd2[1] in ['aac', 'dts']: audio_cmd2[2:2] = ['-strict', '-2'] - if a_mapped[1] == a_mapped[0] and audio_cmd2[1:] == audio_cmd[1:]: #check for duplicate output track. + if a_mapped[1] == a_mapped[0] and audio_cmd2[1:] == audio_cmd[1:]: # check for duplicate output track. del map_cmd[-2:] else: audio_cmd.extend(audio_cmd2) if core.AINCLUDE and core.ACODEC3: - audio_streams.extend(commentary) #add commentry tracks back here. + audio_streams.extend(commentary) # add commentry tracks back here. for audio in audio_streams: if audio["index"] in a_mapped: continue @@ -443,7 +443,7 @@ def build_commands(file, new_dir, movie_name, bitbucket): burnt = 1 if not core.ALLOWSUBS: break - if sub["codec_name"] in ["dvd_subtitle", "VobSub"] and core.SCODEC == "mov_text": # We can't convert these. + if sub["codec_name"] in ["dvd_subtitle", "VobSub"] and core.SCODEC == "mov_text": # We can't convert these. continue map_cmd.extend(['-map', '0:{index}'.format(index=sub["index"])]) s_mapped.extend([sub["index"]]) @@ -454,7 +454,7 @@ def build_commands(file, new_dir, movie_name, bitbucket): break if sub["index"] in s_mapped: continue - if sub["codec_name"] in ["dvd_subtitle", "VobSub"] and core.SCODEC == "mov_text": # We can't convert these. + if sub["codec_name"] in ["dvd_subtitle", "VobSub"] and core.SCODEC == "mov_text": # We can't convert these. continue map_cmd.extend(['-map', '0:{index}'.format(index=sub["index"])]) s_mapped.extend([sub["index"]]) @@ -478,7 +478,7 @@ def build_commands(file, new_dir, movie_name, bitbucket): continue if core.SCODEC == "mov_text": subcode = [stream["codec_name"] for stream in sub_details["streams"]] - if set(subcode).intersection(["dvd_subtitle", "VobSub"]): # We can't convert these. + if set(subcode).intersection(["dvd_subtitle", "VobSub"]): # We can't convert these. continue command.extend(['-i', subfile]) lan = os.path.splitext(os.path.splitext(subfile)[0])[1][1:].split('-')[0] @@ -542,12 +542,12 @@ def extract_subs(file, newfile_path, bitbucket): try: sub_streams = [item for item in video_details["streams"] if - item["codec_type"] == "subtitle" and item["tags"]["language"] in core.SLANGUAGES and item[ - "codec_name"] != "hdmv_pgs_subtitle" and item["codec_name"] != "pgssub"] + item["codec_type"] == "subtitle" and item["tags"]["language"] in core.SLANGUAGES and item[ + "codec_name"] != "hdmv_pgs_subtitle" and item["codec_name"] != "pgssub"] except: sub_streams = [item for item in video_details["streams"] if - item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ - "codec_name"] != "pgssub"] + item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ + "codec_name"] != "pgssub"] num = len(sub_streams) for n in range(num): sub = sub_streams[n] @@ -650,7 +650,7 @@ def rip_iso(item, new_dir, bitbucket): proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) out, err = proc.communicate() file_list = [re.match(".+(VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb])", line).groups()[0] for line in - out.splitlines() if re.match(".+VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", line)] + out.splitlines() if re.match(".+VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", line)] combined = [] for n in range(99): concat = [] diff --git a/core/utils.py b/core/utils.py index ce8944ea..7189cce6 100644 --- a/core/utils.py +++ b/core/utils.py @@ -45,10 +45,15 @@ requests.packages.urllib3.disable_warnings() # Monkey Patch shutil.copyfileobj() to adjust the buffer length to 512KB rather than 4KB shutil.copyfileobjOrig = shutil.copyfileobj + + def copyfileobj_fast(fsrc, fdst, length=512 * 1024): shutil.copyfileobjOrig(fsrc, fdst, length=length) + + shutil.copyfileobj = copyfileobj_fast + def report_nzb(failure_link, client_agent): # Contact indexer site logger.info("Sending failure notification to indexer site") @@ -605,6 +610,7 @@ def parse_vuze(args): return input_directory, input_name, input_category, input_hash, input_id + def parse_qbittorrent(args): # qbittorrent usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D|%N|%L|%I" try: @@ -612,28 +618,29 @@ def parse_qbittorrent(args): except: input = [] try: - input_directory = os.path.normpath(input[0].replace('"','')) + input_directory = os.path.normpath(input[0].replace('"', '')) except: input_directory = '' try: - input_name = input[1].replace('"','') + input_name = input[1].replace('"', '') except: input_name = '' try: - input_category = input[2].replace('"','') + input_category = input[2].replace('"', '') except: input_category = '' try: - input_hash = input[3].replace('"','') + input_hash = input[3].replace('"', '') except: input_hash = '' try: - input_id = input[3].replace('"','') + input_id = input[3].replace('"', '') except: input_id = '' return input_directory, input_name, input_category, input_hash, input_id + def parse_args(client_agent, args): clients = { 'other': parse_other, @@ -1309,6 +1316,7 @@ def get_download_info(input_name, status): return sql_results + class WindowsProcess(object): def __init__(self): self.mutex = None @@ -1385,6 +1393,7 @@ class PosixProcess(object): if os.path.isfile(self.pidpath): os.unlink(self.pidpath) + if os.name == 'nt': RunningProcess = WindowsProcess else: diff --git a/libs/custom/utorrent/client.py b/libs/custom/utorrent/client.py index 44dd1679..c58023a0 100644 --- a/libs/custom/utorrent/client.py +++ b/libs/custom/utorrent/client.py @@ -19,6 +19,7 @@ try: except ImportError: import simplejson as json + class UTorrentClient(object): def __init__(self, base_url, username, password): @@ -27,7 +28,7 @@ class UTorrentClient(object): self.password = password self.opener = self._make_opener('uTorrent', base_url, username, password) self.token = self._get_token() - #TODO refresh token, when necessary + # TODO refresh token, when necessary def _make_opener(self, realm, base_url, username, password): '''uTorrent API need HTTP Basic Auth and cookie support for token verify.''' @@ -60,25 +61,25 @@ class UTorrentClient(object): return self._action(params) def start(self, *hashes): - params = [('action', 'start'),] + params = [('action', 'start'), ] for hash in hashes: params.append(('hash', hash)) return self._action(params) def stop(self, *hashes): - params = [('action', 'stop'),] + params = [('action', 'stop'), ] for hash in hashes: params.append(('hash', hash)) return self._action(params) def pause(self, *hashes): - params = [('action', 'pause'),] + params = [('action', 'pause'), ] for hash in hashes: params.append(('hash', hash)) return self._action(params) def forcestart(self, *hashes): - params = [('action', 'forcestart'),] + params = [('action', 'forcestart'), ] for hash in hashes: params.append(('hash', hash)) return self._action(params) @@ -94,8 +95,8 @@ class UTorrentClient(object): def setprops(self, hash, **kvpairs): params = [('action', 'setprops'), ('hash', hash)] for k, v in iteritems(kvpairs): - params.append( ("s", k) ) - params.append( ("v", v) ) + params.append(("s", k)) + params.append(("v", v)) return self._action(params) @@ -111,7 +112,7 @@ class UTorrentClient(object): form = MultiPartForm() if filepath is not None: - file_handler = open(filepath,'rb') + file_handler = open(filepath, 'rb') else: file_handler = StringIO(bytes) @@ -124,19 +125,19 @@ class UTorrentClient(object): self._action(params) def remove(self, *hashes): - params = [('action', 'remove'),] + params = [('action', 'remove'), ] for hash in hashes: params.append(('hash', hash)) return self._action(params) def removedata(self, *hashes): - params = [('action', 'removedata'),] + params = [('action', 'removedata'), ] for hash in hashes: params.append(('hash', hash)) return self._action(params) def _action(self, params, body=None, content_type=None): - #about token, see https://github.com/bittorrent/webui/wiki/TokenSystem + # about token, see https://github.com/bittorrent/webui/wiki/TokenSystem url = self.base_url + '?token=' + self.token + '&' + urlencode(params) request = Request(url) diff --git a/libs/custom/utorrent/upload.py b/libs/custom/utorrent/upload.py index f5659f41..faa21591 100644 --- a/libs/custom/utorrent/upload.py +++ b/libs/custom/utorrent/upload.py @@ -42,29 +42,28 @@ class MultiPartForm(object): # Add the form fields parts.extend( - [ part_boundary, - 'Content-Disposition: form-data; name="%s"' % name, - '', - value, - ] + [part_boundary, + 'Content-Disposition: form-data; name="%s"' % name, + '', + value, + ] for name, value in self.form_fields - ) + ) # Add the files to upload parts.extend( - [ part_boundary, - 'Content-Disposition: file; name="%s"; filename="%s"' % \ - (field_name, filename), - 'Content-Type: %s' % content_type, - '', - body, - ] + [part_boundary, + 'Content-Disposition: file; name="%s"; filename="%s"' % (field_name, filename), + 'Content-Type: %s' % content_type, + '', + body, + ] for field_name, filename, content_type, body in self.files - ) + ) # Flatten the list and add closing boundary marker, # then return CR+LF separated data flattened = list(itertools.chain(*parts)) flattened.append('--' + self.boundary + '--') flattened.append('') - return '\r\n'.join(flattened) \ No newline at end of file + return '\r\n'.join(flattened) diff --git a/nzbToMedia.py b/nzbToMedia.py index d3b09e7f..862231e1 100755 --- a/nzbToMedia.py +++ b/nzbToMedia.py @@ -668,13 +668,14 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d pass control_value_dict = {"input_directory": text_type(input_directory1)} - new_value_dict = {"input_name": text_type(input_name1), - "input_hash": text_type(download_id), - "input_id": text_type(download_id), - "client_agent": text_type(client_agent), - "status": 0, - "last_update": datetime.date.today().toordinal() - } + new_value_dict = { + "input_name": text_type(input_name1), + "input_hash": text_type(download_id), + "input_id": text_type(download_id), + "client_agent": text_type(client_agent), + "status": 0, + "last_update": datetime.date.today().toordinal(), + } my_db.upsert("downloads", new_value_dict, control_value_dict) # auto-detect section diff --git a/tests/general.py b/tests/general.py index 8692d430..f6e4f35a 100755 --- a/tests/general.py +++ b/tests/general.py @@ -14,15 +14,15 @@ from core.utils import server_responding # Initialize the config core.initialize() -#label = core.TORRENT_CLASS.core.get_torrent_status("f33a9c4b15cbd9170722d700069af86746817ade", ["label"]).get()['label'] -#print label +# label = core.TORRENT_CLASS.core.get_torrent_status("f33a9c4b15cbd9170722d700069af86746817ade", ["label"]).get()['label'] +# print label if transcoder.is_video_good(core.TEST_FILE, 0): print("FFPROBE Works") else: print("FFPROBE FAILED") -test = core.CFG['SickBeard','NzbDrone']['tv'].isenabled() +test = core.CFG['SickBeard', 'NzbDrone']['tv'].isenabled() print(test) section = core.CFG.findsection('tv').isenabled() print(section)