[Scan Script] Truncate NZB Name Length

Share your scripts or request scripts with specific features.
Forum rules
Please keep the forum clean - one topic per script. Questions not related to a specific script should be posted in Support forum.
Post Reply
cjicantlie
Posts: 1
Joined: 17 Oct 2015, 06:52

[Scan Script] Truncate NZB Name Length

Post by cjicantlie » 17 Oct 2015, 07:00

I am having an issue lately where a few shows I watch have really long file names on their NZBs, leading to the "Could not move file" errors due to the file name length(with subfolder) exceeding Window's limits.

If I add an NZB manually in a paused state, and manually truncate the name, and unpause, the show will download just fine.

I would love a scan script that automatically cuts off the name after the SxxExx or YYYY.MM.DD portion, so I won't have to manually do this anymore.

Any help would be much appreciated.

Thanks

Edit: Figured it out. Was a rather simple script really. Had to research a bit to figure out the basics.

Here is the code if anyone wants:

Code: Select all

##############################################################################
### NZBGET SCAN SCRIPT                                                     ###

# This Script will Truncate NZB file name
#
# Will truncate nzb name length to 50 characters
#
#
# NOTE: This script requires Python (v2 or later) to be installed on your system.
#

### NZBGET SCAN SCRIPT                                                     ###
##############################################################################

import os, re, sys

POSTPROCESS_SKIP=95
POSTPROCESS_ERROR=94
POSTPROCESS_SUCCESS=93

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)
	
nname = os.environ['NZBNP_NZBNAME']
tname = nname[:50]

print('[NZB] NZBNAME=' + tname)


sys.exit(POSTPROCESS_SUCCESS)

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest