Help writing a copy script
Posted: 04 Feb 2014, 19:31
Hi there,
I've been using sab for a while, and I had a coder friend write a script for me to copy files that matched certain categories into a given folder, so I essentially ended up with 2 copies of the same file in 2 different places. I'd like to do the same thing with NZBGet but I'm having trouble adapting the script, as I'm no coder. Can someone help?
Here's what I've got so far but the script fails without any useful info:
#!/usr/bin/env python
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Copies comic and music.
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys,os,distutils.dir_util
# Args as found in docs at: http://wiki.sabnzbd.org/user-scripts
# 1 The final directory of the job (full path)
origin = "$NZBPP_DIRECTORY" #sys.argv[1]
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
category = "$NZBPP_CATEGORY" #sys.argv[5]
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21
destination = ""
if category.lower() == "Comics":
destination = "C:\Users\Ryan\Dropbox\Comics"
elif category.lower() == "Music":
destination = "C:\Users\Ryan\Music\iTunes\iTunes Media\Automatically Add to iTunes"
else:
print("Origin: " + origin)
print("Category: " + category)
sys.exit("Script failed!")
distutils.dir_util.copy_tree(origin, destination)
Thanks!
I've been using sab for a while, and I had a coder friend write a script for me to copy files that matched certain categories into a given folder, so I essentially ended up with 2 copies of the same file in 2 different places. I'd like to do the same thing with NZBGet but I'm having trouble adapting the script, as I'm no coder. Can someone help?
Here's what I've got so far but the script fails without any useful info:
#!/usr/bin/env python
##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###
# Copies comic and music.
### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################
import sys,os,distutils.dir_util
# Args as found in docs at: http://wiki.sabnzbd.org/user-scripts
# 1 The final directory of the job (full path)
origin = "$NZBPP_DIRECTORY" #sys.argv[1]
# 2 The original name of the NZB file
# 3 Clean version of the job name (no path info and ".nzb" removed)
# 4 Indexer's report number (if supported)
# 5 User-defined category
category = "$NZBPP_CATEGORY" #sys.argv[5]
# 6 Group that the NZB was posted in e.g. alt.binaries.x
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+21
destination = ""
if category.lower() == "Comics":
destination = "C:\Users\Ryan\Dropbox\Comics"
elif category.lower() == "Music":
destination = "C:\Users\Ryan\Music\iTunes\iTunes Media\Automatically Add to iTunes"
else:
print("Origin: " + origin)
print("Category: " + category)
sys.exit("Script failed!")
distutils.dir_util.copy_tree(origin, destination)
Thanks!