Merge pull request #1455 from clinton-hall/fix/pep8

Fix various PEP8 violations
This commit is contained in:
Labrys of Knossos 2018-12-26 11:42:42 -05:00 committed by GitHub
commit 857c47e8c7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 392 additions and 2560 deletions

View file

@ -31,17 +31,18 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
try: try:
encoded, input_directory1 = char_replace(input_directory) encoded, input_directory1 = char_replace(input_directory)
encoded, input_name1 = char_replace(input_name) encoded, input_name1 = char_replace(input_name)
except: except Exception:
pass pass
control_value_dict = {"input_directory": text_type(input_directory1)} control_value_dict = {"input_directory": text_type(input_directory1)}
new_value_dict = {"input_name": text_type(input_name1), new_value_dict = {
"input_hash": text_type(input_hash), "input_name": text_type(input_name1),
"input_id": text_type(input_id), "input_hash": text_type(input_hash),
"client_agent": text_type(client_agent), "input_id": text_type(input_id),
"status": 0, "client_agent": text_type(client_agent),
"last_update": datetime.date.today().toordinal() "status": 0,
} "last_update": datetime.date.today().toordinal(),
}
my_db.upsert("downloads", new_value_dict, control_value_dict) 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)) logger.debug("Received Directory: {0} | Name: {1} | Category: {2}".format(input_directory, input_name, input_category))
@ -195,7 +196,7 @@ def process_torrent(input_directory, input_name, input_category, input_hash, inp
try: try:
core.copy_link(inputFile, target_file, core.USELINK) core.copy_link(inputFile, target_file, core.USELINK)
core.remove_read_only(target_file) core.remove_read_only(target_file)
except: except Exception:
logger.error("Failed to link: {0} to {1}".format(inputFile, target_file)) logger.error("Failed to link: {0} to {1}".format(inputFile, target_file))
input_name, output_destination = convert_to_ascii(input_name, output_destination) input_name, output_destination = convert_to_ascii(input_name, output_destination)
@ -305,7 +306,7 @@ def main(args):
try: try:
input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args) input_directory, input_name, input_category, input_hash, input_id = core.parse_args(client_agent, args)
except: except Exception:
logger.error("There was a problem loading variables") logger.error("There was a problem loading variables")
return -1 return -1

View file

@ -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_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_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_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} 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 Exit Codes
NZBGET_POSTPROCESS_PARCHECK = 92 NZBGET_POSTPROCESS_PARCHECK = 92
@ -281,7 +281,7 @@ def initialize(section=None):
# pylint: disable=E1101 # pylint: disable=E1101
# On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError # On non-unicode builds this will raise an AttributeError, if encoding type is not valid it throws a LookupError
sys.setdefaultencoding(SYS_ENCODING) sys.setdefaultencoding(SYS_ENCODING)
except: except Exception:
print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable' print('Sorry, you MUST add the nzbToMedia folder to the PYTHONPATH environment variable'
'\nor find another way to force Python to use {codec} for string encoding.'.format '\nor find another way to force Python to use {codec} for string encoding.'.format
(codec=SYS_ENCODING)) (codec=SYS_ENCODING))
@ -345,7 +345,7 @@ def initialize(section=None):
# restart nzbToMedia # restart nzbToMedia
try: try:
del MYAPP del MYAPP
except: except Exception:
pass pass
restart() restart()
else: else:
@ -361,7 +361,7 @@ def initialize(section=None):
NZB_CLIENTAGENT = CFG["Nzb"]["clientAgent"] # sabnzbd NZB_CLIENTAGENT = CFG["Nzb"]["clientAgent"] # sabnzbd
SABNZBDHOST = CFG["Nzb"]["sabnzbd_host"] 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"] SABNZBDAPIKEY = CFG["Nzb"]["sabnzbd_apikey"]
NZB_DEFAULTDIR = CFG["Nzb"]["default_downloadDirectory"] NZB_DEFAULTDIR = CFG["Nzb"]["default_downloadDirectory"]
GROUPS = CFG["Custom"]["remove_group"] GROUPS = CFG["Custom"]["remove_group"]
@ -398,7 +398,7 @@ def initialize(section=None):
DELUGEUSR = CFG["Torrent"]["DelugeUSR"] # mysecretusr DELUGEUSR = CFG["Torrent"]["DelugeUSR"] # mysecretusr
DELUGEPWD = CFG["Torrent"]["DelugePWD"] # mysecretpwr DELUGEPWD = CFG["Torrent"]["DelugePWD"] # mysecretpwr
QBITTORRENTHOST = CFG["Torrent"]["qBittorrenHost"] # localhost QBITTORRENTHOST = CFG["Torrent"]["qBittorrenHost"] # localhost
QBITTORRENTPORT = int(CFG["Torrent"]["qBittorrentPort"]) # 8080 QBITTORRENTPORT = int(CFG["Torrent"]["qBittorrentPort"]) # 8080
QBITTORRENTUSR = CFG["Torrent"]["qBittorrentUSR"] # mysecretusr QBITTORRENTUSR = CFG["Torrent"]["qBittorrentUSR"] # mysecretusr
QBITTORRENTPWD = CFG["Torrent"]["qBittorrentPWD"] # mysecretpwr QBITTORRENTPWD = CFG["Torrent"]["qBittorrentPWD"] # mysecretpwr
@ -426,27 +426,27 @@ def initialize(section=None):
try: try:
subprocess.Popen(["nice"], stdout=devnull, stderr=devnull).communicate() subprocess.Popen(["nice"], stdout=devnull, stderr=devnull).communicate()
NICENESS.extend(['nice', '-n{0}'.format(int(CFG["Posix"]["niceness"]))]) NICENESS.extend(['nice', '-n{0}'.format(int(CFG["Posix"]["niceness"]))])
except: except Exception:
pass pass
try: try:
subprocess.Popen(["ionice"], stdout=devnull, stderr=devnull).communicate() subprocess.Popen(["ionice"], stdout=devnull, stderr=devnull).communicate()
try: try:
NICENESS.extend(['ionice', '-c{0}'.format(int(CFG["Posix"]["ionice_class"]))]) NICENESS.extend(['ionice', '-c{0}'.format(int(CFG["Posix"]["ionice_class"]))])
except: except Exception:
pass pass
try: try:
if 'ionice' in NICENESS: if 'ionice' in NICENESS:
NICENESS.extend(['-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))]) NICENESS.extend(['-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))])
else: else:
NICENESS.extend(['ionice', '-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))]) NICENESS.extend(['ionice', '-n{0}'.format(int(CFG["Posix"]["ionice_classdata"]))])
except: except Exception:
pass pass
except: except Exception:
pass pass
devnull.close() devnull.close()
COMPRESSEDCONTAINER = [re.compile('.r\d{2}$', re.I), COMPRESSEDCONTAINER = [re.compile(r'.r\d{2}$', re.I),
re.compile('.part\d+.rar$', re.I), re.compile(r'.part\d+.rar$', re.I),
re.compile('.rar$', re.I)] re.compile('.rar$', re.I)]
COMPRESSEDCONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in CFG["Extensions"]["compressedExtensions"]] COMPRESSEDCONTAINER += [re.compile('{0}$'.format(ext), re.I) for ext in CFG["Extensions"]["compressedExtensions"]]
MEDIACONTAINER = CFG["Extensions"]["mediaExtensions"] MEDIACONTAINER = CFG["Extensions"]["mediaExtensions"]
@ -480,7 +480,7 @@ def initialize(section=None):
GENERALOPTS.append('+genpts') GENERALOPTS.append('+genpts')
try: try:
OUTPUTQUALITYPERCENT = int(CFG["Transcoder"]["outputQualityPercent"]) OUTPUTQUALITYPERCENT = int(CFG["Transcoder"]["outputQualityPercent"])
except: except Exception:
pass pass
OUTPUTVIDEOPATH = CFG["Transcoder"]["outputVideoPath"] OUTPUTVIDEOPATH = CFG["Transcoder"]["outputVideoPath"]
PROCESSOUTPUT = int(CFG["Transcoder"]["processOutput"]) PROCESSOUTPUT = int(CFG["Transcoder"]["processOutput"])
@ -505,19 +505,19 @@ def initialize(section=None):
VPRESET = CFG["Transcoder"]["outputVideoPreset"].strip() VPRESET = CFG["Transcoder"]["outputVideoPreset"].strip()
try: try:
VFRAMERATE = float(CFG["Transcoder"]["outputVideoFramerate"].strip()) VFRAMERATE = float(CFG["Transcoder"]["outputVideoFramerate"].strip())
except: except Exception:
pass pass
try: try:
VCRF = int(CFG["Transcoder"]["outputVideoCRF"].strip()) VCRF = int(CFG["Transcoder"]["outputVideoCRF"].strip())
except: except Exception:
pass pass
try: try:
VLEVEL = CFG["Transcoder"]["outputVideoLevel"].strip() VLEVEL = CFG["Transcoder"]["outputVideoLevel"].strip()
except: except Exception:
pass pass
try: try:
VBITRATE = int((CFG["Transcoder"]["outputVideoBitrate"].strip()).replace('k', '000')) VBITRATE = int((CFG["Transcoder"]["outputVideoBitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
VRESOLUTION = CFG["Transcoder"]["outputVideoResolution"] VRESOLUTION = CFG["Transcoder"]["outputVideoResolution"]
ACODEC = CFG["Transcoder"]["outputAudioCodec"].strip() ACODEC = CFG["Transcoder"]["outputAudioCodec"].strip()
@ -528,11 +528,11 @@ def initialize(section=None):
ACODEC_ALLOW = [] ACODEC_ALLOW = []
try: try:
ACHANNELS = int(CFG["Transcoder"]["outputAudioChannels"].strip()) ACHANNELS = int(CFG["Transcoder"]["outputAudioChannels"].strip())
except: except Exception:
pass pass
try: try:
ABITRATE = int((CFG["Transcoder"]["outputAudioBitrate"].strip()).replace('k', '000')) ABITRATE = int((CFG["Transcoder"]["outputAudioBitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
ACODEC2 = CFG["Transcoder"]["outputAudioTrack2Codec"].strip() ACODEC2 = CFG["Transcoder"]["outputAudioTrack2Codec"].strip()
ACODEC2_ALLOW = CFG["Transcoder"]["AudioCodec2Allow"].strip() ACODEC2_ALLOW = CFG["Transcoder"]["AudioCodec2Allow"].strip()
@ -542,11 +542,11 @@ def initialize(section=None):
ACODEC2_ALLOW = [] ACODEC2_ALLOW = []
try: try:
ACHANNELS2 = int(CFG["Transcoder"]["outputAudioTrack2Channels"].strip()) ACHANNELS2 = int(CFG["Transcoder"]["outputAudioTrack2Channels"].strip())
except: except Exception:
pass pass
try: try:
ABITRATE2 = int((CFG["Transcoder"]["outputAudioTrack2Bitrate"].strip()).replace('k', '000')) ABITRATE2 = int((CFG["Transcoder"]["outputAudioTrack2Bitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
ACODEC3 = CFG["Transcoder"]["outputAudioOtherCodec"].strip() ACODEC3 = CFG["Transcoder"]["outputAudioOtherCodec"].strip()
ACODEC3_ALLOW = CFG["Transcoder"]["AudioOtherCodecAllow"].strip() ACODEC3_ALLOW = CFG["Transcoder"]["AudioOtherCodecAllow"].strip()
@ -556,11 +556,11 @@ def initialize(section=None):
ACODEC3_ALLOW = [] ACODEC3_ALLOW = []
try: try:
ACHANNELS3 = int(CFG["Transcoder"]["outputAudioOtherChannels"].strip()) ACHANNELS3 = int(CFG["Transcoder"]["outputAudioOtherChannels"].strip())
except: except Exception:
pass pass
try: try:
ABITRATE3 = int((CFG["Transcoder"]["outputAudioOtherBitrate"].strip()).replace('k', '000')) ABITRATE3 = int((CFG["Transcoder"]["outputAudioOtherBitrate"].strip()).replace('k', '000'))
except: except Exception:
pass pass
SCODEC = CFG["Transcoder"]["outputSubtitleCodec"].strip() SCODEC = CFG["Transcoder"]["outputSubtitleCodec"].strip()
BURN = int(CFG["Transcoder"]["burnInSubtitle"].strip()) BURN = int(CFG["Transcoder"]["burnInSubtitle"].strip())
@ -574,118 +574,118 @@ def initialize(section=None):
'libfaac': ['libfaac', 'aac', 'faac'] 'libfaac': ['libfaac', 'aac', 'faac']
} }
transcode_defaults = { transcode_defaults = {
'iPad':{ 'iPad': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':None, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': None, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'iPad-1080p':{ 'iPad-1080p': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': '1920:1080', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':None, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': None, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'iPad-720p':{ 'iPad-720p': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': '1280:720', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':None, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': None, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'Apple-TV':{ 'Apple-TV': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': '1280:720', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'ac3','ACODEC_ALLOW':['ac3'],'ABITRATE':None, 'ACHANNELS':6, 'ACODEC': 'ac3', 'ACODEC_ALLOW': ['ac3'], 'ABITRATE': None, 'ACHANNELS': 6,
'ACODEC2':'aac','ACODEC2_ALLOW':['libfaac'],'ABITRATE2':None, 'ACHANNELS2':2, 'ACODEC2': 'aac', 'ACODEC2_ALLOW': ['libfaac'], 'ABITRATE2': None, 'ACHANNELS2': 2,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'iPod':{ 'iPod': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': '1280:720', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2,
'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'iPhone':{ 'iPhone': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': '460:320', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2,
'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'PS3':{ 'PS3': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'ac3','ACODEC_ALLOW':['ac3'],'ABITRATE':None, 'ACHANNELS':6, 'ACODEC': 'ac3', 'ACODEC_ALLOW': ['ac3'], 'ABITRATE': None, 'ACHANNELS': 6,
'ACODEC2':'aac','ACODEC2_ALLOW':['libfaac'],'ABITRATE2':None, 'ACHANNELS2':2, 'ACODEC2': 'aac', 'ACODEC2_ALLOW': ['libfaac'], 'ABITRATE2': None, 'ACHANNELS2': 2,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'xbox':{ 'xbox': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'ac3','ACODEC_ALLOW':['ac3'],'ABITRATE':None, 'ACHANNELS':6, 'ACODEC': 'ac3', 'ACODEC_ALLOW': ['ac3'], 'ABITRATE': None, 'ACHANNELS': 6,
'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'Roku-480p':{ 'Roku-480p': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'Roku-720p':{ 'Roku-720p': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'Roku-1080p':{ 'Roku-1080p': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': None, 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':160000, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 160000, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'mkv':{ 'mkv': {
'VEXTENSION':'.mkv','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':None,'VLEVEL':None, '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'], '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, 'ACODEC': 'dts', 'ACODEC_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE': None, 'ACHANNELS': 8,
'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None,
'ACODEC3':'ac3','ACODEC3_ALLOW':['libfaac', 'dts', 'ac3', 'mp2', 'mp3'],'ABITRATE3':None, 'ACHANNELS3':8, 'ACODEC3': 'ac3', 'ACODEC3_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE3': None, 'ACHANNELS3': 8,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'mp4-scene-release':{ 'mp4-scene-release': {
'VEXTENSION':'.mp4','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':None,'VCRF':19,'VLEVEL':'3.1', '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'], '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, 'ACODEC': 'dts', 'ACODEC_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE': None, 'ACHANNELS': 8,
'ACODEC2':None,'ACODEC2_ALLOW':[],'ABITRATE2':None, 'ACHANNELS2':None, 'ACODEC2': None, 'ACODEC2_ALLOW': [], 'ABITRATE2': None, 'ACHANNELS2': None,
'ACODEC3':'ac3','ACODEC3_ALLOW':['libfaac', 'dts', 'ac3', 'mp2', 'mp3'],'ABITRATE3':None, 'ACHANNELS3':8, 'ACODEC3': 'ac3', 'ACODEC3_ALLOW': ['libfaac', 'dts', 'ac3', 'mp2', 'mp3'], 'ABITRATE3': None, 'ACHANNELS3': 8,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
}, },
'MKV-SD':{ 'MKV-SD': {
'VEXTENSION':'.mkv','VCODEC':'libx264','VPRESET':None,'VFRAMERATE':None,'VBITRATE':'1200k','VCRF':None,'VLEVEL':None, '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'], 'VRESOLUTION': '720: -1', 'VCODEC_ALLOW': ['libx264', 'h264', 'h.264', 'AVC', 'avc', 'mpeg4', 'msmpeg4', 'MPEG-4'],
'ACODEC':'aac','ACODEC_ALLOW':['libfaac'],'ABITRATE':128000, 'ACHANNELS':2, 'ACODEC': 'aac', 'ACODEC_ALLOW': ['libfaac'], 'ABITRATE': 128000, 'ACHANNELS': 2,
'ACODEC2':'ac3','ACODEC2_ALLOW':['ac3'],'ABITRATE2':None, 'ACHANNELS2':6, 'ACODEC2': 'ac3', 'ACODEC2_ALLOW': ['ac3'], 'ABITRATE2': None, 'ACHANNELS2': 6,
'ACODEC3':None,'ACODEC3_ALLOW':[],'ABITRATE3':None, 'ACHANNELS3':None, 'ACODEC3': None, 'ACODEC3_ALLOW': [], 'ABITRATE3': None, 'ACHANNELS3': None,
'SCODEC':'mov_text' 'SCODEC': 'mov_text'
} }
} }
if DEFAULTS and DEFAULTS in transcode_defaults: if DEFAULTS and DEFAULTS in transcode_defaults:
VEXTENSION = transcode_defaults[DEFAULTS]['VEXTENSION'] VEXTENSION = transcode_defaults[DEFAULTS]['VEXTENSION']
@ -765,17 +765,17 @@ def initialize(section=None):
else: else:
try: try:
SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip() SEVENZIP = subprocess.Popen(['which', '7z'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not SEVENZIP: if not SEVENZIP:
try: try:
SEVENZIP = subprocess.Popen(['which', '7zr'], stdout=subprocess.PIPE).communicate()[0].strip() SEVENZIP = subprocess.Popen(['which', '7zr'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not SEVENZIP: if not SEVENZIP:
try: try:
SEVENZIP = subprocess.Popen(['which', '7za'], stdout=subprocess.PIPE).communicate()[0].strip() SEVENZIP = subprocess.Popen(['which', '7za'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not SEVENZIP: if not SEVENZIP:
SEVENZIP = None SEVENZIP = None
@ -783,7 +783,7 @@ def initialize(section=None):
"Failed to locate 7zip. Transcoding of disk images and extraction of .7z files will not be possible!") "Failed to locate 7zip. Transcoding of disk images and extraction of .7z files will not be possible!")
try: try:
PAR2CMD = subprocess.Popen(['which', 'par2'], stdout=subprocess.PIPE).communicate()[0].strip() PAR2CMD = subprocess.Popen(['which', 'par2'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not PAR2CMD: if not PAR2CMD:
PAR2CMD = None PAR2CMD = None
@ -798,12 +798,12 @@ def initialize(section=None):
else: else:
try: try:
FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip() FFMPEG = subprocess.Popen(['which', 'ffmpeg'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFMPEG: if not FFMPEG:
try: try:
FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip() FFMPEG = subprocess.Popen(['which', 'avconv'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFMPEG: if not FFMPEG:
FFMPEG = None FFMPEG = None
@ -819,12 +819,12 @@ def initialize(section=None):
else: else:
try: try:
FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip() FFPROBE = subprocess.Popen(['which', 'ffprobe'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFPROBE: if not FFPROBE:
try: try:
FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip() FFPROBE = subprocess.Popen(['which', 'avprobe'], stdout=subprocess.PIPE).communicate()[0].strip()
except: except Exception:
pass pass
if not FFPROBE: if not FFPROBE:
FFPROBE = None FFPROBE = None

View file

@ -60,7 +60,7 @@ class Game(object):
logger.postprocess("moving files to library: {0}".format(library), section) logger.postprocess("moving files to library: {0}".format(library), section)
try: try:
shutil.move(dir_name, os.path.join(library, input_name)) shutil.move(dir_name, os.path.join(library, input_name))
except: except Exception:
logger.error("Unable to move {0} to {1}".format(dir_name, os.path.join(library, input_name)), section) logger.error("Unable to move {0} to {1}".format(dir_name, os.path.join(library, input_name)), section)
return [1, "{0}: Failed to post-process - Unable to move files".format(section)] return [1, "{0}: Failed to post-process - Unable to move files".format(section)]
else: else:

View file

@ -26,9 +26,9 @@ class Movie(object):
method = cfg["method"] method = cfg["method"]
else: else:
method = None method = None
#added importMode for Radarr config # added importMode for Radarr config
if section == "Radarr": if section == "Radarr":
import_mode = cfg.get("importMode","Move") import_mode = cfg.get("importMode", "Move")
else: else:
import_mode = None import_mode = None
delete_failed = int(cfg["delete_failed"]) delete_failed = int(cfg["delete_failed"])
@ -75,7 +75,7 @@ class Movie(object):
download_id = release[release_id]['download_info']['id'] download_id = release[release_id]['download_info']['id']
downloader = release[release_id]['download_info']['downloader'] downloader = release[release_id]['download_info']['downloader']
release_status_old = release[release_id]['status'] release_status_old = release[release_id]['status']
except: except Exception:
pass pass
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. 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.
@ -147,7 +147,7 @@ class Movie(object):
logger.debug('Renaming: {0} to: {1}'.format(video, video2)) logger.debug('Renaming: {0} to: {1}'.format(video, video2))
os.rename(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.') logger.info('No CouchPotato or Radarr apikey entered. Processing completed.')
return [0, "{0}: Successfully post-processed {1}".format(section, input_name)] 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) logger.postprocess("Starting {0} scan for {1}".format(method, input_name), section)
if section == "Radarr": 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: if not download_id:
payload.pop("downloadClientId") payload.pop("downloadClientId")
logger.debug("Opening URL: {0} with PARAMS: {1}".format(base_url, payload), section) logger.debug("Opening URL: {0} with PARAMS: {1}".format(base_url, payload), section)
@ -300,7 +300,7 @@ class Movie(object):
logger.postprocess("SUCCESS: Release for {0} has now been marked with a status of [{1}]".format( logger.postprocess("SUCCESS: Release for {0} has now been marked with a status of [{1}]".format(
title, str(release_status_new).upper()), section) title, str(release_status_new).upper()), section)
return [0, "{0}: Successfully post-processed {1}".format(section, input_name)] return [0, "{0}: Successfully post-processed {1}".format(section, input_name)]
except: except Exception:
pass pass
elif scan_id: elif scan_id:
url = "{0}/{1}".format(base_url, scan_id) url = "{0}/{1}".format(base_url, scan_id)
@ -416,7 +416,7 @@ class Movie(object):
id = result[section]['_id'] id = result[section]['_id']
results[id] = result[section] results[id] = result[section]
return results return results
except: except Exception:
pass pass
# Gather release info and proceed with trying to narrow results to one release choice # Gather release info and proceed with trying to narrow results to one release choice
@ -441,7 +441,7 @@ class Movie(object):
id = release['_id'] id = release['_id']
results[id] = release results[id] = release
results[id]['title'] = movie['title'] results[id]['title'] = movie['title']
except: except Exception:
continue continue
# Narrow results by removing old releases by comparing their last_edit field # Narrow results by removing old releases by comparing their last_edit field
@ -451,7 +451,7 @@ class Movie(object):
try: try:
if x2["last_edit"] > x1["last_edit"]: if x2["last_edit"] > x1["last_edit"]:
results.pop(id1) results.pop(id1)
except: except Exception:
continue continue
# Search downloads on clients for a match to try and narrow our results down to 1 # Search downloads on clients for a match to try and narrow our results down to 1
@ -460,7 +460,7 @@ class Movie(object):
try: try:
if not find_download(str(x['download_info']['downloader']).lower(), x['download_info']['id']): if not find_download(str(x['download_info']['downloader']).lower(), x['download_info']['id']):
results.pop(id) results.pop(id)
except: except Exception:
continue continue
return results return results

View file

@ -61,9 +61,9 @@ class Music(object):
core.extract_files(dir_name) core.extract_files(dir_name)
input_name, dir_name = convert_to_ascii(input_name, 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: # 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) # logger.info("Status shown as failed from Downloader, but valid video files found. Setting as successful.", section)
# status = 0 # status = 0
if status == 0 and section == "HeadPhones": if status == 0 and section == "HeadPhones":

View file

@ -44,7 +44,7 @@ class TV(object):
delete_failed = int(cfg.get("delete_failed", 0)) delete_failed = int(cfg.get("delete_failed", 0))
nzb_extraction_by = cfg.get("nzbExtractionBy", "Downloader") nzb_extraction_by = cfg.get("nzbExtractionBy", "Downloader")
process_method = cfg.get("process_method") 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" process_method = "symlink"
remote_path = int(cfg.get("remote_path", 0)) remote_path = int(cfg.get("remote_path", 0))
wait_for = int(cfg.get("wait_for", 2)) wait_for = int(cfg.get("wait_for", 2))
@ -56,8 +56,8 @@ class TV(object):
extract = 0 extract = 0
else: else:
extract = int(cfg.get("extract", 0)) extract = int(cfg.get("extract", 0))
#get importmode, default to "Move" for consistency with legacy # get importmode, default to "Move" for consistency with legacy
import_mode = cfg.get("importMode","Move") 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. 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] 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: if not apikey and username and password:
login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root) login = "{0}{1}:{2}{3}/login".format(protocol, host, port, web_root)
login_params = {'username': username, 'password': password} 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'): if r.status_code == 401 and r.cookies.get('_xsrf'):
login_params['_xsrf'] = r.cookies.get('_xsrf') login_params['_xsrf'] = r.cookies.get('_xsrf')
s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60)) s.post(login, data=login_params, stream=True, verify=False, timeout=(30, 60))

View file

@ -18,7 +18,7 @@ class Section(configobj.Section, object):
if not section.sections: if not section.sections:
try: try:
value = list(ConfigObj.find_key(section, 'enabled'))[0] value = list(ConfigObj.find_key(section, 'enabled'))[0]
except: except Exception:
value = 0 value = 0
if int(value) == 1: if int(value) == 1:
return section return section
@ -28,7 +28,7 @@ class Section(configobj.Section, object):
for subsection in subsections: for subsection in subsections:
try: try:
value = list(ConfigObj.find_key(subsections, 'enabled'))[0] value = list(ConfigObj.find_key(subsections, 'enabled'))[0]
except: except Exception:
value = 0 value = 0
if int(value) != 1: if int(value) != 1:
@ -45,7 +45,7 @@ class Section(configobj.Section, object):
for subsection in to_return: for subsection in to_return:
try: try:
value = list(ConfigObj.find_key(to_return[subsection], key))[0] value = list(ConfigObj.find_key(to_return[subsection], key))[0]
except: except Exception:
value = None value = None
if not value: if not value:
@ -198,7 +198,7 @@ class ConfigObj(configobj.ConfigObj, Section):
if not list(ConfigObj.find_key(CFG_NEW, option)): if not list(ConfigObj.find_key(CFG_NEW, option)):
try: try:
values.pop(option) values.pop(option)
except: except Exception:
pass pass
return values return values
@ -239,7 +239,7 @@ class ConfigObj(configobj.ConfigObj, Section):
process_section(section, subsection) process_section(section, subsection)
# create a backup of our old config # 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() CFG_OLD.write()
# write our new config to autoProcessMedia.cfg # write our new config to autoProcessMedia.cfg
@ -299,9 +299,9 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "CouchPotato" section = "CouchPotato"
env_cat_key = 'NZBPO_CPSCATEGORY' env_cat_key = 'NZBPO_CPSCATEGORY'
env_keys = ['ENABLED', 'APIKEY', 'HOST', 'PORT', 'SSL', 'WEB_ROOT', 'METHOD', 'DELETE_FAILED', 'REMOTE_PATH', 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', 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: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_CPS{index}'.format(index=env_keys[index]) key = 'NZBPO_CPS{index}'.format(index=env_keys[index])
@ -318,9 +318,9 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "SickBeard" section = "SickBeard"
env_cat_key = 'NZBPO_SBCATEGORY' env_cat_key = 'NZBPO_SBCATEGORY'
env_keys = ['ENABLED', 'HOST', 'PORT', 'APIKEY', 'USERNAME', 'PASSWORD', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 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', 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: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_SB{index}'.format(index=env_keys[index]) key = 'NZBPO_SB{index}'.format(index=env_keys[index])
@ -354,9 +354,9 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "Mylar" section = "Mylar"
env_cat_key = 'NZBPO_MYCATEGORY' env_cat_key = 'NZBPO_MYCATEGORY'
env_keys = ['ENABLED', 'HOST', 'PORT', 'USERNAME', 'PASSWORD', 'APIKEY', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 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', cfg_keys = ['enabled', 'host', 'port', 'username', 'password', 'apikey', 'ssl', 'web_root', 'watch_dir',
'remote_path'] 'remote_path']
if env_cat_key in os.environ: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_MY{index}'.format(index=env_keys[index]) key = 'NZBPO_MY{index}'.format(index=env_keys[index])
@ -386,10 +386,10 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "NzbDrone" section = "NzbDrone"
env_cat_key = 'NZBPO_NDCATEGORY' env_cat_key = 'NZBPO_NDCATEGORY'
env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', env_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']
#new cfgKey added for importMode # new cfgKey added for importMode
cfg_keys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 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: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_ND{index}'.format(index=env_keys[index]) key = 'NZBPO_ND{index}'.format(index=env_keys[index])
@ -406,10 +406,10 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "Radarr" section = "Radarr"
env_cat_key = 'NZBPO_RACATEGORY' env_cat_key = 'NZBPO_RACATEGORY'
env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 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'] 'TORRENT_NOLINK', 'NZBEXTRACTIONBY', 'WAIT_FOR', 'DELETE_FAILED', 'REMOTE_PATH', 'OMDBAPIKEY', 'IMPORTMODE']
#new cfgKey added for importMode # new cfgKey added for importMode
cfg_keys = ['enabled', 'host', 'apikey', 'port', 'ssl', 'web_root', 'watch_dir', 'fork', 'delete_failed', 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: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_RA{index}'.format(index=env_keys[index]) key = 'NZBPO_RA{index}'.format(index=env_keys[index])
@ -426,9 +426,9 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "Lidarr" section = "Lidarr"
env_cat_key = 'NZBPO_LICATEGORY' env_cat_key = 'NZBPO_LICATEGORY'
env_keys = ['ENABLED', 'HOST', 'APIKEY', 'PORT', 'SSL', 'WEB_ROOT', 'WATCH_DIR', 'FORK', 'DELETE_FAILED', 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', 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: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_LI{index}'.format(index=env_keys[index]) key = 'NZBPO_LI{index}'.format(index=env_keys[index])
@ -464,25 +464,25 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "Transcoder" section = "Transcoder"
env_keys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTFASTSTART', 'OUTPUTVIDEOPATH', env_keys = ['TRANSCODE', 'DUPLICATE', 'IGNOREEXTENSIONS', 'OUTPUTFASTSTART', 'OUTPUTVIDEOPATH',
'PROCESSOUTPUT', 'AUDIOLANGUAGE', 'ALLAUDIOLANGUAGES', 'SUBLANGUAGES', 'PROCESSOUTPUT', 'AUDIOLANGUAGE', 'ALLAUDIOLANGUAGES', 'SUBLANGUAGES',
'ALLSUBLANGUAGES', 'EMBEDSUBS', 'BURNINSUBTITLE', 'EXTRACTSUBS', 'EXTERNALSUBDIR', 'ALLSUBLANGUAGES', 'EMBEDSUBS', 'BURNINSUBTITLE', 'EXTRACTSUBS', 'EXTERNALSUBDIR',
'OUTPUTDEFAULT', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'VIDEOCODECALLOW', 'OUTPUTDEFAULT', 'OUTPUTVIDEOEXTENSION', 'OUTPUTVIDEOCODEC', 'VIDEOCODECALLOW',
'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC', 'OUTPUTVIDEOPRESET', 'OUTPUTVIDEOFRAMERATE', 'OUTPUTVIDEOBITRATE', 'OUTPUTAUDIOCODEC',
'AUDIOCODECALLOW', 'OUTPUTAUDIOBITRATE', 'OUTPUTQUALITYPERCENT', 'GETSUBS', 'AUDIOCODECALLOW', 'OUTPUTAUDIOBITRATE', 'OUTPUTQUALITYPERCENT', 'GETSUBS',
'OUTPUTAUDIOTRACK2CODEC', 'AUDIOCODEC2ALLOW', 'OUTPUTAUDIOTRACK2BITRATE', 'OUTPUTAUDIOTRACK2CODEC', 'AUDIOCODEC2ALLOW', 'OUTPUTAUDIOTRACK2BITRATE',
'OUTPUTAUDIOOTHERCODEC', 'AUDIOOTHERCODECALLOW', 'OUTPUTAUDIOOTHERBITRATE', 'OUTPUTAUDIOOTHERCODEC', 'AUDIOOTHERCODECALLOW', 'OUTPUTAUDIOOTHERBITRATE',
'OUTPUTSUBTITLECODEC', 'OUTPUTAUDIOCHANNELS', 'OUTPUTAUDIOTRACK2CHANNELS', 'OUTPUTSUBTITLECODEC', 'OUTPUTAUDIOCHANNELS', 'OUTPUTAUDIOTRACK2CHANNELS',
'OUTPUTAUDIOOTHERCHANNELS','OUTPUTVIDEORESOLUTION'] 'OUTPUTAUDIOOTHERCHANNELS', 'OUTPUTVIDEORESOLUTION']
cfg_keys = ['transcode', 'duplicate', 'ignoreExtensions', 'outputFastStart', 'outputVideoPath', cfg_keys = ['transcode', 'duplicate', 'ignoreExtensions', 'outputFastStart', 'outputVideoPath',
'processOutput', 'audioLanguage', 'allAudioLanguages', 'subLanguages', 'processOutput', 'audioLanguage', 'allAudioLanguages', 'subLanguages',
'allSubLanguages', 'embedSubs', 'burnInSubtitle', 'extractSubs', 'externalSubDir', 'allSubLanguages', 'embedSubs', 'burnInSubtitle', 'extractSubs', 'externalSubDir',
'outputDefault', 'outputVideoExtension', 'outputVideoCodec', 'VideoCodecAllow', 'outputDefault', 'outputVideoExtension', 'outputVideoCodec', 'VideoCodecAllow',
'outputVideoPreset', 'outputVideoFramerate', 'outputVideoBitrate', 'outputAudioCodec', 'outputVideoPreset', 'outputVideoFramerate', 'outputVideoBitrate', 'outputAudioCodec',
'AudioCodecAllow', 'outputAudioBitrate', 'outputQualityPercent', 'getSubs', 'AudioCodecAllow', 'outputAudioBitrate', 'outputQualityPercent', 'getSubs',
'outputAudioTrack2Codec', 'AudioCodec2Allow', 'outputAudioTrack2Bitrate', 'outputAudioTrack2Codec', 'AudioCodec2Allow', 'outputAudioTrack2Bitrate',
'outputAudioOtherCodec', 'AudioOtherCodecAllow', 'outputAudioOtherBitrate', 'outputAudioOtherCodec', 'AudioOtherCodecAllow', 'outputAudioOtherBitrate',
'outputSubtitleCodec', 'outputAudioChannels', 'outputAudioTrack2Channels', 'outputSubtitleCodec', 'outputAudioChannels', 'outputAudioTrack2Channels',
'outputAudioOtherChannels', 'outputVideoResolution'] 'outputAudioOtherChannels', 'outputVideoResolution']
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_{index}'.format(index=env_keys[index]) key = 'NZBPO_{index}'.format(index=env_keys[index])
if key in os.environ: if key in os.environ:
@ -503,9 +503,9 @@ class ConfigObj(configobj.ConfigObj, Section):
section = "UserScript" section = "UserScript"
env_cat_key = 'NZBPO_USCATEGORY' env_cat_key = 'NZBPO_USCATEGORY'
env_keys = ['USER_SCRIPT_MEDIAEXTENSIONS', 'USER_SCRIPT_PATH', 'USER_SCRIPT_PARAM', 'USER_SCRIPT_RUNONCE', 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', 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: if env_cat_key in os.environ:
for index in range(len(env_keys)): for index in range(len(env_keys)):
key = 'NZBPO_{index}'.format(index=env_keys[index]) key = 'NZBPO_{index}'.format(index=env_keys[index])

View file

@ -147,7 +147,7 @@ def extract(file_path, output_destination):
break break
else: else:
continue continue
except: except Exception:
core.logger.error("EXTRACTOR: Extraction failed for {file}. " core.logger.error("EXTRACTOR: Extraction failed for {file}. "
"Could not call command {cmd}".format "Could not call command {cmd}".format
(file=file_path, cmd=cmd)) (file=file_path, cmd=cmd))
@ -165,13 +165,13 @@ def extract(file_path, output_destination):
if not os.path.join(dir, subdir) in orig_files: if not os.path.join(dir, subdir) in orig_files:
try: try:
os.chmod(os.path.join(dir, subdir), perms) os.chmod(os.path.join(dir, subdir), perms)
except: except Exception:
pass pass
for file in files: for file in files:
if not os.path.join(dir, file) in orig_files: if not os.path.join(dir, file) in orig_files:
try: try:
shutil.copymode(file_path, os.path.join(dir, file)) shutil.copymode(file_path, os.path.join(dir, file))
except: except Exception:
pass pass
return True return True
else: else:

View file

@ -20,7 +20,7 @@ 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'} 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") f1 = replace[cfg.get("fork", "auto")] if cfg.get("fork", "auto") in replace else cfg.get("fork", "auto")
try: try:
fork = f1, core.FORKS[f1] fork = f1, core.FORKS[f1]
@ -68,7 +68,7 @@ def auto_fork(section, input_category):
login = "{protocol}{host}:{port}{root}/login".format( login = "{protocol}{host}:{port}{root}/login".format(
protocol=protocol, host=host, port=port, root=web_root) protocol=protocol, host=host, port=port, root=web_root)
login_params = {'username': username, 'password': password} 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'): if r.status_code == 401 and r.cookies.get('_xsrf'):
login_params['_xsrf'] = r.cookies.get('_xsrf') login_params['_xsrf'] = r.cookies.get('_xsrf')
s.post(login, data=login_params, stream=True, verify=False) s.post(login, data=login_params, stream=True, verify=False)
@ -82,7 +82,7 @@ def auto_fork(section, input_category):
optional_parameters = [] optional_parameters = []
try: try:
optional_parameters = r.json()['data']['optionalParameters'].keys() optional_parameters = r.json()['data']['optionalParameters'].keys()
except: except Exception:
optional_parameters = r.json()['data']['data']['optionalParameters'].keys() optional_parameters = r.json()['data']['data']['optionalParameters'].keys()
for param in params: for param in params:
if param not in optional_parameters: if param not in optional_parameters:

View file

@ -169,10 +169,13 @@ class DBConnection(object):
def upsert(self, table_name, value_dict, key_dict): def upsert(self, table_name, value_dict, key_dict):
def gen_params(my_dict):
return [
"{key} = ?".format(key=k)
for k in my_dict.keys()
]
changes_before = self.connection.total_changes changes_before = self.connection.total_changes
gen_params = lambda my_dict: ["{key} = ?".format(key=k) for k in my_dict.keys()]
items = list(value_dict.values()) + list(key_dict.values()) items = list(value_dict.values()) + list(key_dict.values())
self.action( self.action(
"UPDATE {table} " "UPDATE {table} "

View file

@ -123,7 +123,7 @@ def rename_script(dirname):
rename_file = "" rename_file = ""
for dir, dirs, files in os.walk(dirname): for dir, dirs, files in os.walk(dirname):
for file in files: for file in files:
if re.search('(rename\S*\.(sh|bat)$)', file, re.IGNORECASE): if re.search(r'(rename\S*\.(sh|bat)$)', file, re.IGNORECASE):
rename_file = os.path.join(dir, file) rename_file = os.path.join(dir, file)
dirname = dir dirname = dir
break break
@ -146,6 +146,7 @@ def rename_script(dirname):
except Exception as error: except Exception as error:
logger.error("Unable to rename file due to: {error}".format(error=error), "EXCEPTION") logger.error("Unable to rename file due to: {error}".format(error=error), "EXCEPTION")
def par2(dirname): def par2(dirname):
newlist = [] newlist = []
sofar = 0 sofar = 0
@ -176,7 +177,7 @@ def par2(dirname):
proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket) proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket)
proc.communicate() proc.communicate()
result = proc.returncode result = proc.returncode
except: except Exception:
logger.error("par2 file processing for {0} has failed".format(parfile), "PAR2") logger.error("par2 file processing for {0} has failed".format(parfile), "PAR2")
if result == 0: if result == 0:
logger.info("par2 file processing succeeded", "PAR2") logger.info("par2 file processing succeeded", "PAR2")

View file

@ -69,7 +69,7 @@ def zip_out(file, img, bitbucket):
cmd = [core.SEVENZIP, '-so', 'e', img, file] cmd = [core.SEVENZIP, '-so', 'e', img, file]
try: try:
procin = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) procin = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket)
except: except Exception:
logger.error("Extracting [{0}] has failed".format(file), 'TRANSCODER') logger.error("Extracting [{0}] has failed".format(file), 'TRANSCODER')
return procin return procin
@ -99,7 +99,7 @@ def get_video_details(videofile, img=None, bitbucket=None):
out, err = proc.communicate() out, err = proc.communicate()
result = proc.returncode result = proc.returncode
video_details = json.loads(out) video_details = json.loads(out)
except: except Exception:
pass pass
if not video_details: if not video_details:
try: try:
@ -113,7 +113,7 @@ def get_video_details(videofile, img=None, bitbucket=None):
out, err = proc.communicate() out, err = proc.communicate()
result = proc.returncode result = proc.returncode
video_details = json.loads(out) video_details = json.loads(out)
except: except Exception:
logger.error("Checking [{0}] has failed".format(file), 'TRANSCODER') logger.error("Checking [{0}] has failed".format(file), 'TRANSCODER')
return video_details, result return video_details, result
@ -132,7 +132,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
elif check: elif check:
name = ('{0}.cd{1}'.format(movie_name, check.groups()[0])) name = ('{0}.cd{1}'.format(movie_name, check.groups()[0]))
elif core.CONCAT and re.match("(.+)[cC][dD][0-9]", name): elif core.CONCAT and re.match("(.+)[cC][dD][0-9]", name):
name = re.sub("([\ \.\-\_\=\:]+[cC][dD][0-9])", "", name) name = re.sub('([ ._=:-]+[cC][dD][0-9])', "", name)
if ext == core.VEXTENSION and new_dir == dir: # we need to change the name to prevent overwriting itself. if ext == core.VEXTENSION and new_dir == dir: # we need to change the name to prevent overwriting itself.
core.VEXTENSION = '-transcoded{ext}'.format(ext=core.VEXTENSION) # adds '-transcoded.ext' core.VEXTENSION = '-transcoded{ext}'.format(ext=core.VEXTENSION) # adds '-transcoded.ext'
else: else:
@ -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"] sub_streams = [item for item in video_details["streams"] if item["codec_type"] == "subtitle"]
if core.VEXTENSION not in ['.mkv', '.mpegts']: if core.VEXTENSION not in ['.mkv', '.mpegts']:
sub_streams = [item for item in video_details["streams"] if sub_streams = [item for item in video_details["streams"] if
item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[
"codec_name"] != "pgssub"] "codec_name"] != "pgssub"]
for video in video_streams: for video in video_streams:
codec = video["codec_name"] codec = video["codec_name"]
@ -262,26 +262,26 @@ def build_commands(file, new_dir, movie_name, bitbucket):
if audio_streams: if audio_streams:
for i, val in reversed(list(enumerate(audio_streams))): for i, val in reversed(list(enumerate(audio_streams))):
try: 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) commentary.append(val)
del audio_streams[i] del audio_streams[i]
except: except Exception:
continue continue
try: try:
audio1 = [item for item in audio_streams if item["tags"]["language"] == core.ALANGUAGE] audio1 = [item for item in audio_streams if item["tags"]["language"] == core.ALANGUAGE]
except: # no language tags. Assume only 1 language. except Exception: # no language tags. Assume only 1 language.
audio1 = audio_streams audio1 = audio_streams
try: try:
audio2 = [item for item in audio1 if item["codec_name"] in core.ACODEC_ALLOW] audio2 = [item for item in audio1 if item["codec_name"] in core.ACODEC_ALLOW]
except: except Exception:
audio2 = [] audio2 = []
try: try:
audio3 = [item for item in audio_streams if item["tags"]["language"] != core.ALANGUAGE] audio3 = [item for item in audio_streams if item["tags"]["language"] != core.ALANGUAGE]
except: except Exception:
audio3 = [] audio3 = []
try: try:
audio4 = [item for item in audio3 if item["codec_name"] in core.ACODEC_ALLOW] audio4 = [item for item in audio3 if item["codec_name"] in core.ACODEC_ALLOW]
except: except Exception:
audio4 = [] audio4 = []
if audio2: # right (or only) language and codec... if audio2: # right (or only) language and codec...
@ -328,11 +328,11 @@ def build_commands(file, new_dir, movie_name, bitbucket):
used_audio += 1 used_audio += 1
try: try:
audio5 = [item for item in audio1 if item["codec_name"] in core.ACODEC2_ALLOW] audio5 = [item for item in audio1 if item["codec_name"] in core.ACODEC2_ALLOW]
except: except Exception:
audio5 = [] audio5 = []
try: try:
audio6 = [item for item in audio3 if item["codec_name"] in core.ACODEC2_ALLOW] audio6 = [item for item in audio3 if item["codec_name"] in core.ACODEC2_ALLOW]
except: except Exception:
audio6 = [] audio6 = []
if audio5: # right language and codec. if audio5: # right language and codec.
map_cmd.extend(['-map', '0:{index}'.format(index=audio5[0]["index"])]) map_cmd.extend(['-map', '0:{index}'.format(index=audio5[0]["index"])])
@ -380,13 +380,13 @@ def build_commands(file, new_dir, movie_name, bitbucket):
if audio_cmd2[1] in ['aac', 'dts']: if audio_cmd2[1] in ['aac', 'dts']:
audio_cmd2[2:2] = ['-strict', '-2'] 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:] del map_cmd[-2:]
else: else:
audio_cmd.extend(audio_cmd2) audio_cmd.extend(audio_cmd2)
if core.AINCLUDE and core.ACODEC3: 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: for audio in audio_streams:
if audio["index"] in a_mapped: if audio["index"] in a_mapped:
continue continue
@ -425,7 +425,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
for lan in core.SLANGUAGES: for lan in core.SLANGUAGES:
try: try:
subs1 = [item for item in sub_streams if item["tags"]["language"] == lan] subs1 = [item for item in sub_streams if item["tags"]["language"] == lan]
except: except Exception:
subs1 = [] subs1 = []
if core.BURN and not subs1 and not burnt and os.path.isfile(file): if core.BURN and not subs1 and not burnt and os.path.isfile(file):
for subfile in get_subs(file): for subfile in get_subs(file):
@ -443,7 +443,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
burnt = 1 burnt = 1
if not core.ALLOWSUBS: if not core.ALLOWSUBS:
break 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 continue
map_cmd.extend(['-map', '0:{index}'.format(index=sub["index"])]) map_cmd.extend(['-map', '0:{index}'.format(index=sub["index"])])
s_mapped.extend([sub["index"]]) s_mapped.extend([sub["index"]])
@ -454,7 +454,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
break break
if sub["index"] in s_mapped: if sub["index"] in s_mapped:
continue 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 continue
map_cmd.extend(['-map', '0:{index}'.format(index=sub["index"])]) map_cmd.extend(['-map', '0:{index}'.format(index=sub["index"])])
s_mapped.extend([sub["index"]]) s_mapped.extend([sub["index"]])
@ -478,7 +478,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
continue continue
if core.SCODEC == "mov_text": if core.SCODEC == "mov_text":
subcode = [stream["codec_name"] for stream in sub_details["streams"]] 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 continue
command.extend(['-i', subfile]) command.extend(['-i', subfile])
lan = os.path.splitext(os.path.splitext(subfile)[0])[1][1:].split('-')[0] lan = os.path.splitext(os.path.splitext(subfile)[0])[1][1:].split('-')[0]
@ -489,7 +489,7 @@ def build_commands(file, new_dir, movie_name, bitbucket):
metlan = Language(lan) metlan = Language(lan)
if len(lan) == 2: if len(lan) == 2:
metlan = Language.fromalpha2(lan) metlan = Language.fromalpha2(lan)
except: except Exception:
pass pass
if metlan: if metlan:
meta_cmd.extend(['-metadata:s:s:{x}'.format(x=len(s_mapped) + n), meta_cmd.extend(['-metadata:s:s:{x}'.format(x=len(s_mapped) + n),
@ -542,12 +542,12 @@ def extract_subs(file, newfile_path, bitbucket):
try: try:
sub_streams = [item for item in video_details["streams"] if sub_streams = [item for item in video_details["streams"] if
item["codec_type"] == "subtitle" and item["tags"]["language"] in core.SLANGUAGES and item[ item["codec_type"] == "subtitle" and item["tags"]["language"] in core.SLANGUAGES and item[
"codec_name"] != "hdmv_pgs_subtitle" and item["codec_name"] != "pgssub"] "codec_name"] != "hdmv_pgs_subtitle" and item["codec_name"] != "pgssub"]
except: except Exception:
sub_streams = [item for item in video_details["streams"] if sub_streams = [item for item in video_details["streams"] if
item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[ item["codec_type"] == "subtitle" and item["codec_name"] != "hdmv_pgs_subtitle" and item[
"codec_name"] != "pgssub"] "codec_name"] != "pgssub"]
num = len(sub_streams) num = len(sub_streams)
for n in range(num): for n in range(num):
sub = sub_streams[n] sub = sub_streams[n]
@ -575,13 +575,13 @@ def extract_subs(file, newfile_path, bitbucket):
proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket) proc = subprocess.Popen(command, stdout=bitbucket, stderr=bitbucket)
proc.communicate() proc.communicate()
result = proc.returncode result = proc.returncode
except: except Exception:
logger.error("Extracting subtitle has failed") logger.error("Extracting subtitle has failed")
if result == 0: if result == 0:
try: try:
shutil.copymode(file, output_file) shutil.copymode(file, output_file)
except: except Exception:
pass pass
logger.info("Extracting {0} subtitle from {1} has succeeded".format(lan, file)) logger.info("Extracting {0} subtitle from {1} has succeeded".format(lan, file))
else: else:
@ -605,7 +605,7 @@ def process_list(it, new_dir, bitbucket):
if not vts_path: if not vts_path:
try: try:
vts_path = re.match("(.+VIDEO_TS)", item).groups()[0] vts_path = re.match("(.+VIDEO_TS)", item).groups()[0]
except: except Exception:
vts_path = os.path.split(item)[0] vts_path = os.path.split(item)[0]
rem_list.append(item) rem_list.append(item)
elif re.match(".+VIDEO_TS.", item) or re.match(".+VTS_[0-9][0-9]_[0-9].", item): elif re.match(".+VIDEO_TS.", item) or re.match(".+VTS_[0-9][0-9]_[0-9].", item):
@ -649,8 +649,8 @@ def rip_iso(item, new_dir, bitbucket):
print_cmd(cmd) print_cmd(cmd)
proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket) proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=bitbucket)
out, err = proc.communicate() 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 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(".+VIDEO_TS[\\\/]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", line)] out.splitlines() if re.match(r".+VIDEO_TS[/\\]VTS_[0-9][0-9]_[0-9].[Vv][Oo][Bb]", line)]
combined = [] combined = []
for n in range(99): for n in range(99):
concat = [] concat = []
@ -677,7 +677,7 @@ def rip_iso(item, new_dir, bitbucket):
if not new_files: if not new_files:
logger.error("No VIDEO_TS folder found in image file {0}".format(item), "TRANSCODER") logger.error("No VIDEO_TS folder found in image file {0}".format(item), "TRANSCODER")
new_files = [failure_dir] new_files = [failure_dir]
except: except Exception:
logger.error("Failed to extract from image file {0}".format(item), "TRANSCODER") logger.error("Failed to extract from image file {0}".format(item), "TRANSCODER")
new_files = [failure_dir] new_files = [failure_dir]
return new_files return new_files
@ -788,7 +788,7 @@ def transcode_directory(dir_name):
procin.stdout.close() procin.stdout.close()
proc.communicate() proc.communicate()
result = proc.returncode result = proc.returncode
except: except Exception:
logger.error("Transcoding of video {0} has failed".format(newfile_path)) logger.error("Transcoding of video {0} has failed".format(newfile_path))
if core.SUBSDIR and result == 0 and isinstance(file, string_types): if core.SUBSDIR and result == 0 and isinstance(file, string_types):
@ -803,13 +803,13 @@ def transcode_directory(dir_name):
if result == 0: if result == 0:
try: try:
shutil.copymode(file, newfile_path) shutil.copymode(file, newfile_path)
except: except Exception:
pass pass
logger.info("Transcoding of video to {0} succeeded".format(newfile_path)) logger.info("Transcoding of video to {0} succeeded".format(newfile_path))
if os.path.isfile(newfile_path) and (file in new_list or not core.DUPLICATE): if os.path.isfile(newfile_path) and (file in new_list or not core.DUPLICATE):
try: try:
os.unlink(file) os.unlink(file)
except: except Exception:
pass pass
else: else:
logger.error("Transcoding of video to {0} failed with result {1}".format(newfile_path, result)) logger.error("Transcoding of video to {0} failed with result {1}".format(newfile_path, result))
@ -819,7 +819,7 @@ def transcode_directory(dir_name):
for file in rem_list: for file in rem_list:
try: try:
os.unlink(file) os.unlink(file)
except: except Exception:
pass pass
if not os.listdir(text_type(new_dir)): # this is an empty directory and we didn't transcode into it. if not os.listdir(text_type(new_dir)): # this is an empty directory and we didn't transcode into it.
os.rmdir(new_dir) os.rmdir(new_dir)

View file

@ -15,7 +15,7 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
core.USER_SCRIPT_MEDIAEXTENSIONS = settings["user_script_mediaExtensions"].lower() core.USER_SCRIPT_MEDIAEXTENSIONS = settings["user_script_mediaExtensions"].lower()
if isinstance(core.USER_SCRIPT_MEDIAEXTENSIONS, str): if isinstance(core.USER_SCRIPT_MEDIAEXTENSIONS, str):
core.USER_SCRIPT_MEDIAEXTENSIONS = core.USER_SCRIPT_MEDIAEXTENSIONS.split(',') core.USER_SCRIPT_MEDIAEXTENSIONS = core.USER_SCRIPT_MEDIAEXTENSIONS.split(',')
except: except Exception:
core.USER_SCRIPT_MEDIAEXTENSIONS = [] core.USER_SCRIPT_MEDIAEXTENSIONS = []
core.USER_SCRIPT = settings.get("user_script_path") core.USER_SCRIPT = settings.get("user_script_path")
@ -26,13 +26,13 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
core.USER_SCRIPT_PARAM = settings["user_script_param"] core.USER_SCRIPT_PARAM = settings["user_script_param"]
if isinstance(core.USER_SCRIPT_PARAM, str): if isinstance(core.USER_SCRIPT_PARAM, str):
core.USER_SCRIPT_PARAM = core.USER_SCRIPT_PARAM.split(',') core.USER_SCRIPT_PARAM = core.USER_SCRIPT_PARAM.split(',')
except: except Exception:
core.USER_SCRIPT_PARAM = [] core.USER_SCRIPT_PARAM = []
try: try:
core.USER_SCRIPT_SUCCESSCODES = settings["user_script_successCodes"] core.USER_SCRIPT_SUCCESSCODES = settings["user_script_successCodes"]
if isinstance(core.USER_SCRIPT_SUCCESSCODES, str): if isinstance(core.USER_SCRIPT_SUCCESSCODES, str):
core.USER_SCRIPT_SUCCESSCODES = core.USER_SCRIPT_SUCCESSCODES.split(',') core.USER_SCRIPT_SUCCESSCODES = core.USER_SCRIPT_SUCCESSCODES.split(',')
except: except Exception:
core.USER_SCRIPT_SUCCESSCODES = 0 core.USER_SCRIPT_SUCCESSCODES = 0
core.USER_SCRIPT_CLEAN = int(settings.get("user_script_clean", 1)) core.USER_SCRIPT_CLEAN = int(settings.get("user_script_clean", 1))
@ -95,7 +95,7 @@ def external_script(output_destination, torrent_name, torrent_label, settings):
"If the UserScript completed successfully you should add {0} to the user_script_successCodes".format( "If the UserScript completed successfully you should add {0} to the user_script_successCodes".format(
res), "USERSCRIPT") res), "USERSCRIPT")
result = int(1) result = int(1)
except: except Exception:
logger.error("UserScript {0} has failed".format(command[0]), "USERSCRIPT") logger.error("UserScript {0} has failed".format(command[0]), "USERSCRIPT")
result = int(1) result = int(1)
final_result += result final_result += result

View file

@ -45,10 +45,15 @@ requests.packages.urllib3.disable_warnings()
# Monkey Patch shutil.copyfileobj() to adjust the buffer length to 512KB rather than 4KB # Monkey Patch shutil.copyfileobj() to adjust the buffer length to 512KB rather than 4KB
shutil.copyfileobjOrig = shutil.copyfileobj shutil.copyfileobjOrig = shutil.copyfileobj
def copyfileobj_fast(fsrc, fdst, length=512 * 1024): def copyfileobj_fast(fsrc, fdst, length=512 * 1024):
shutil.copyfileobjOrig(fsrc, fdst, length=length) shutil.copyfileobjOrig(fsrc, fdst, length=length)
shutil.copyfileobj = copyfileobj_fast shutil.copyfileobj = copyfileobj_fast
def report_nzb(failure_link, client_agent): def report_nzb(failure_link, client_agent):
# Contact indexer site # Contact indexer site
logger.info("Sending failure notification to indexer site") logger.info("Sending failure notification to indexer site")
@ -85,7 +90,7 @@ def sanitize_name(name):
name = name.strip(' .') name = name.strip(' .')
try: try:
name = name.encode(core.SYS_ENCODING) name = name.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
return name return name
@ -123,11 +128,11 @@ def category_search(input_directory, input_name, input_category, root, categorie
try: try:
input_name = input_name.encode(core.SYS_ENCODING) input_name = input_name.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
try: try:
input_directory = input_directory.encode(core.SYS_ENCODING) input_directory = input_directory.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
if input_directory is None: # =Nothing to process here. if input_directory is None: # =Nothing to process here.
@ -228,7 +233,7 @@ def is_min_size(input_name, min_size):
if file_ext in core.AUDIOCONTAINER: if file_ext in core.AUDIOCONTAINER:
try: try:
input_size = get_dir_size(os.path.dirname(input_name)) input_size = get_dir_size(os.path.dirname(input_name))
except: except Exception:
logger.error("Failed to get file size for {0}".format(input_name), 'MINSIZE') logger.error("Failed to get file size for {0}".format(input_name), 'MINSIZE')
return True return True
@ -239,7 +244,7 @@ def is_min_size(input_name, min_size):
def is_sample(input_name): def is_sample(input_name):
# Ignore 'sample' in files # Ignore 'sample' in files
if re.search('(^|[\W_])sample\d*[\W_]', input_name.lower()): if re.search('(^|[\\W_])sample\\d*[\\W_]', input_name.lower()):
return True return True
@ -330,7 +335,7 @@ def flatten(output_destination):
try: try:
shutil.move(outputFile, target) shutil.move(outputFile, target)
except: except Exception:
logger.error("Could not flatten {0}".format(outputFile), 'FLATTEN') logger.error("Could not flatten {0}".format(outputFile), 'FLATTEN')
remove_empty_folders(output_destination) # Cleanup empty directories remove_empty_folders(output_destination) # Cleanup empty directories
@ -367,7 +372,7 @@ def remove_read_only(filename):
(name=filename)) (name=filename))
try: try:
os.chmod(filename, stat.S_IWRITE) os.chmod(filename, stat.S_IWRITE)
except: except Exception:
logger.warning('Cannot change permissions of {file}'.format(file=filename), logger.WARNING) logger.warning('Cannot change permissions of {file}'.format(file=filename), logger.WARNING)
@ -398,7 +403,7 @@ def test_connection(host, port):
try: try:
socket.create_connection((host, port)) socket.create_connection((host, port))
return "Up" return "Up"
except: except Exception:
return "Down" return "Down"
@ -510,19 +515,19 @@ def parse_rtorrent(args):
input_directory = os.path.normpath(args[1]) input_directory = os.path.normpath(args[1])
try: try:
input_name = args[2] input_name = args[2]
except: except Exception:
input_name = '' input_name = ''
try: try:
input_category = args[3] input_category = args[3]
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = args[4] input_hash = args[4]
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = args[4] input_id = args[4]
except: except Exception:
input_id = '' input_id = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -534,15 +539,15 @@ def parse_utorrent(args):
input_name = args[2] input_name = args[2]
try: try:
input_category = args[3] input_category = args[3]
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = args[4] input_hash = args[4]
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = args[4] input_id = args[4]
except: except Exception:
input_id = '' input_id = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -556,7 +561,7 @@ def parse_deluge(args):
input_id = args[1] input_id = args[1]
try: try:
input_category = core.TORRENT_CLASS.core.get_torrent_status(input_id, ['label']).get()['label'] input_category = core.TORRENT_CLASS.core.get_torrent_status(input_id, ['label']).get()['label']
except: except Exception:
input_category = '' input_category = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
@ -575,65 +580,67 @@ def parse_vuze(args):
# vuze usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D%N%L%I%K%F" # vuze usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D%N%L%I%K%F"
try: try:
input = args[1].split(',') input = args[1].split(',')
except: except Exception:
input = [] input = []
try: try:
input_directory = os.path.normpath(input[0]) input_directory = os.path.normpath(input[0])
except: except Exception:
input_directory = '' input_directory = ''
try: try:
input_name = input[1] input_name = input[1]
except: except Exception:
input_name = '' input_name = ''
try: try:
input_category = input[2] input_category = input[2]
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = input[3] input_hash = input[3]
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = input[3] input_id = input[3]
except: except Exception:
input_id = '' input_id = ''
try: try:
if input[4] == 'single': if input[4] == 'single':
input_name = input[5] input_name = input[5]
except: except Exception:
pass pass
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
def parse_qbittorrent(args): def parse_qbittorrent(args):
# qbittorrent usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D|%N|%L|%I" # qbittorrent usage: C:\full\path\to\nzbToMedia\TorrentToMedia.py "%D|%N|%L|%I"
try: try:
input = args[1].split('|') input = args[1].split('|')
except: except Exception:
input = [] input = []
try: try:
input_directory = os.path.normpath(input[0].replace('"','')) input_directory = os.path.normpath(input[0].replace('"', ''))
except: except Exception:
input_directory = '' input_directory = ''
try: try:
input_name = input[1].replace('"','') input_name = input[1].replace('"', '')
except: except Exception:
input_name = '' input_name = ''
try: try:
input_category = input[2].replace('"','') input_category = input[2].replace('"', '')
except: except Exception:
input_category = '' input_category = ''
try: try:
input_hash = input[3].replace('"','') input_hash = input[3].replace('"', '')
except: except Exception:
input_hash = '' input_hash = ''
try: try:
input_id = input[3].replace('"','') input_id = input[3].replace('"', '')
except: except Exception:
input_id = '' input_id = ''
return input_directory, input_name, input_category, input_hash, input_id return input_directory, input_name, input_category, input_hash, input_id
def parse_args(client_agent, args): def parse_args(client_agent, args):
clients = { clients = {
'other': parse_other, 'other': parse_other,
@ -647,7 +654,7 @@ def parse_args(client_agent, args):
try: try:
return clients[client_agent](args) return clients[client_agent](args)
except: except Exception:
return None, None, None, None, None return None, None, None, None, None
@ -699,7 +706,7 @@ def get_dirs(section, subsection, link='hard'):
try: try:
new_path = new_path.encode(core.SYS_ENCODING) new_path = new_path.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
# Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe). # Just fail-safe incase we already have afile with this clean-name (was actually a bug from earlier code, but let's be safe).
@ -714,7 +721,7 @@ def get_dirs(section, subsection, link='hard'):
newfile = os.path.join(new_path, sanitize_name(os.path.split(mediafile)[1])) newfile = os.path.join(new_path, sanitize_name(os.path.split(mediafile)[1]))
try: try:
newfile = newfile.encode(core.SYS_ENCODING) newfile = newfile.encode(core.SYS_ENCODING)
except: except Exception:
pass pass
# link file to its new path # link file to its new path
@ -780,7 +787,7 @@ def remove_dir(dir_name):
logger.info("Deleting {0}".format(dir_name)) logger.info("Deleting {0}".format(dir_name))
try: try:
shutil.rmtree(text_type(dir_name), onerror=onerror) shutil.rmtree(text_type(dir_name), onerror=onerror)
except: except Exception:
logger.error("Unable to delete folder {0}".format(dir_name)) logger.error("Unable to delete folder {0}".format(dir_name))
@ -797,7 +804,7 @@ def clean_dir(path, section, subsection):
delete_ignored = int(cfg.get('delete_ignored', 0)) delete_ignored = int(cfg.get('delete_ignored', 0))
try: try:
num_files = len(list_media_files(path, min_size=min_size, delete_ignored=delete_ignored)) num_files = len(list_media_files(path, min_size=min_size, delete_ignored=delete_ignored))
except: except Exception:
num_files = 'unknown' num_files = 'unknown'
if num_files > 0: if num_files > 0:
logger.info( logger.info(
@ -808,7 +815,7 @@ def clean_dir(path, section, subsection):
logger.info("Directory {0} has been processed, removing ...".format(path), 'CLEANDIRS') logger.info("Directory {0} has been processed, removing ...".format(path), 'CLEANDIRS')
try: try:
shutil.rmtree(path, onerror=onerror) shutil.rmtree(path, onerror=onerror)
except: except Exception:
logger.error("Unable to delete directory {0}".format(path)) logger.error("Unable to delete directory {0}".format(path))
@ -820,7 +827,7 @@ def create_torrent_class(client_agent):
try: try:
logger.debug("Connecting to {0}: {1}".format(client_agent, core.UTORRENTWEBUI)) logger.debug("Connecting to {0}: {1}".format(client_agent, core.UTORRENTWEBUI))
tc = UTorrentClient(core.UTORRENTWEBUI, core.UTORRENTUSR, core.UTORRENTPWD) tc = UTorrentClient(core.UTORRENTWEBUI, core.UTORRENTUSR, core.UTORRENTPWD)
except: except Exception:
logger.error("Failed to connect to uTorrent") logger.error("Failed to connect to uTorrent")
if client_agent == 'transmission': if client_agent == 'transmission':
@ -830,7 +837,7 @@ def create_torrent_class(client_agent):
tc = TransmissionClient(core.TRANSMISSIONHOST, core.TRANSMISSIONPORT, tc = TransmissionClient(core.TRANSMISSIONHOST, core.TRANSMISSIONPORT,
core.TRANSMISSIONUSR, core.TRANSMISSIONUSR,
core.TRANSMISSIONPWD) core.TRANSMISSIONPWD)
except: except Exception:
logger.error("Failed to connect to Transmission") logger.error("Failed to connect to Transmission")
if client_agent == 'deluge': if client_agent == 'deluge':
@ -839,7 +846,7 @@ def create_torrent_class(client_agent):
tc = DelugeClient() tc = DelugeClient()
tc.connect(host=core.DELUGEHOST, port=core.DELUGEPORT, username=core.DELUGEUSR, tc.connect(host=core.DELUGEHOST, port=core.DELUGEPORT, username=core.DELUGEUSR,
password=core.DELUGEPWD) password=core.DELUGEPWD)
except: except Exception:
logger.error("Failed to connect to Deluge") logger.error("Failed to connect to Deluge")
if client_agent == 'qbittorrent': if client_agent == 'qbittorrent':
@ -847,7 +854,7 @@ def create_torrent_class(client_agent):
logger.debug("Connecting to {0}: http://{1}:{2}".format(client_agent, core.QBITTORRENTHOST, core.QBITTORRENTPORT)) 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 = qBittorrentClient("http://{0}:{1}/".format(core.QBITTORRENTHOST, core.QBITTORRENTPORT))
tc.login(core.QBITTORRENTUSR, core.QBITTORRENTPWD) tc.login(core.QBITTORRENTUSR, core.QBITTORRENTPWD)
except: except Exception:
logger.error("Failed to connect to qBittorrent") logger.error("Failed to connect to qBittorrent")
return tc return tc
@ -865,7 +872,7 @@ def pause_torrent(client_agent, input_hash, input_id, input_name):
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "": if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "":
core.TORRENT_CLASS.pause(input_hash) core.TORRENT_CLASS.pause(input_hash)
time.sleep(5) time.sleep(5)
except: except Exception:
logger.warning("Failed to stop torrent {0} in {1}".format(input_name, client_agent)) logger.warning("Failed to stop torrent {0} in {1}".format(input_name, client_agent))
@ -883,7 +890,7 @@ def resume_torrent(client_agent, input_hash, input_id, input_name):
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "": if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "":
core.TORRENT_CLASS.resume(input_hash) core.TORRENT_CLASS.resume(input_hash)
time.sleep(5) time.sleep(5)
except: except Exception:
logger.warning("Failed to start torrent {0} in {1}".format(input_name, client_agent)) logger.warning("Failed to start torrent {0} in {1}".format(input_name, client_agent))
@ -901,7 +908,7 @@ def remove_torrent(client_agent, input_hash, input_id, input_name):
if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "": if client_agent == 'qbittorrent' and core.TORRENT_CLASS != "":
core.TORRENT_CLASS.delete_permanently(input_hash) core.TORRENT_CLASS.delete_permanently(input_hash)
time.sleep(5) time.sleep(5)
except: except Exception:
logger.warning("Failed to delete torrent {0} in {1}".format(input_name, client_agent)) logger.warning("Failed to delete torrent {0} in {1}".format(input_name, client_agent))
else: else:
resume_torrent(client_agent, input_hash, input_id, input_name) resume_torrent(client_agent, input_hash, input_id, input_name)
@ -974,7 +981,7 @@ def get_nzoid(input_name):
result = r.json() result = r.json()
clean_name = os.path.splitext(os.path.split(input_name)[1])[0] clean_name = os.path.splitext(os.path.split(input_name)[1])[0]
slots.extend([(slot['nzo_id'], slot['filename']) for slot in result['queue']['slots']]) slots.extend([(slot['nzo_id'], slot['filename']) for slot in result['queue']['slots']])
except: except Exception:
logger.warning("Data from SABnzbd queue could not be parsed") logger.warning("Data from SABnzbd queue could not be parsed")
params['mode'] = "history" params['mode'] = "history"
try: try:
@ -986,7 +993,7 @@ def get_nzoid(input_name):
result = r.json() result = r.json()
clean_name = os.path.splitext(os.path.split(input_name)[1])[0] clean_name = os.path.splitext(os.path.split(input_name)[1])[0]
slots.extend([(slot['nzo_id'], slot['name']) for slot in result['history']['slots']]) slots.extend([(slot['nzo_id'], slot['name']) for slot in result['history']['slots']])
except: except Exception:
logger.warning("Data from SABnzbd history could not be parsed") logger.warning("Data from SABnzbd history could not be parsed")
try: try:
for nzo_id, name in slots: for nzo_id, name in slots:
@ -994,7 +1001,7 @@ def get_nzoid(input_name):
nzoid = nzo_id nzoid = nzo_id
logger.debug("Found nzoid: {0}".format(nzoid)) logger.debug("Found nzoid: {0}".format(nzoid))
break break
except: except Exception:
logger.warning("Data from SABnzbd could not be parsed") logger.warning("Data from SABnzbd could not be parsed")
return nzoid return nzoid
@ -1007,13 +1014,13 @@ def clean_file_name(filename):
space, but handles decimal numbers in string, for example: space, but handles decimal numbers in string, for example:
""" """
filename = re.sub("(\D)\.(?!\s)(\D)", "\\1 \\2", filename) filename = re.sub(r"(\D)\.(?!\s)(\D)", r"\1 \2", filename)
filename = re.sub("(\d)\.(\d{4})", "\\1 \\2", filename) # if it ends in a year then don't keep the dot filename = re.sub(r"(\d)\.(\d{4})", r"\1 \2", filename) # if it ends in a year then don't keep the dot
filename = re.sub("(\D)\.(?!\s)", "\\1 ", filename) filename = re.sub(r"(\D)\.(?!\s)", r"\1 ", filename)
filename = re.sub("\.(?!\s)(\D)", " \\1", filename) filename = re.sub(r"\.(?!\s)(\D)", r" \1", filename)
filename = filename.replace("_", " ") filename = filename.replace("_", " ")
filename = re.sub("-$", "", filename) filename = re.sub("-$", "", filename)
filename = re.sub("^\[.*\]", "", filename) filename = re.sub(r"^\[.*]", "", filename)
return filename.strip() return filename.strip()
@ -1032,7 +1039,7 @@ def is_media_file(mediafile, media=True, audio=True, meta=True, archives=True, o
# ignore MAC OS's "resource fork" files # ignore MAC OS's "resource fork" files
if file_name.startswith('._'): if file_name.startswith('._'):
return False return False
except: except Exception:
pass pass
if (media and file_ext.lower() in core.MEDIACONTAINER) \ if (media and file_ext.lower() in core.MEDIACONTAINER) \
or (audio and file_ext.lower() in core.AUDIOCONTAINER) \ or (audio and file_ext.lower() in core.AUDIOCONTAINER) \
@ -1057,7 +1064,7 @@ def list_media_files(path, min_size=0, delete_ignored=0, media=True, audio=True,
os.unlink(path) os.unlink(path)
logger.debug('Ignored file {0} has been removed ...'.format logger.debug('Ignored file {0} has been removed ...'.format
(cur_file)) (cur_file))
except: except Exception:
pass pass
else: else:
files.append(path) files.append(path)
@ -1079,7 +1086,7 @@ def list_media_files(path, min_size=0, delete_ignored=0, media=True, audio=True,
os.unlink(full_cur_file) os.unlink(full_cur_file)
logger.debug('Ignored file {0} has been removed ...'.format logger.debug('Ignored file {0} has been removed ...'.format
(cur_file)) (cur_file))
except: except Exception:
pass pass
continue continue
@ -1095,14 +1102,14 @@ def find_imdbid(dir_name, input_name, omdb_api_key):
# find imdbid in dirName # find imdbid in dirName
logger.info('Searching folder and file names for imdbID ...') logger.info('Searching folder and file names for imdbID ...')
m = re.search('(tt\d{7})', dir_name + input_name) m = re.search(r'(tt\d{7})', dir_name + input_name)
if m: if m:
imdbid = m.group(1) imdbid = m.group(1)
logger.info("Found imdbID [{0}]".format(imdbid)) logger.info("Found imdbID [{0}]".format(imdbid))
return imdbid return imdbid
if os.path.isdir(dir_name): if os.path.isdir(dir_name):
for file in os.listdir(text_type(dir_name)): for file in os.listdir(text_type(dir_name)):
m = re.search('(tt\d{7})', file) m = re.search(r'(tt\d{7})', file)
if m: if m:
imdbid = m.group(1) imdbid = m.group(1)
logger.info("Found imdbID [{0}] via file name".format(imdbid)) logger.info("Found imdbID [{0}] via file name".format(imdbid))
@ -1119,7 +1126,7 @@ def find_imdbid(dir_name, input_name, omdb_api_key):
logger.info('Searching IMDB for imdbID ...') logger.info('Searching IMDB for imdbID ...')
try: try:
guess = guessit.guessit(input_name) guess = guessit.guessit(input_name)
except: except Exception:
guess = None guess = None
if guess: if guess:
# Movie Title # Movie Title
@ -1149,12 +1156,12 @@ def find_imdbid(dir_name, input_name, omdb_api_key):
try: try:
results = r.json() results = r.json()
except: except Exception:
logger.error("No json data returned from omdbapi.com") logger.error("No json data returned from omdbapi.com")
try: try:
imdbid = results['imdbID'] imdbid = results['imdbID']
except: except Exception:
logger.error("No imdbID returned from omdbapi.com") logger.error("No imdbID returned from omdbapi.com")
if imdbid: if imdbid:
@ -1207,14 +1214,14 @@ def import_subs(filename):
return return
try: try:
subliminal.region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'}) subliminal.region.configure('dogpile.cache.dbm', arguments={'filename': 'cachefile.dbm'})
except: except Exception:
pass pass
languages = set() languages = set()
for item in core.SLANGUAGES: for item in core.SLANGUAGES:
try: try:
languages.add(Language(item)) languages.add(Language(item))
except: except Exception:
pass pass
if not languages: if not languages:
return return
@ -1309,6 +1316,7 @@ def get_download_info(input_name, status):
return sql_results return sql_results
class WindowsProcess(object): class WindowsProcess(object):
def __init__(self): def __init__(self):
self.mutex = None self.mutex = None
@ -1353,7 +1361,7 @@ class PosixProcess(object):
# Make sure it is not a "stale" pidFile # Make sure it is not a "stale" pidFile
try: try:
pid = int(open(self.pidpath, 'r').read().strip()) pid = int(open(self.pidpath, 'r').read().strip())
except: except Exception:
pid = None pid = None
# Check list of running pids, if not running it is stale so overwrite # Check list of running pids, if not running it is stale so overwrite
if isinstance(pid, int): if isinstance(pid, int):
@ -1373,7 +1381,7 @@ class PosixProcess(object):
fp = open(self.pidpath, 'w') fp = open(self.pidpath, 'w')
fp.write(str(os.getpid())) fp.write(str(os.getpid()))
fp.close() fp.close()
except: except Exception:
pass pass
return self.lasterror return self.lasterror
@ -1385,6 +1393,7 @@ class PosixProcess(object):
if os.path.isfile(self.pidpath): if os.path.isfile(self.pidpath):
os.unlink(self.pidpath) os.unlink(self.pidpath)
if os.name == 'nt': if os.name == 'nt':
RunningProcess = WindowsProcess RunningProcess = WindowsProcess
else: else:

View file

@ -16,7 +16,6 @@ from six.moves.urllib.request import urlretrieve
import cleanup import cleanup
import core import core
from core import github_api as github, logger from core import github_api as github, logger
import libs.util
class CheckVersion(object): class CheckVersion(object):
@ -285,7 +284,7 @@ class GitUpdateManager(UpdateManager):
self._num_commits_behind = int(output.count("<")) self._num_commits_behind = int(output.count("<"))
self._num_commits_ahead = int(output.count(">")) self._num_commits_ahead = int(output.count(">"))
except: except Exception:
logger.log(u"git didn't return numbers for behind and ahead, not using it", logger.DEBUG) logger.log(u"git didn't return numbers for behind and ahead, not using it", logger.DEBUG)
return return

View file

@ -26,18 +26,18 @@ class DelugeClient(object):
def _get_local_auth(self): def _get_local_auth(self):
username = password = "" username = password = ""
if platform.system() in ('Windows', 'Microsoft'): if platform.system() in ('Windows', 'Microsoft'):
appDataPath = os.environ.get("APPDATA") app_data_path = os.environ.get("APPDATA")
if not appDataPath: if not app_data_path:
from six.moves import winreg from six.moves import winreg
hkey = winreg.OpenKey( hkey = winreg.OpenKey(
winreg.HKEY_CURRENT_USER, winreg.HKEY_CURRENT_USER,
"Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders", "Software\\Microsoft\\Windows\\CurrentVersion\\Explorer\\Shell Folders",
) )
appDataReg = winreg.QueryValueEx(hkey, "AppData") app_data_reg = winreg.QueryValueEx(hkey, "AppData")
appDataPath = appDataReg[0] app_data_path = app_data_reg[0]
winreg.CloseKey(hkey) winreg.CloseKey(hkey)
auth_file = os.path.join(appDataPath, "deluge", "auth") auth_file = os.path.join(app_data_path, "deluge", "auth")
else: else:
from xdg.BaseDirectory import save_config_path from xdg.BaseDirectory import save_config_path
try: try:
@ -79,11 +79,13 @@ class DelugeClient(object):
return func return func
def _introspect(self): def _introspect(self):
def splitter(value):
return value.split(".")
self.modules = [] self.modules = []
methods = self.remote_call("daemon.get_method_list").get() methods = self.remote_call("daemon.get_method_list").get()
methodmap = defaultdict(dict) methodmap = defaultdict(dict)
splitter = lambda v: v.split(".")
for module, method in imap(splitter, methods): for module, method in imap(splitter, methods):
methodmap[module][method] = self._create_module_method(module, method) methodmap[module][method] = self._create_module_method(module, method)

View file

@ -19,6 +19,7 @@ try:
except ImportError: except ImportError:
import simplejson as json import simplejson as json
class UTorrentClient(object): class UTorrentClient(object):
def __init__(self, base_url, username, password): def __init__(self, base_url, username, password):
@ -27,7 +28,7 @@ class UTorrentClient(object):
self.password = password self.password = password
self.opener = self._make_opener('uTorrent', base_url, username, password) self.opener = self._make_opener('uTorrent', base_url, username, password)
self.token = self._get_token() self.token = self._get_token()
#TODO refresh token, when necessary # TODO refresh token, when necessary
def _make_opener(self, realm, base_url, username, password): def _make_opener(self, realm, base_url, username, password):
'''uTorrent API need HTTP Basic Auth and cookie support for token verify.''' '''uTorrent API need HTTP Basic Auth and cookie support for token verify.'''
@ -60,25 +61,25 @@ class UTorrentClient(object):
return self._action(params) return self._action(params)
def start(self, *hashes): def start(self, *hashes):
params = [('action', 'start'),] params = [('action', 'start'), ]
for hash in hashes: for hash in hashes:
params.append(('hash', hash)) params.append(('hash', hash))
return self._action(params) return self._action(params)
def stop(self, *hashes): def stop(self, *hashes):
params = [('action', 'stop'),] params = [('action', 'stop'), ]
for hash in hashes: for hash in hashes:
params.append(('hash', hash)) params.append(('hash', hash))
return self._action(params) return self._action(params)
def pause(self, *hashes): def pause(self, *hashes):
params = [('action', 'pause'),] params = [('action', 'pause'), ]
for hash in hashes: for hash in hashes:
params.append(('hash', hash)) params.append(('hash', hash))
return self._action(params) return self._action(params)
def forcestart(self, *hashes): def forcestart(self, *hashes):
params = [('action', 'forcestart'),] params = [('action', 'forcestart'), ]
for hash in hashes: for hash in hashes:
params.append(('hash', hash)) params.append(('hash', hash))
return self._action(params) return self._action(params)
@ -94,8 +95,8 @@ class UTorrentClient(object):
def setprops(self, hash, **kvpairs): def setprops(self, hash, **kvpairs):
params = [('action', 'setprops'), ('hash', hash)] params = [('action', 'setprops'), ('hash', hash)]
for k, v in iteritems(kvpairs): for k, v in iteritems(kvpairs):
params.append( ("s", k) ) params.append(("s", k))
params.append( ("v", v) ) params.append(("v", v))
return self._action(params) return self._action(params)
@ -111,7 +112,7 @@ class UTorrentClient(object):
form = MultiPartForm() form = MultiPartForm()
if filepath is not None: if filepath is not None:
file_handler = open(filepath,'rb') file_handler = open(filepath, 'rb')
else: else:
file_handler = StringIO(bytes) file_handler = StringIO(bytes)
@ -124,19 +125,19 @@ class UTorrentClient(object):
self._action(params) self._action(params)
def remove(self, *hashes): def remove(self, *hashes):
params = [('action', 'remove'),] params = [('action', 'remove'), ]
for hash in hashes: for hash in hashes:
params.append(('hash', hash)) params.append(('hash', hash))
return self._action(params) return self._action(params)
def removedata(self, *hashes): def removedata(self, *hashes):
params = [('action', 'removedata'),] params = [('action', 'removedata'), ]
for hash in hashes: for hash in hashes:
params.append(('hash', hash)) params.append(('hash', hash))
return self._action(params) return self._action(params)
def _action(self, params, body=None, content_type=None): 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) url = self.base_url + '?token=' + self.token + '&' + urlencode(params)
request = Request(url) request = Request(url)

View file

@ -23,9 +23,9 @@ class MultiPartForm(object):
self.form_fields.append((name, value)) self.form_fields.append((name, value))
return return
def add_file(self, fieldname, filename, fileHandle, mimetype=None): def add_file(self, fieldname, filename, file_handle, mimetype=None):
"""Add a file to be uploaded.""" """Add a file to be uploaded."""
body = fileHandle.read() body = file_handle.read()
if mimetype is None: if mimetype is None:
mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream' mimetype = mimetypes.guess_type(filename)[0] or 'application/octet-stream'
self.files.append((fieldname, filename, mimetype, body)) self.files.append((fieldname, filename, mimetype, body))
@ -42,29 +42,28 @@ class MultiPartForm(object):
# Add the form fields # Add the form fields
parts.extend( parts.extend(
[ part_boundary, [part_boundary,
'Content-Disposition: form-data; name="%s"' % name, 'Content-Disposition: form-data; name="%s"' % name,
'', '',
value, value,
] ]
for name, value in self.form_fields for name, value in self.form_fields
) )
# Add the files to upload # Add the files to upload
parts.extend( parts.extend(
[ part_boundary, [part_boundary,
'Content-Disposition: file; name="%s"; filename="%s"' % \ 'Content-Disposition: file; name="%s"; filename="%s"' % (field_name, filename),
(field_name, filename), 'Content-Type: %s' % content_type,
'Content-Type: %s' % content_type, '',
'', body,
body, ]
]
for field_name, filename, content_type, body in self.files for field_name, filename, content_type, body in self.files
) )
# Flatten the list and add closing boundary marker, # Flatten the list and add closing boundary marker,
# then return CR+LF separated data # then return CR+LF separated data
flattened = list(itertools.chain(*parts)) flattened = list(itertools.chain(*parts))
flattened.append('--' + self.boundary + '--') flattened.append('--' + self.boundary + '--')
flattened.append('') flattened.append('')
return '\r\n'.join(flattened) return '\r\n'.join(flattened)

View file

@ -1,259 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Check Media for corruption (0, 1).
#
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## CouchPotato
# CouchPotato script category.
#
# category that gets called for post-processing with CouchPotatoServer.
#cpsCategory=movie
# CouchPotato api key.
#cpsapikey=
# CouchPotato host.
#
# The ipaddress for your CouchPotato server. e.g For the Same system use localhost or 127.0.0.1
#cpshost=localhost
# CouchPotato port.
#cpsport=5050
# CouchPotato uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#cpsssl=0
# CouchPotato URL_Base
#
# set this if using a reverse proxy.
#cpsweb_root=
# CouchPotato watch directory.
#
# set this to where your CouchPotato completed downloads are.
#cpswatch_dir=
# CouchPotato OMDB API Key.
#
# api key for www.omdbapi.com (used as alternative to imdb to assist with movie identification).
#cpsomdbapikey=
# CouchPotato Postprocess Method (renamer, manage).
#
# use "renamer" for CPS renamer (default) or "manage" to call a manage update.
#cpsmethod=renamer
# CouchPotato Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#cpsdelete_failed=0
# CouchPotato wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the movie has changed status.
#cpswait_for=2
# CouchPotatoServer and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#cpsremote_path=0
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Transcoder
# getSubs (0, 1).
#
# set to 1 to download subtitles.
#getSubs=0
# subLanguages.
#
# subLanguages. create a list of languages in the order you want them in your subtitles.
#subLanguages=eng,spa,fra
# Transcode (0, 1).
#
# set to 1 to transcode, otherwise set to 0.
#transcode=0
# create a duplicate, or replace the original (0, 1).
#
# set to 1 to cretae a new file or 0 to replace the original
#duplicate=1
# ignore extensions.
#
# list of extensions that won't be transcoded.
#ignoreExtensions=.avi,.mkv
# outputFastStart (0,1).
#
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
#outputFastStart=0
# outputVideoPath.
#
# outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable.
#outputVideoPath=
# processOutput (0,1).
#
# processOutput. 1 will send the outputVideoPath to SickBeard/CouchPotato. 0 will send original files.
#processOutput=0
# audioLanguage.
#
# audioLanguage. set the 3 letter language code you want as your primary audio track.
#audioLanguage=eng
# allAudioLanguages (0,1).
#
# allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available.
#allAudioLanguages=0
# allSubLanguages (0,1).
#
# allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above.
#allSubLanguages=0
# embedSubs (0,1).
#
# embedSubs. 1 will embded external sub/srt subs into your video if this is supported.
#embedSubs=1
# burnInSubtitle (0,1).
#
# burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs)
#burnInSubtitle=0
# extractSubs (0,1).
#
# extractSubs. 1 will extract subs from the video file and save these as external srt files.
#extractSubs=0
# externalSubDir.
#
# externalSubDir. set the directory where subs should be saved (if not the same directory as the video)
#externalSubDir=
# outputDefault (None, iPad, iPad-1080p, iPad-720p, Apple-TV2, iPod, iPhone, PS3, xbox, Roku-1080p, Roku-720p, Roku-480p, mkv, mp4-scene-release, MKV-SD).
#
# outputDefault. Loads default configs for the selected device. The remaining options below are ignored.
# If you want to use your own profile, set None and set the remaining options below.
#outputDefault=None
# hwAccel (0,1).
#
# hwAccel. 1 will set ffmpeg to enable hardware acceleration (this requires a recent ffmpeg).
#hwAccel=0
# ffmpeg output settings.
#outputVideoExtension=.mp4
#outputVideoCodec=libx264
#VideoCodecAllow=
#outputVideoResolution=720:-1
#outputVideoPreset=medium
#outputVideoFramerate=24
#outputVideoBitrate=800k
#outputAudioCodec=ac3
#AudioCodecAllow=
#outputAudioChannels=6
#outputAudioBitrate=640k
#outputQualityPercent=
#outputAudioTrack2Codec=libfaac
#AudioCodec2Allow=
#outputAudioTrack2Channels=2
#outputAudioTrack2Bitrate=160k
#outputAudioOtherCodec=libmp3lame
#AudioOtherCodecAllow=
#outputAudioOtherChannels=2
#outputAudioOtherBitrate=128k
#outputSubtitleCodec=
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,104 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
#
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
## Gamez
# Gamez script category.
#
# category that gets called for post-processing with Gamez.
#gzCategory=games
# Gamez api key.
#gzapikey=
# Gamez host.
#
# The ipaddress for your Gamez server. e.g For the Same system use localhost or 127.0.0.1
#gzhost=localhost
# Gamez port.
#gzport=8085
# Gamez uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#gzssl=0
# Gamez library
#
# move downloaded games here.
#gzlibrary
# Gamez web_root
#
# set this if using a reverse proxy.
#gzweb_root=
# Gamez watch directory.
#
# set this to where your Gamez completed downloads are.
#gzwatch_dir=
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,126 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to HeadPhones.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## HeadPhones
# HeadPhones script category.
#
# category that gets called for post-processing with HeadHones.
#hpCategory=music
# HeadPhones api key.
#hpapikey=
# HeadPhones host.
#
# The ipaddress for your HeadPhones server. e.g For the Same system use localhost or 127.0.0.1
#hphost=localhost
# HeadPhones port.
#hpport=8181
# HeadPhones uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#hpssl=0
# HeadPhones web_root
#
# set this if using a reverse proxy.
#hpweb_root=
# HeadPhones Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#hpdelete_failed=0
# HeadPhones watch directory.
#
# set this to where your HeadPhones completed downloads are.
#hpwatch_dir=
# HeadPhones wait_for
#
# Set the number of minutes to wait after initiating HeadPhones post-processing to check if the album status has changed.
#hpwait_for=2
# HeadPhones and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#hpremote_path=0
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,241 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to Lidarr.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Check Media for corruption (0, 1).
#
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## Lidarr
# Lidarr script category.
#
# category that gets called for post-processing with NzbDrone.
#liCategory=music2
# Lidarr host.
#
# The ipaddress for your Lidarr server. e.g For the Same system use localhost or 127.0.0.1
#lihost=localhost
# Lidarr port.
#liport=8686
# Lidarr API key.
#liapikey=
# Lidarr uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#lissl=0
# Lidarr web_root
#
# set this if using a reverse proxy.
#liweb_root=
# Lidarr wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the episode has changed status.
#liwait_for=6
# Lidarr Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#lidelete_failed=0
# Lidarr and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#liremote_path=0
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Transcoder
# getSubs (0, 1).
#
# set to 1 to download subtitles.
#getSubs = 0
# subLanguages.
#
# subLanguages. create a list of languages in the order you want them in your subtitles.
#subLanguages = eng,spa,fra
# Transcode (0, 1).
#
# set to 1 to transcode, otherwise set to 0.
#transcode=0
# create a duplicate, or replace the original (0, 1).
#
# set to 1 to cretae a new file or 0 to replace the original
#duplicate=1
# ignore extensions.
#
# list of extensions that won't be transcoded.
#ignoreExtensions=.avi,.mkv
# outputFastStart (0,1).
#
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
#outputFastStart = 0
# outputVideoPath.
#
# outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable.
#outputVideoPath =
# processOutput (0,1).
#
# processOutput. 1 will send the outputVideoPath to SickBeard/CouchPotato. 0 will send original files.
#processOutput = 0
# audioLanguage.
#
# audioLanguage. set the 3 letter language code you want as your primary audio track.
#audioLanguage = eng
# allAudioLanguages (0,1).
#
# allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available.
#allAudioLanguages = 0
# allSubLanguages (0,1).
#
# allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above.
#allSubLanguages = 0
# embedSubs (0,1).
#
# embedSubs. 1 will embded external sub/srt subs into your video if this is supported.
#embedSubs = 1
# burnInSubtitle (0,1).
#
# burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs)
#burnInSubtitle = 0
# extractSubs (0,1).
#
# extractSubs. 1 will extract subs from the video file and save these as external srt files.
#extractSubs = 0
# externalSubDir.
#
# externalSubDir. set the directory where subs should be saved (if not the same directory as the video)
#externalSubDir =
# outputDefault (None, iPad, iPad-1080p, iPad-720p, Apple-TV2, iPod, iPhone, PS3, xbox, Roku-1080p, Roku-720p, Roku-480p, mkv, mp4-scene-release, MKV-SD).
#
# outputDefault. Loads default configs for the selected device. The remaining options below are ignored.
# If you want to use your own profile, set None and set the remaining options below.
#outputDefault = None
# hwAccel (0,1).
#
# hwAccel. 1 will set ffmpeg to enable hardware acceleration (this requires a recent ffmpeg).
#hwAccel=0
# ffmpeg output settings.
#outputVideoExtension=.mp4
#outputVideoCodec=libx264
#VideoCodecAllow =
#outputVideoResolution=720:-1
#outputVideoPreset=medium
#outputVideoFramerate=24
#outputVideoBitrate=800k
#outputAudioCodec=libmp3lame
#AudioCodecAllow =
#outputAudioBitrate=128k
#outputQualityPercent = 0
#outputAudioTrack2Codec = libfaac
#AudioCodec2Allow =
#outputAudioTrack2Bitrate = 128k
#outputAudioOtherCodec = libmp3lame
#AudioOtherCodecAllow =
#outputAudioOtherBitrate = 128k
#outputSubtitleCodec =
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,625 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to CouchPotato, SickBeard, NzbDrone, Mylar, Gamez, HeadPhones.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Check Media for corruption (0, 1).
#
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## CouchPotato
# CouchPotato script category.
#
# category that gets called for post-processing with CouchPotatoServer.
#cpsCategory=movie
# CouchPotato api key.
#cpsapikey=
# CouchPotato host.
#
# The ipaddress for your CouchPotato server. e.g For the Same system use localhost or 127.0.0.1
#cpshost=localhost
# CouchPotato port.
#cpsport=5050
# CouchPotato uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#cpsssl=0
# CouchPotato URL_Base
#
# set this if using a reverse proxy.
#cpsweb_root=
# CouchPotato Postprocess Method (renamer, manage).
#
# use "renamer" for CPS renamer (default) or "manage" to call a manage update.
#cpsmethod=renamer
# CouchPotato OMDB API Key.
#
# api key for www.omdbapi.com (used as alternative to imdb to assist with movie identification).
#cpsomdbapikey=
# CouchPotato Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#cpsdelete_failed=0
# CouchPotato wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the movie has changed status.
#cpswait_for=2
# Couchpotato and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#cpsremote_path=0
## Radarr
# Radarr script category.
#
# category that gets called for post-processing with NzbDrone.
#raCategory=movies2
# Radarr host.
#
# The ipaddress for your Radarr server. e.g For the Same system use localhost or 127.0.0.1
#rahost=localhost
# Radarr port.
#raport=7878
# Radarr API key.
#raapikey=
# Radarr uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#rassl=0
# Radarr web_root
#
# set this if using a reverse proxy.
#raweb_root=
# Radarr wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the episode has changed status.
#rawait_for=6
# Radarr OMDB API Key.
#
# api key for www.omdbapi.com (used as alternative to imdb to assist with movie identification).
#raomdbapikey=
# Radarr import mode (Move, Copy).
#
# set to define import behaviour Move or Copy
#raimportmode=Copy
# Radarr Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#radelete_failed=0
# Radarr and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#raremote_path=0
## SickBeard
# SickBeard script category.
#
# category that gets called for post-processing with SickBeard.
#sbCategory=tv
# SickBeard host.
#
# The ipaddress for your SickBeard/SickRage server. e.g For the Same system use localhost or 127.0.0.1
#sbhost=localhost
# SickBeard port.
#sbport=8081
# SickBeard api key. For SickChill, Medusa, SiCKRAGE only.
#sbapikey=
# SickBeard username.
#sbusername=
# SickBeard password.
#sbpassword=
# SickBeard uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#sbssl=0
# SickBeard web_root
#
# set this if using a reverse proxy.
#sbweb_root=
# SickBeard watch directory.
#
# set this if SickBeard and nzbGet are on different systems.
#sbwatch_dir=
# SickBeard fork.
#
# set to default or auto to auto-detect the custom fork type.
#sbfork=auto
# SickBeard Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#sbdelete_failed=0
# SickBeard Ignore associated subtitle check (0, 1).
#
# set to 1 to ignore subtitles check, or 0 to don't check.
#sbignore_subs=0
# SickBeard process method.
#
# set this to move, copy, hardlink, symlink as appropriate if you want to over-ride SB defaults. Leave blank to use SB default.
#sbprocess_method=
# SickBeard and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#sbremote_path=0
## NzbDrone
# NzbDrone script category.
#
# category that gets called for post-processing with NzbDrone.
#ndCategory=tv2
# NzbDrone host.
#
# The ipaddress for your NzbDrone/Sonarr server. e.g For the Same system use localhost or 127.0.0.1
#ndhost=localhost
# NzbDrone port.
#ndport=8989
# NzbDrone API key.
#ndapikey=
# NzbDrone uses SSL (0, 1).
#
# Set to 1 if using SSL, else set to 0.
#ndssl=0
# NzbDrone web root.
#
# set this if using a reverse proxy.
#ndweb_root=
# NzbDrone wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the episode has changed status.
#ndwait_for=6
# NzbDrone import mode (Move, Copy).
#
# set to define import behaviour Move or Copy
#ndimportmode=Copy
# NzbDrone Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#nddelete_failed=0
# NzbDrone and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#ndremote_path=0
## HeadPhones
# HeadPhones script category.
#
# category that gets called for post-processing with HeadHones.
#hpCategory=music
# HeadPhones api key.
#hpapikey=
# HeadPhones host.
#
# The ipaddress for your HeadPhones server. e.g For the Same system use localhost or 127.0.0.1
#hphost=localhost
# HeadPhones port.
#hpport=8181
# HeadPhones uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#hpssl=0
# HeadPhones web_root
#
# set this if using a reverse proxy.
#hpweb_root=
# HeadPhones Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#hpdelete_failed=0
# HeadPhones and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#hpremote_path=0
## Lidarr
# Lidarr script category.
#
# category that gets called for post-processing with NzbDrone.
#liCategory=music2
# Lidarr host.
#
# The ipaddress for your Lidarr server. e.g For the Same system use localhost or 127.0.0.1
#lihost=localhost
# Lidarr port.
#liport=8686
# Lidarr API key.
#liapikey=
# Lidarr uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#lissl=0
# Lidarr web_root
#
# set this if using a reverse proxy.
#liweb_root=
# Lidarr wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the episode has changed status.
#liwait_for=6
# Lidarr Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#lidelete_failed=0
# Lidarr and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#liremote_path=0
## Mylar
# Mylar script category.
#
# category that gets called for post-processing with Mylar.
#myCategory=comics
# Mylar host.
#
# The ipaddress for your Mylar server. e.g For the Same system use localhost or 127.0.0.1
#myhost=localhost
# Mylar port.
#myport=8090
# Mylar api key.
#myapikey=
# Mylar uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#myssl=0
# Mylar web_root
#
# set this if using a reverse proxy.
#myweb_root=
# Mylar wait_for
#
# Set the number of minutes to wait after calling the force process, to check the issue has changed status.
#myswait_for=1
# Mylar and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#myremote_path=0
## Gamez
# Gamez script category.
#
# category that gets called for post-processing with Gamez.
#gzCategory=games
# Gamez api key.
#gzapikey=
# Gamez host.
#
# The ipaddress for your Gamez server. e.g For the Same system use localhost or 127.0.0.1
#gzhost=localhost
# Gamez port.
#gzport=8085
# Gamez uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#gzssl=0
# Gamez library
#
# move downloaded games here.
#gzlibrary
# Gamez web_root
#
# set this if using a reverse proxy.
#gzweb_root=
# Gamez and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#gzremote_path=0
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Transcoder
# getSubs (0, 1).
#
# set to 1 to download subtitles.
#getSubs=0
# subLanguages.
#
# subLanguages. create a list of languages in the order you want them in your subtitles.
#subLanguages=eng,spa,fra
# Transcode (0, 1).
#
# set to 1 to transcode, otherwise set to 0.
#transcode=0
# create a duplicate, or replace the original (0, 1).
#
# set to 1 to cretae a new file or 0 to replace the original
#duplicate=1
# ignore extensions.
#
# list of extensions that won't be transcoded.
#ignoreExtensions=.avi,.mkv
# outputFastStart (0,1).
#
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
#outputFastStart=0
# outputVideoPath.
#
# outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable.
#outputVideoPath=
# processOutput (0,1).
#
# processOutput. 1 will send the outputVideoPath to SickBeard/CouchPotato. 0 will send original files.
#processOutput=0
# audioLanguage.
#
# audioLanguage. set the 3 letter language code you want as your primary audio track.
#audioLanguage=eng
# allAudioLanguages (0,1).
#
# allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available.
#allAudioLanguages=0
# allSubLanguages (0,1).
#
# allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above.
#allSubLanguages=0
# embedSubs (0,1).
#
# embedSubs. 1 will embded external sub/srt subs into your video if this is supported.
#embedSubs=1
# burnInSubtitle (0,1).
#
# burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs)
#burnInSubtitle=0
# extractSubs (0,1).
#
# extractSubs. 1 will extract subs from the video file and save these as external srt files.
#extractSubs=0
# externalSubDir.
#
# externalSubDir. set the directory where subs should be saved (if not the same directory as the video)
#externalSubDir=
# outputDefault (None, iPad, iPad-1080p, iPad-720p, Apple-TV2, iPod, iPhone, PS3, xbox, Roku-1080p, Roku-720p, Roku-480p, mkv, mp4-scene-release).
#
# outputDefault. Loads default configs for the selected device. The remaining options below are ignored.
# If you want to use your own profile, set None and set the remaining options below.
#outputDefault=None
# hwAccel (0,1).
#
# hwAccel. 1 will set ffmpeg to enable hardware acceleration (this requires a recent ffmpeg).
#hwAccel=0
# ffmpeg output settings.
#outputVideoExtension=.mp4
#outputVideoCodec=libx264
#VideoCodecAllow=
#outputVideoResolution=720:-1
#outputVideoPreset=medium
#outputVideoFramerate=24
#outputVideoBitrate=800k
#outputAudioCodec=ac3
#AudioCodecAllow=
#outputAudioChannels=6
#outputAudioBitrate=640k
#outputQualityPercent=
#outputAudioTrack2Codec=libfaac
#AudioCodec2Allow=
#outputAudioTrack2Channels=2
#outputAudioTrack2Bitrate=160k
#outputAudioOtherCodec=libmp3lame
#AudioOtherCodecAllow=
#outputAudioOtherChannels=2
#outputAudioOtherBitrate=128k
#outputSubtitleCodec=
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
## UserScript
# User Script category.
#
# category that gets called for post-processing with user script (accepts "UNCAT", "ALL", or a defined category).
#usCategory=mine
# User Script Remote Path (0,1).
#
# Script calls commands on another system.
#usremote_path=0
# User Script extensions.
#
# What extension do you want to process? Specify all the extension, or use "ALL" to process all files.
#user_script_mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg
# User Script Path
#
# Specify the path to your custom script.
#user_script_path=/nzbToMedia/userscripts/script.sh
# User Script arguments.
#
# Specify the argument(s) passed to script, comma separated in order.
# for example FP,FN,DN, TN, TL for file path (absolute file name with path), file name, absolute directory name (with path), Torrent Name, Torrent Label/Category.
# So the result is /media/test/script/script.sh FP FN DN TN TL. Add other arguments as needed eg -f, -r
#user_script_param=FN
# User Script Run Once (0,1).
#
# Set user_script_runOnce = 0 to run for each file, or 1 to only run once (presumably on teh entire directory).
#user_script_runOnce=0
# User Script Success Codes.
#
# Specify the successcodes returned by the user script as a comma separated list. Linux default is 0
#user_script_successCodes=0
# User Script Clean After (0,1).
#
# Clean after? Note that delay function is used to prevent possible mistake :) Delay is intended as seconds
#user_script_clean=1
# User Script Delay.
#
# Delay in seconds after processing.
#usdelay=120
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
from __future__ import print_function from __future__ import print_function
@ -664,17 +44,18 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
try: try:
encoded, input_directory1 = char_replace(input_directory) encoded, input_directory1 = char_replace(input_directory)
encoded, input_name1 = char_replace(input_name) encoded, input_name1 = char_replace(input_name)
except: except Exception:
pass pass
control_value_dict = {"input_directory": text_type(input_directory1)} control_value_dict = {"input_directory": text_type(input_directory1)}
new_value_dict = {"input_name": text_type(input_name1), new_value_dict = {
"input_hash": text_type(download_id), "input_name": text_type(input_name1),
"input_id": text_type(download_id), "input_hash": text_type(download_id),
"client_agent": text_type(client_agent), "input_id": text_type(download_id),
"status": 0, "client_agent": text_type(client_agent),
"last_update": datetime.date.today().toordinal() "status": 0,
} "last_update": datetime.date.today().toordinal(),
}
my_db.upsert("downloads", new_value_dict, control_value_dict) my_db.upsert("downloads", new_value_dict, control_value_dict)
# auto-detect section # auto-detect section
@ -715,7 +96,7 @@ def process(input_directory, input_name=None, status=0, client_agent='manual', d
logger.error('Remote Path is enabled for {0}:{1} but no Network mount points are defined. Please check your autoProcessMedia.cfg, exiting!'.format( 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)) section_name, input_category))
return [-1, ""] return [-1, ""]
except: except Exception:
logger.error('Remote Path {0} is not valid for {1}:{2} Please set this to either 0 to disable or 1 to enable!'.format( logger.error('Remote Path {0} is not valid for {1}:{2} Please set this to either 0 to disable or 1 to enable!'.format(
core.get("remote_path"), section_name, input_category)) core.get("remote_path"), section_name, input_category))

View file

@ -1,117 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to Mylar.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
#
### OPTIONS
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
## Mylar
# Mylar script category.
#
# category that gets called for post-processing with Mylar.
#myCategory=comics
# Mylar host.
#
# The ipaddress for your Mylar server. e.g For the Same system use localhost or 127.0.0.1
#myhost=localhost
# Mylar port.
#myport=8090
# Mylar api key.
#myapikey=
# Mylar uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#myssl=0
# Mylar web_root
#
# set this if using a reverse proxy.
#myweb_root=
# Mylar wait_for
#
# Set the number of minutes to wait after calling the force process, to check the issue has changed status.
#myswait_for=1
# Mylar watch directory.
#
# set this to where your Mylar completed downloads are.
#mywatch_dir=
# Mylar and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#myremote_path=0
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,246 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to NzbDrone/Sonarr.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Check Media for corruption (0, 1).
#
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## NzbDrone
# NzbDrone script category.
#
# category that gets called for post-processing with NzbDrone.
#ndCategory=tv2
# NzbDrone host.
#
# The ipaddress for your NzbDrone/Sonarr server. e.g For the Same system use localhost or 127.0.0.1
#ndhost=localhost
# NzbDrone port.
#ndport=8989
# NzbDrone API key.
#ndapikey=
# NzbDrone uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#ndssl=0
# NzbDrone web_root
#
# set this if using a reverse proxy.
#ndweb_root=
# NzbDrone wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the episode has changed status.
#ndwait_for=6
# NzbDrone import mode (Move, Copy).
#
# set to define import behaviour Move or Copy
#ndimportmode=Copy
# NzbDrone Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#nddelete_failed=0
# NzbDrone and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#ndremote_path=0
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Transcoder
# getSubs (0, 1).
#
# set to 1 to download subtitles.
#getSubs = 0
# subLanguages.
#
# subLanguages. create a list of languages in the order you want them in your subtitles.
#subLanguages = eng,spa,fra
# Transcode (0, 1).
#
# set to 1 to transcode, otherwise set to 0.
#transcode=0
# create a duplicate, or replace the original (0, 1).
#
# set to 1 to cretae a new file or 0 to replace the original
#duplicate=1
# ignore extensions.
#
# list of extensions that won't be transcoded.
#ignoreExtensions=.avi,.mkv
# outputFastStart (0,1).
#
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
#outputFastStart = 0
# outputVideoPath.
#
# outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable.
#outputVideoPath =
# processOutput (0,1).
#
# processOutput. 1 will send the outputVideoPath to SickBeard/CouchPotato. 0 will send original files.
#processOutput = 0
# audioLanguage.
#
# audioLanguage. set the 3 letter language code you want as your primary audio track.
#audioLanguage = eng
# allAudioLanguages (0,1).
#
# allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available.
#allAudioLanguages = 0
# allSubLanguages (0,1).
#
# allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above.
#allSubLanguages = 0
# embedSubs (0,1).
#
# embedSubs. 1 will embded external sub/srt subs into your video if this is supported.
#embedSubs = 1
# burnInSubtitle (0,1).
#
# burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs)
#burnInSubtitle = 0
# extractSubs (0,1).
#
# extractSubs. 1 will extract subs from the video file and save these as external srt files.
#extractSubs = 0
# externalSubDir.
#
# externalSubDir. set the directory where subs should be saved (if not the same directory as the video)
#externalSubDir =
# outputDefault (None, iPad, iPad-1080p, iPad-720p, Apple-TV2, iPod, iPhone, PS3, xbox, Roku-1080p, Roku-720p, Roku-480p, mkv, mp4-scene-release, MKV-SD).
#
# outputDefault. Loads default configs for the selected device. The remaining options below are ignored.
# If you want to use your own profile, set None and set the remaining options below.
#outputDefault = None
# hwAccel (0,1).
#
# hwAccel. 1 will set ffmpeg to enable hardware acceleration (this requires a recent ffmpeg).
#hwAccel=0
# ffmpeg output settings.
#outputVideoExtension=.mp4
#outputVideoCodec=libx264
#VideoCodecAllow =
#outputVideoResolution=720:-1
#outputVideoPreset=medium
#outputVideoFramerate=24
#outputVideoBitrate=800k
#outputAudioCodec=libmp3lame
#AudioCodecAllow =
#outputAudioBitrate=128k
#outputQualityPercent = 0
#outputAudioTrack2Codec = libfaac
#AudioCodec2Allow =
#outputAudioTrack2Bitrate = 128k
#outputAudioOtherCodec = libmp3lame
#AudioOtherCodecAllow =
#outputAudioOtherBitrate = 128k
#outputSubtitleCodec =
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,251 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to Radarr.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Check Media for corruption (0, 1).
#
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## Radarr
# Radarr script category.
#
# category that gets called for post-processing with NzbDrone.
#raCategory=movies2
# Radarr host.
#
# The ipaddress for your Radarr server. e.g For the Same system use localhost or 127.0.0.1
#rahost=localhost
# Radarr port.
#raport=7878
# Radarr API key.
#raapikey=
# Radarr uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#rassl=0
# Radarr web_root
#
# set this if using a reverse proxy.
#raweb_root=
# Radarr OMDB API Key.
#
# api key for www.omdbapi.com (used as alternative to imdb to assist with movie identification).
#raomdbapikey=
# Radarr wait_for
#
# Set the number of minutes to wait after calling the renamer, to check the episode has changed status.
#rawait_for=6
# Radarr import mode (Move, Copy).
#
# set to define import behaviour Move or Copy
#raimportmode=Copy
# Radarr Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#radelete_failed=0
# Radarr and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#raremote_path=0
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Transcoder
# getSubs (0, 1).
#
# set to 1 to download subtitles.
#getSubs = 0
# subLanguages.
#
# subLanguages. create a list of languages in the order you want them in your subtitles.
#subLanguages = eng,spa,fra
# Transcode (0, 1).
#
# set to 1 to transcode, otherwise set to 0.
#transcode=0
# create a duplicate, or replace the original (0, 1).
#
# set to 1 to cretae a new file or 0 to replace the original
#duplicate=1
# ignore extensions.
#
# list of extensions that won't be transcoded.
#ignoreExtensions=.avi,.mkv
# outputFastStart (0,1).
#
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
#outputFastStart = 0
# outputVideoPath.
#
# outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable.
#outputVideoPath =
# processOutput (0,1).
#
# processOutput. 1 will send the outputVideoPath to SickBeard/CouchPotato. 0 will send original files.
#processOutput = 0
# audioLanguage.
#
# audioLanguage. set the 3 letter language code you want as your primary audio track.
#audioLanguage = eng
# allAudioLanguages (0,1).
#
# allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available.
#allAudioLanguages = 0
# allSubLanguages (0,1).
#
# allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above.
#allSubLanguages = 0
# embedSubs (0,1).
#
# embedSubs. 1 will embded external sub/srt subs into your video if this is supported.
#embedSubs = 1
# burnInSubtitle (0,1).
#
# burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs)
#burnInSubtitle = 0
# extractSubs (0,1).
#
# extractSubs. 1 will extract subs from the video file and save these as external srt files.
#extractSubs = 0
# externalSubDir.
#
# externalSubDir. set the directory where subs should be saved (if not the same directory as the video)
#externalSubDir =
# outputDefault (None, iPad, iPad-1080p, iPad-720p, Apple-TV2, iPod, iPhone, PS3, xbox, Roku-1080p, Roku-720p, Roku-480p, mkv, mp4-scene-release, MKV-SD).
#
# outputDefault. Loads default configs for the selected device. The remaining options below are ignored.
# If you want to use your own profile, set None and set the remaining options below.
#outputDefault = None
# hwAccel (0,1).
#
# hwAccel. 1 will set ffmpeg to enable hardware acceleration (this requires a recent ffmpeg).
#hwAccel=0
# ffmpeg output settings.
#outputVideoExtension=.mp4
#outputVideoCodec=libx264
#VideoCodecAllow =
#outputVideoResolution=720:-1
#outputVideoPreset=medium
#outputVideoFramerate=24
#outputVideoBitrate=800k
#outputAudioCodec=libmp3lame
#AudioCodecAllow =
#outputAudioBitrate=128k
#outputQualityPercent = 0
#outputAudioTrack2Codec = libfaac
#AudioCodec2Allow =
#outputAudioTrack2Bitrate = 128k
#outputAudioOtherCodec = libmp3lame
#AudioOtherCodecAllow =
#outputAudioOtherBitrate = 128k
#outputSubtitleCodec =
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -1,260 +1,5 @@
#!/usr/bin/env python2 #!/usr/bin/env python2
# coding=utf-8 # coding=utf-8
#
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Post-Process to SickBeard.
#
# This script sends the download to your automated media management servers.
#
# NOTE: This script requires Python to be installed on your system.
##############################################################################
### OPTIONS ###
## General
# Auto Update nzbToMedia (0, 1).
#
# Set to 1 if you want nzbToMedia to automatically check for and update to the latest version
#auto_update=0
# Check Media for corruption (0, 1).
#
# Enable/Disable media file checking using ffprobe.
#check_media=1
# Safe Mode protection of DestDir (0, 1).
#
# Enable/Disable a safety check to ensure we don't process all downloads in the default_downloadDirectory by mistake.
#safe_mode=1
# Disable additional extraction checks for failed (0, 1).
#
# Turn this on to disable additional extraction attempts for failed downloads. Default = 0 this will attempt to extract and verify if media is present.
#no_extract_failed = 0
## SickBeard
# SickBeard script category.
#
# category that gets called for post-processing with SickBeard.
#sbCategory=tv
# SickBeard host.
#
# The ipaddress for your SickBeard/SickRage server. e.g For the Same system use localhost or 127.0.0.1
#sbhost=localhost
# SickBeard port.
#sbport=8081
# SickBeard api key. For SickChill, Medusa, SiCKRAGE only.
#sbapikey=
# SickBeard username.
#sbusername=
# SickBeard password.
#sbpassword=
# SickBeard uses ssl (0, 1).
#
# Set to 1 if using ssl, else set to 0.
#sbssl=0
# SickBeard web_root
#
# set this if using a reverse proxy.
#sbweb_root=
# SickBeard watch directory.
#
# set this to where your SickBeard completed downloads are.
#sbwatch_dir=
# SickBeard fork.
#
# set to default or auto to auto-detect the custom fork type.
#sbfork=auto
# SickBeard Delete Failed Downloads (0, 1).
#
# set to 1 to delete failed, or 0 to leave files in place.
#sbdelete_failed=0
# SickBeard process method.
#
# set this to move, copy, hardlink, symlink as appropriate if you want to over-ride SB defaults. Leave blank to use SB default.
#sbprocess_method=
# SickBeard and NZBGet are a different system (0, 1).
#
# Enable to replace local path with the path as per the mountPoints below.
#sbremote_path=0
## Network
# Network Mount Points (Needed for remote path above)
#
# Enter Mount points as LocalPath,RemotePath and separate each pair with '|'
# e.g. mountPoints=/volume1/Public/,E:\|/volume2/share/,\\NAS\
#mountPoints=
## Extensions
# Media Extensions
#
# This is a list of media extensions that are used to verify that the download does contain valid media.
#mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso,.ts
## Posix
# Niceness for external tasks Extractor and Transcoder.
#
# Set the Niceness value for the nice command. These range from -20 (most favorable to the process) to 19 (least favorable to the process).
#niceness=10
# ionice scheduling class (0, 1, 2, 3).
#
# Set the ionice scheduling class. 0 for none, 1 for real time, 2 for best-effort, 3 for idle.
#ionice_class=2
# ionice scheduling class data.
#
# Set the ionice scheduling class data. This defines the class data, if the class accepts an argument. For real time and best-effort, 0-7 is valid data.
#ionice_classdata=4
## Transcoder
# getSubs (0, 1).
#
# set to 1 to download subtitles.
#getSubs=0
# subLanguages.
#
# subLanguages. create a list of languages in the order you want them in your subtitles.
#subLanguages=eng,spa,fra
# Transcode (0, 1).
#
# set to 1 to transcode, otherwise set to 0.
#transcode=0
# create a duplicate, or replace the original (0, 1).
#
# set to 1 to cretae a new file or 0 to replace the original
#duplicate=1
# ignore extensions.
#
# list of extensions that won't be transcoded.
#ignoreExtensions=.avi,.mkv
# outputFastStart (0,1).
#
# outputFastStart. 1 will use -movflags + faststart. 0 will disable this from being used.
#outputFastStart=0
# outputVideoPath.
#
# outputVideoPath. Set path you want transcoded videos moved to. Leave blank to disable.
#outputVideoPath=
# processOutput (0,1).
#
# processOutput. 1 will send the outputVideoPath to SickBeard/CouchPotato. 0 will send original files.
#processOutput=0
# audioLanguage.
#
# audioLanguage. set the 3 letter language code you want as your primary audio track.
#audioLanguage=eng
# allAudioLanguages (0,1).
#
# allAudioLanguages. 1 will keep all audio tracks (uses AudioCodec3) where available.
#allAudioLanguages=0
# allSubLanguages (0,1).
#
# allSubLanguages. 1 will keep all exisiting sub languages. 0 will discare those not in your list above.
#allSubLanguages=0
# embedSubs (0,1).
#
# embedSubs. 1 will embded external sub/srt subs into your video if this is supported.
#embedSubs=1
# burnInSubtitle (0,1).
#
# burnInSubtitle. burns the default sub language into your video (needed for players that don't support subs)
#burnInSubtitle=0
# extractSubs (0,1).
#
# extractSubs. 1 will extract subs from the video file and save these as external srt files.
#extractSubs=0
# externalSubDir.
#
# externalSubDir. set the directory where subs should be saved (if not the same directory as the video)
#externalSubDir=
# outputDefault (None, iPad, iPad-1080p, iPad-720p, Apple-TV2, iPod, iPhone, PS3, xbox, Roku-1080p, Roku-720p, Roku-480p, mkv, mp4-scene-release, MKV-SD).
#
# outputDefault. Loads default configs for the selected device. The remaining options below are ignored.
# If you want to use your own profile, set None and set the remaining options below.
#outputDefault=None
# hwAccel (0,1).
#
# hwAccel. 1 will set ffmpeg to enable hardware acceleration (this requires a recent ffmpeg).
#hwAccel=0
# ffmpeg output settings.
#outputVideoExtension=.mp4
#outputVideoCodec=libx264
#VideoCodecAllow=
#outputVideoResolution=720:-1
#outputVideoPreset=medium
#outputVideoFramerate=24
#outputVideoBitrate=800k
#outputAudioCodec=ac3
#AudioCodecAllow=
#outputAudioChannels=6
#outputAudioBitrate=640k
#outputQualityPercent=
#outputAudioTrack2Codec=libfaac
#AudioCodec2Allow=
#outputAudioTrack2Channels=2
#outputAudioTrack2Bitrate=160k
#outputAudioOtherCodec=libmp3lame
#AudioOtherCodecAllow=
#outputAudioOtherChannels=2
#outputAudioOtherBitrate=128k
#outputSubtitleCodec=
## WakeOnLan
# use WOL (0, 1).
#
# set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
#wolwake=0
# WOL MAC
#
# enter the mac address of the system to be woken.
#wolmac=00:01:2e:2D:64:e1
# Set the Host and Port of a server to verify system has woken.
#wolhost=192.168.1.37
#wolport=80
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys import sys

View file

@ -14,15 +14,15 @@ from core.utils import server_responding
# Initialize the config # Initialize the config
core.initialize() core.initialize()
#label = core.TORRENT_CLASS.core.get_torrent_status("f33a9c4b15cbd9170722d700069af86746817ade", ["label"]).get()['label'] # label = core.TORRENT_CLASS.core.get_torrent_status("f33a9c4b15cbd9170722d700069af86746817ade", ["label"]).get()['label']
#print label # print(label)
if transcoder.is_video_good(core.TEST_FILE, 0): if transcoder.is_video_good(core.TEST_FILE, 0):
print("FFPROBE Works") print("FFPROBE Works")
else: else:
print("FFPROBE FAILED") print("FFPROBE FAILED")
test = core.CFG['SickBeard','NzbDrone']['tv'].isenabled() test = core.CFG['SickBeard', 'NzbDrone']['tv'].isenabled()
print(test) print(test)
section = core.CFG.findsection('tv').isenabled() section = core.CFG.findsection('tv').isenabled()
print(section) print(section)