You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
TRaSH-Guides/docs/Downloaders/NZBGet/scripts/Clean/Clean.py

62 lines
2.2 KiB

#!/usr/bin/env python3
#
##############################################################################
### NZBGET SCAN SCRIPT ###
# Clean NZB name.
#
# Removes the following suffixes from NZB name:
# NZBgeek / Obfuscated / BUYMORE / Scrambled.
#
# NOTE: This script requires Python to be installed on your system.
### NZBGET SCAN SCRIPT ###
##############################################################################
from __future__ import print_function
import os, re, sys
# Exit codes used by NZBGet
chore(editorconfig): Add more extensions (#1410) * Add more extensions to editorconfig Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat(editorconfig): update indent size * Revert "feat(editorconfig): update indent size" This reverts commit 30e5918efe499ebf05559b19bdb140e75bd0d31b. * style: :lipstick: format json files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format yaml files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format md files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format other files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format md files Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: editorconfig lint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * revert: :fire: remove deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: fix incorrect prior merges Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: change json to 2 spaces Signed-off-by: GitHub <noreply@github.com> * style: :lipstick: format json to 2 spaces Signed-off-by: GitHub <noreply@github.com> * update(formatting/py): run pep8 formatting --------- Signed-off-by: Eric Nemchik <eric@nemchik.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: FonduemangVI <15520607+FonduemangVI@users.noreply.github.com> Co-authored-by: FonduemangVI <michael.thomas@vualtlabs1226.com> Co-authored-by: zakary <zak@ary.dev>
7 months ago
POSTPROCESS_SUCCESS = 93
POSTPROCESS_ERROR = 94
POSTPROCESS_SKIP = 95
# Check if the script is called from NZBGet 13.0 or later
chore(editorconfig): Add more extensions (#1410) * Add more extensions to editorconfig Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat(editorconfig): update indent size * Revert "feat(editorconfig): update indent size" This reverts commit 30e5918efe499ebf05559b19bdb140e75bd0d31b. * style: :lipstick: format json files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format yaml files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format md files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format other files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format md files Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: editorconfig lint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * revert: :fire: remove deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: fix incorrect prior merges Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: change json to 2 spaces Signed-off-by: GitHub <noreply@github.com> * style: :lipstick: format json to 2 spaces Signed-off-by: GitHub <noreply@github.com> * update(formatting/py): run pep8 formatting --------- Signed-off-by: Eric Nemchik <eric@nemchik.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: FonduemangVI <15520607+FonduemangVI@users.noreply.github.com> Co-authored-by: FonduemangVI <michael.thomas@vualtlabs1226.com> Co-authored-by: zakary <zak@ary.dev>
7 months ago
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")
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)
if fwp:
chore(editorconfig): Add more extensions (#1410) * Add more extensions to editorconfig Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat(editorconfig): update indent size * Revert "feat(editorconfig): update indent size" This reverts commit 30e5918efe499ebf05559b19bdb140e75bd0d31b. * style: :lipstick: format json files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format yaml files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format md files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format other files Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: format md files Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: markdownlint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: editorconfig lint fixes Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * feat: :rocket: deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * revert: :fire: remove deploy preview Signed-off-by: Eric Nemchik <eric@nemchik.com> * fix: :bug: fix incorrect prior merges Signed-off-by: Eric Nemchik <eric@nemchik.com> * style: :lipstick: change json to 2 spaces Signed-off-by: GitHub <noreply@github.com> * style: :lipstick: format json to 2 spaces Signed-off-by: GitHub <noreply@github.com> * update(formatting/py): run pep8 formatting --------- Signed-off-by: Eric Nemchik <eric@nemchik.com> Signed-off-by: GitHub <noreply@github.com> Co-authored-by: FonduemangVI <15520607+FonduemangVI@users.noreply.github.com> Co-authored-by: FonduemangVI <michael.thomas@vualtlabs1226.com> Co-authored-by: zakary <zak@ary.dev>
7 months ago
print("[NZB] NZBNAME=", fwp, sep="")
sys.exit(POSTPROCESS_SUCCESS)