Create Clean.py

Clean NZB name.
Removes suffixes from NZB name
pull/1/head
TRaSH 5 years ago
parent 0bc91e8bee
commit 4ee0099634

@ -0,0 +1,53 @@
#!/usr/bin/env python
#
##############################################################################
### 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
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).')
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)-NZBgeek\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Obfuscated\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Scrambled\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-BUYMORE\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-postbot\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-AsRequested-xpost\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-4P\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-Rakuv\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-xpost\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)-AsRequested\.nzb$', '.nzb', fwp)
fwp = re.sub('(?i)[eztv]\.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)
if fwp:
print('[NZB] NZBNAME=', fwp, sep='')
sys.exit(POSTPROCESS_SUCCESS)
Loading…
Cancel
Save