update(formatting/py): run pep8 formatting

pull/1410/head
zakary 2 weeks ago
parent 7453a3027c
commit 44d476c569

@ -18,44 +18,44 @@ from __future__ import print_function
import os, re, sys
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_SKIP=95
POSTPROCESS_SUCCESS = 93
POSTPROCESS_ERROR = 94
POSTPROCESS_SKIP = 95
# Check if the script is called from NZBGet 13.0 or later
if not 'NZBOP_SCRIPTDIR' in os.environ:
print('*** NZBGet post-processing script ***')
print('This script is supposed to be called from NZBGet (13.0 or later).')
if not "NZBOP_SCRIPTDIR" in os.environ:
print("*** NZBGet post-processing script ***")
print("This script is supposed to be called from NZBGet (13.0 or later).")
sys.exit(POSTPROCESS_ERROR)
if not 'NZBNP_NZBNAME' in os.environ:
print('[WARN] Filename not found in environment')
if not "NZBNP_NZBNAME" in os.environ:
print("[WARN] Filename not found in environment")
sys.exit(POSTPROCESS_ERROR)
fwp = os.environ['NZBNP_NZBNAME']
fwp = re.sub('(?i)-4P\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-4Planet\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-AsRequested\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-AsRequested-xpost\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-BUYMORE\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Chamele0n\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-GEROV\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-iNC0GNiTO\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-NZBGeek\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Obfuscated\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-postbot\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Rakuv\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Scrambled\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-WhiteRev\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-xpost\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)\[eztv([ ._-]re)?\]\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)\[TGx\]\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)\[TGx\]-xpost\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)\[ettv\]\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-WRTEAM\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-CAPTCHA\.nzb$', '.nzb', fwp)
fwp = re.sub(r'(\-[^-.\n]*)(\-.{4})?\.nzb$', r'\1.nzb', fwp)
fwp = os.environ["NZBNP_NZBNAME"]
fwp = re.sub("(?i)-4P\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-4Planet\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-AsRequested\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-AsRequested-xpost\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-BUYMORE\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-Chamele0n\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-GEROV\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-iNC0GNiTO\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-NZBGeek\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-Obfuscated\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-postbot\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-Rakuv\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-Scrambled\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-WhiteRev\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-xpost\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)\[eztv([ ._-]re)?\]\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)\[TGx\]\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)\[TGx\]-xpost\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)\[ettv\]\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-WRTEAM\.nzb$", ".nzb", fwp)
fwp = re.sub("(?i)-CAPTCHA\.nzb$", ".nzb", fwp)
fwp = re.sub(r"(\-[^-.\n]*)(\-.{4})?\.nzb$", r"\1.nzb", fwp)
if fwp:
print('[NZB] NZBNAME=', fwp, sep='')
print("[NZB] NZBNAME=", fwp, sep="")
sys.exit(POSTPROCESS_SUCCESS)

@ -43,51 +43,73 @@ NZBGET_POSTPROCESS_NONE = 95
# EXTENSION STUFF
############################################################
def do_check():
if 'NZBOP_SCRIPTDIR' not in os.environ:
if "NZBOP_SCRIPTDIR" not in os.environ:
print("This script can only be called from NZBGet (11.0 or later).")
sys.exit(0)
if os.environ['NZBOP_VERSION'][0:5] < '11.0':
print("[ERROR] NZBGet Version %s is not supported. Please update NZBGet." % (str(os.environ['NZBOP_VERSION'])))
if os.environ["NZBOP_VERSION"][0:5] < "11.0":
print(
"[ERROR] NZBGet Version %s is not supported. Please update NZBGet."
% (str(os.environ["NZBOP_VERSION"]))
)
sys.exit(0)
print("Script triggered from NZBGet Version %s." % (str(os.environ['NZBOP_VERSION'])))
print(
"Script triggered from NZBGet Version %s." % (str(os.environ["NZBOP_VERSION"]))
)
status = 0
if 'NZBPP_TOTALSTATUS' in os.environ:
if not os.environ['NZBPP_TOTALSTATUS'] == 'SUCCESS':
print("[ERROR] Download failed with status %s." % (os.environ['NZBPP_STATUS']))
if "NZBPP_TOTALSTATUS" in os.environ:
if not os.environ["NZBPP_TOTALSTATUS"] == "SUCCESS":
print(
"[ERROR] Download failed with status %s." % (os.environ["NZBPP_STATUS"])
)
status = 1
else:
# Check par status
if os.environ['NZBPP_PARSTATUS'] == '1' or os.environ['NZBPP_PARSTATUS'] == '4':
print("[ERROR] Par-repair failed, setting status \"failed\".")
if os.environ["NZBPP_PARSTATUS"] == "1" or os.environ["NZBPP_PARSTATUS"] == "4":
print('[ERROR] Par-repair failed, setting status "failed".')
status = 1
# Check unpack status
if os.environ['NZBPP_UNPACKSTATUS'] == '1':
print("[ERROR] Unpack failed, setting status \"failed\".")
if os.environ["NZBPP_UNPACKSTATUS"] == "1":
print('[ERROR] Unpack failed, setting status "failed".')
status = 1
if os.environ['NZBPP_UNPACKSTATUS'] == '0' and os.environ['NZBPP_PARSTATUS'] == '0':
if (
os.environ["NZBPP_UNPACKSTATUS"] == "0"
and os.environ["NZBPP_PARSTATUS"] == "0"
):
# Unpack was skipped due to nzb-file properties or due to errors during par-check
if os.environ['NZBPP_HEALTH'] < 1000:
print("[ERROR] Download health is compromised and Par-check/repair disabled or no .par2 files found. " \
"Setting status \"failed\".")
print("[ERROR] Please check your Par-check/repair settings for future downloads.")
if os.environ["NZBPP_HEALTH"] < 1000:
print(
"[ERROR] Download health is compromised and Par-check/repair disabled or no .par2 files found. "
'Setting status "failed".'
)
print(
"[ERROR] Please check your Par-check/repair settings for future downloads."
)
status = 1
else:
print("[ERROR] Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is " \
"ok so handle as though download successful.")
print("[WARNING] Please check your Par-check/repair settings for future downloads.")
print(
"[ERROR] Par-check/repair disabled or no .par2 files found, and Unpack not required. Health is "
"ok so handle as though download successful."
)
print(
"[WARNING] Please check your Par-check/repair settings for future downloads."
)
# Check if destination directory exists (important for reprocessing of history items)
if not os.path.isdir(os.environ['NZBPP_DIRECTORY']):
print("[ERROR] Nothing to post-process: destination directory", os.environ[
'NZBPP_DIRECTORY'], "doesn't exist. Setting status \"failed\".")
if not os.path.isdir(os.environ["NZBPP_DIRECTORY"]):
print(
"[ERROR] Nothing to post-process: destination directory",
os.environ["NZBPP_DIRECTORY"],
'doesn\'t exist. Setting status "failed".',
)
status = 1
# All checks done, now launching the script.
@ -98,9 +120,9 @@ def do_check():
def get_file_name(path):
try:
file_name = os.path.basename(path)
extensions = re.findall(r'\.([^.]+)', file_name)
ext = '.'.join(extensions)
name = file_name.replace(".%s" % ext, '')
extensions = re.findall(r"\.([^.]+)", file_name)
ext = ".".join(extensions)
name = file_name.replace(".%s" % ext, "")
return name, ext
except Exception:
pass
@ -109,10 +131,10 @@ def get_file_name(path):
def is_file_hash(file_name):
hash_regexp = [
r'^[a-fA-F0-9]{40}$',
r'^[a-fA-F0-9]{32}$',
r'^[a-f0-9]{128}$',
r'^[a-zA-Z0-9]{42}$'
r"^[a-fA-F0-9]{40}$",
r"^[a-fA-F0-9]{32}$",
r"^[a-f0-9]{128}$",
r"^[a-zA-Z0-9]{42}$",
]
for hash in hash_regexp:
if re.match(hash, file_name):
@ -146,20 +168,20 @@ def find_files(folder, extension=None, depth=None):
do_check()
# retrieve required variables
directory = os.path.normpath(os.environ['NZBPP_DIRECTORY'])
nzb_name = os.environ['NZBPP_NZBFILENAME']
directory = os.path.normpath(os.environ["NZBPP_DIRECTORY"])
nzb_name = os.environ["NZBPP_NZBFILENAME"]
if nzb_name is None:
print("[ERROR] Unable to retrieve NZBPP_NZBFILENAME")
sys.exit(NZBGET_POSTPROCESS_ERROR)
nzb_name = nzb_name.replace('.nzb', '')
nzb_name = nzb_name.replace(".nzb", "")
print(("[INFO] Using \"%s\" for hashed filenames" % nzb_name))
print(("[INFO] Scanning \"%s\" for hashed filenames" % directory))
print(('[INFO] Using "%s" for hashed filenames' % nzb_name))
print(('[INFO] Scanning "%s" for hashed filenames' % directory))
# scan for files
found_files = find_files(directory)
if not found_files:
print(("[INFO] No files were found in \"%s\"" % directory))
print(('[INFO] No files were found in "%s"' % directory))
sys.exit(NZBGET_POSTPROCESS_NONE)
else:
print(("[INFO] Found %d files to check for hashed filenames" % len(found_files)))
@ -173,13 +195,20 @@ else:
# is this a file hash
if is_file_hash(file_name):
new_file_path = os.path.join(dir_name, "%s.%s" % (nzb_name, file_ext))
print(("[INFO] Moving \"%s\" to \"%s\"" % (found_file_path, new_file_path)))
print(('[INFO] Moving "%s" to "%s"' % (found_file_path, new_file_path)))
try:
shutil.move(found_file_path, new_file_path)
moved_files += 1
except Exception:
print(("[ERROR] Failed moving \"%s\" to \"%s\"" % (found_file_path, new_file_path)))
print(("[INFO] Finished processing \"%s\", moved %d files" % (directory, moved_files)))
print(
(
'[ERROR] Failed moving "%s" to "%s"'
% (found_file_path, new_file_path)
)
)
print(
('[INFO] Finished processing "%s", moved %d files' % (directory, moved_files))
)
sys.exit(NZBGET_POSTPROCESS_SUCCESS)

@ -30,47 +30,56 @@ POSTPROCESS_ERROR = 94
try:
from lxml import etree
except ImportError:
print(u'[ERROR] Python lxml required. Please install with "sudo apt install python-lxml" or "pip install lxml".')
print(
'[ERROR] Python lxml required. Please install with "sudo apt install python-lxml" or "pip install lxml".'
)
sys.exit(POSTPROCESS_ERROR)
patterns = (
re.compile(r'^(?P<prefix>.*\[PRiVATE\]-\[WtFnZb\]-)'
r'\[(?P<total>\d+)\]-\[(?P<segment>\d+)\/(?P<filename>.{3,}?)\]'
r'\s+-\s+""\s+yEnc\s+',
re.MULTILINE | re.UNICODE),
re.compile(r'^(?P<prefix>.*\[PRiVATE\]-\[WtFnZb\]-)'
r'\[(?P<filename>.{3,}?)\]-\[(?P<segment>\d+)/(?P<total>\d+)\]'
r'\s+-\s+""\s+yEnc\s+',
re.MULTILINE | re.UNICODE))
nzb_dir = os.getenv('NZBNP_DIRECTORY')
nzb_filename = os.getenv('NZBNP_FILENAME')
nzb_name = os.getenv('NZBNP_NZBNAME')
nzb_file_naming = os.getenv('NZBOP_FILENAMING')
re.compile(
r"^(?P<prefix>.*\[PRiVATE\]-\[WtFnZb\]-)"
r"\[(?P<total>\d+)\]-\[(?P<segment>\d+)\/(?P<filename>.{3,}?)\]"
r'\s+-\s+""\s+yEnc\s+',
re.MULTILINE | re.UNICODE,
),
re.compile(
r"^(?P<prefix>.*\[PRiVATE\]-\[WtFnZb\]-)"
r"\[(?P<filename>.{3,}?)\]-\[(?P<segment>\d+)/(?P<total>\d+)\]"
r'\s+-\s+""\s+yEnc\s+',
re.MULTILINE | re.UNICODE,
),
)
nzb_dir = os.getenv("NZBNP_DIRECTORY")
nzb_filename = os.getenv("NZBNP_FILENAME")
nzb_name = os.getenv("NZBNP_NZBNAME")
nzb_file_naming = os.getenv("NZBOP_FILENAMING")
if nzb_dir is None or nzb_filename is None or nzb_name is None:
print('Please run as NZBGet plugin')
print("Please run as NZBGet plugin")
sys.exit(POSTPROCESS_ERROR)
if nzb_file_naming is not None and nzb_file_naming.lower() != 'nzb':
print(u'[ERROR] NZBGet setting FileNaming (under Download Queue) '
u'must be set to "Nzb" for this extension to work correctly, exiting.')
if nzb_file_naming is not None and nzb_file_naming.lower() != "nzb":
print(
"[ERROR] NZBGet setting FileNaming (under Download Queue) "
'must be set to "Nzb" for this extension to work correctly, exiting.'
)
sys.exit(POSTPROCESS_ERROR)
if not os.path.exists(nzb_dir):
print('[ERROR] NZB directory doesn\'t exist, exiting')
print("[ERROR] NZB directory doesn't exist, exiting")
sys.exit(POSTPROCESS_ERROR)
if not nzb_filename.lower().endswith('.nzb'):
print(u'[ERROR] {} is not a .nzb file.'.format(nzb_filename))
if not nzb_filename.lower().endswith(".nzb"):
print("[ERROR] {} is not a .nzb file.".format(nzb_filename))
sys.exit(POSTPROCESS_ERROR)
nzb = os.path.join(nzb_dir, nzb_filename)
if not os.path.exists(nzb):
print('[ERROR] {nzb} doesn\'t exist, exiting'.format(nzb=nzb))
print("[ERROR] {nzb} doesn't exist, exiting".format(nzb=nzb))
sys.exit(POSTPROCESS_ERROR)
with open(nzb, mode='rb') as infile:
with open(nzb, mode="rb") as infile:
tree = etree.parse(infile)
changed = False
@ -78,74 +87,77 @@ file_count = 0
totals = set()
filenames = set()
for f in tree.getiterator('{http://www.newzbin.com/DTD/2003/nzb}file'):
subject = f.get('subject')
for f in tree.getiterator("{http://www.newzbin.com/DTD/2003/nzb}file"):
subject = f.get("subject")
if subject is None:
print(u'[DETAIL] No subject in <file>, skipping')
print("[DETAIL] No subject in <file>, skipping")
continue
file_count += 1
result = [re.match(pattern, subject) for pattern in patterns]
matched = [m for m in result if m is not None]
if len(matched) == 0:
print(u'[INFO] No pattern matching subject, exiting.')
print("[INFO] No pattern matching subject, exiting.")
sys.exit(POSTPROCESS_NONE)
elif len(matched) > 1:
print(u'[ERROR] Multiple patterns matched, exiting.')
print("[ERROR] Multiple patterns matched, exiting.")
sys.exit(POSTPROCESS_ERROR)
else:
match = matched[0].groupdict()
if match['filename'].lower().endswith('.par2'):
print(u'[INFO] par2 exists, exiting')
if match["filename"].lower().endswith(".par2"):
print("[INFO] par2 exists, exiting")
sys.exit(POSTPROCESS_NONE)
if int(match['segment']) > int(match['total']):
print(u'[DETAIL] Segment index is greater then total, skipping')
if int(match["segment"]) > int(match["total"]):
print("[DETAIL] Segment index is greater then total, skipping")
continue
# NZBGet subject parsing changes when duplicate filenames are present
# prefix duplicates to avoid that
if match['filename'] in filenames:
match['filename'] = u'{}.{}'.format(file_count, match['filename'])
if match["filename"] in filenames:
match["filename"] = "{}.{}".format(file_count, match["filename"])
filenames.add(match['filename'])
filenames.add(match["filename"])
s = u'WtFnZb "{filename}" yEnc ({segment}/{total})'.format(
filename = match['filename'],
segment = match['segment'],
total = match['total'])
s = 'WtFnZb "{filename}" yEnc ({segment}/{total})'.format(
filename=match["filename"], segment=match["segment"], total=match["total"]
)
print(u'[INFO] New subject {subject}'.format(subject=s.encode('ascii', 'ignore')))
f.set('subject', s)
print("[INFO] New subject {subject}".format(subject=s.encode("ascii", "ignore")))
f.set("subject", s)
changed = True
totals.add(int(match['total']))
totals.add(int(match["total"]))
if not changed:
print(u'[WARNING] No subject changed, exiting.')
print("[WARNING] No subject changed, exiting.")
sys.exit(POSTPROCESS_NONE)
if len(totals) != 1:
print(u'[WARNING] Mixed values for number of total segments, exiting.')
print("[WARNING] Mixed values for number of total segments, exiting.")
sys.exit(POSTPROCESS_NONE)
if totals.pop() != file_count:
print(u'[WARNING] Listed segment count does not match <file> count, exiting.')
print("[WARNING] Listed segment count does not match <file> count, exiting.")
sys.exit(POSTPROCESS_NONE)
org = u'{}.wtfnzb.original.processed'.format(nzb)
org = "{}.wtfnzb.original.processed".format(nzb)
exists_counter = 0
while os.path.exists(org):
exists_counter += 1
org = u'{}.{}.wtfnzb.original.processed'.format(nzb, exists_counter)
org = "{}.{}.wtfnzb.original.processed".format(nzb, exists_counter)
print(u'[INFO] Preserving original nzb as {}'.format(org))
print("[INFO] Preserving original nzb as {}".format(org))
os.rename(nzb, org)
print(u'[INFO] Writing {}'.format(nzb))
with open(nzb, mode='wb') as outfile:
outfile.write(etree.tostring(tree,
xml_declaration=True,
encoding=tree.docinfo.encoding,
doctype=tree.docinfo.doctype))
print("[INFO] Writing {}".format(nzb))
with open(nzb, mode="wb") as outfile:
outfile.write(
etree.tostring(
tree,
xml_declaration=True,
encoding=tree.docinfo.encoding,
doctype=tree.docinfo.doctype,
)
)
sys.exit(POSTPROCESS_SUCCESS)

@ -22,19 +22,19 @@ from __future__ import print_function
import os, re, sys
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_SKIP=95
POSTPROCESS_SUCCESS = 93
POSTPROCESS_ERROR = 94
POSTPROCESS_SKIP = 95
directory = os.environ['NZBPP_DIRECTORY']
print('Directory used is: ',directory)
directory = os.environ["NZBPP_DIRECTORY"]
print("Directory used is: ", directory)
for path, currentDirectory, files in os.walk(directory):
for file in files:
if file.find("_") !=-1:
dst = file.replace('_', '.')
os.rename (os.path.join(path,file),os.path.join(path,dst) )
print('Result: ',file," renamed to ",dst)
if file.find("_") != -1:
dst = file.replace("_", ".")
os.rename(os.path.join(path, file), os.path.join(path, dst))
print("Result: ", file, " renamed to ", dst)
sys.exit(POSTPROCESS_SUCCESS)

@ -24,41 +24,50 @@ import re
sys.argv = sys.argv[:9]
try:
# Parse the input variables for SABnzbd version >= 4.2.0
(scriptname, nzbname, postprocflags, category, script, prio, downloadsize, grouplist) = sys.argv
(
scriptname,
nzbname,
postprocflags,
category,
script,
prio,
downloadsize,
grouplist,
) = sys.argv
except:
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script
fwp = nzbname
fwp = re.sub('(?i)-4P$', '', fwp)
fwp = re.sub('(?i)-4Planet$', '', fwp)
fwp = re.sub('(?i)-AlternativeToRequested$', '', fwp)
fwp = re.sub('(?i)-AlteZachen$', '', fwp)
fwp = re.sub('(?i)-AsRequested$', '', fwp)
fwp = re.sub('(?i)-AsRequested-xpost$', '', fwp)
fwp = re.sub('(?i)-BUYMORE$', '', fwp)
fwp = re.sub('(?i)-Chamele0n$', '', fwp)
fwp = re.sub('(?i)-GEROV$', '', fwp)
fwp = re.sub('(?i)-iNC0GNiTO$', '', fwp)
fwp = re.sub('(?i)-NZBGeek$', '', fwp)
fwp = re.sub('(?i)-Obfuscated$', '', fwp)
fwp = re.sub('(?i)-Obfuscation$', '', fwp)
fwp = re.sub('(?i)-postbot$', '', fwp)
fwp = re.sub('(?i)-Rakuv[a-z0-9]*$', '', fwp)
fwp = re.sub('(?i)-RePACKPOST$', '', fwp)
fwp = re.sub('(?i)-Scrambled$', '', fwp)
fwp = re.sub('(?i)-WhiteRev$', '', fwp)
fwp = re.sub('(?i)-WRTEAM$', '', fwp)
fwp = re.sub('(?i)-CAPTCHA$', '', fwp)
fwp = re.sub('(?i)-Z0iDS3N$', '', fwp)
fwp = re.sub('(?i)\[eztv([ ._-]re)?\]$', '', fwp)
fwp = re.sub('(?i)\[TGx\]$', '', fwp)
fwp = re.sub('(?i)\[ettv\]$', '', fwp)
fwp = re.sub('(?i)\[TGx\]-xpost$', '', fwp)
fwp = re.sub('(?i).mkv-xpost$', '', fwp)
fwp = re.sub('(?i)-xpost$', '', fwp)
fwp = re.sub(r'(?i)(-D-Z0N3|\-[^-.\n]*)(\-.{4})?$', r'\1', fwp)
fwp = re.sub("(?i)-4P$", "", fwp)
fwp = re.sub("(?i)-4Planet$", "", fwp)
fwp = re.sub("(?i)-AlternativeToRequested$", "", fwp)
fwp = re.sub("(?i)-AlteZachen$", "", fwp)
fwp = re.sub("(?i)-AsRequested$", "", fwp)
fwp = re.sub("(?i)-AsRequested-xpost$", "", fwp)
fwp = re.sub("(?i)-BUYMORE$", "", fwp)
fwp = re.sub("(?i)-Chamele0n$", "", fwp)
fwp = re.sub("(?i)-GEROV$", "", fwp)
fwp = re.sub("(?i)-iNC0GNiTO$", "", fwp)
fwp = re.sub("(?i)-NZBGeek$", "", fwp)
fwp = re.sub("(?i)-Obfuscated$", "", fwp)
fwp = re.sub("(?i)-Obfuscation$", "", fwp)
fwp = re.sub("(?i)-postbot$", "", fwp)
fwp = re.sub("(?i)-Rakuv[a-z0-9]*$", "", fwp)
fwp = re.sub("(?i)-RePACKPOST$", "", fwp)
fwp = re.sub("(?i)-Scrambled$", "", fwp)
fwp = re.sub("(?i)-WhiteRev$", "", fwp)
fwp = re.sub("(?i)-WRTEAM$", "", fwp)
fwp = re.sub("(?i)-CAPTCHA$", "", fwp)
fwp = re.sub("(?i)-Z0iDS3N$", "", fwp)
fwp = re.sub("(?i)\[eztv([ ._-]re)?\]$", "", fwp)
fwp = re.sub("(?i)\[TGx\]$", "", fwp)
fwp = re.sub("(?i)\[ettv\]$", "", fwp)
fwp = re.sub("(?i)\[TGx\]-xpost$", "", fwp)
fwp = re.sub("(?i).mkv-xpost$", "", fwp)
fwp = re.sub("(?i)-xpost$", "", fwp)
fwp = re.sub(r"(?i)(-D-Z0N3|\-[^-.\n]*)(\-.{4})?$", r"\1", fwp)
print("1") # Accept
print("1") # Accept
print(fwp)
print()
print()

@ -20,18 +20,28 @@ import os
import os.path
try:
(scriptname, directory, orgnzbname, jobname, reportnumber, category, group, postprocstatus, url) = sys.argv
(
scriptname,
directory,
orgnzbname,
jobname,
reportnumber,
category,
group,
postprocstatus,
url,
) = sys.argv
except:
print("No commandline parameters found")
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script
sys.exit(1) # exit with 1 causes SABnzbd to ignore the output of this script
files = os.listdir(directory)
for src in files:
if src.find("_") !=-1:
dst = src.replace('_', '.')
os.rename (os.path.join(directory,src),os.path.join(directory,dst) )
print(src, "renamed to ",dst)
if src.find("_") != -1:
dst = src.replace("_", ".")
os.rename(os.path.join(directory, src), os.path.join(directory, dst))
print(src, "renamed to ", dst)
print()
print()
@ -39,4 +49,3 @@ print()
print()
# 0 means OK
sys.exit(0)

Loading…
Cancel
Save