|
|
@ -1,5 +1,5 @@ |
|
|
|
#!/usr/bin/env python |
|
|
|
# Example Post-Processing Script for SABnzbd (2.3.1 and higher), written in Python. |
|
|
|
# Example Post-Processing Script for SABnzbd (3.0.0 and higher), written in Python. |
|
|
|
# For Linux, MacOS, Windows and any other platform with Python |
|
|
|
# See https://sabnzbd.org/wiki/scripts/post-processing-scripts for details |
|
|
|
# |
|
|
@ -10,35 +10,34 @@ import sys, os |
|
|
|
|
|
|
|
# Raw parsing of input parameters en SABnzbd environment variables |
|
|
|
counter = 0 |
|
|
|
print("\nINPUT from argv:\n") |
|
|
|
print("INPUT from argv:") |
|
|
|
for item in sys.argv: |
|
|
|
print("Argument", counter, ":", item) |
|
|
|
counter += 1 |
|
|
|
|
|
|
|
print("\nINPUT from environment variables (only SAB specifics):\n") |
|
|
|
print("INPUT from environment variables (only SAB specifics):") |
|
|
|
for item in os.environ: |
|
|
|
if item.find("SAB_") == 0: |
|
|
|
if item.find("SAB_") == 0: |
|
|
|
print(item, os.environ[item]) |
|
|
|
|
|
|
|
# More intelligent parsing: |
|
|
|
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 SAB compliant number of commandline parameters found (should be 8):", len(sys.argv)-1) |
|
|
|
sys.exit(1) # non-zero return code |
|
|
|
print("No SAB compliant number of commandline parameters found (should be 8):", len(sys.argv) - 1) |
|
|
|
sys.exit(1) # non-zero return code |
|
|
|
|
|
|
|
# Some examples: |
|
|
|
print("\nExamples of some specific values:\n") |
|
|
|
print("jobname is", jobname) |
|
|
|
print("Examples of some specific values:") |
|
|
|
print("jobname is:", jobname) |
|
|
|
try: |
|
|
|
sabversion = os.environ['SAB_VERSION'] |
|
|
|
print("sabversion is", sabversion) |
|
|
|
sabversion = os.environ["SAB_VERSION"] |
|
|
|
print("SAB_VERSION is:", sabversion) |
|
|
|
except: |
|
|
|
pass |
|
|
|
|
|
|
|
''' your code here ''' |
|
|
|
""" your code here """ |
|
|
|
|
|
|
|
# We're done: |
|
|
|
print("\nScript done. All OK.") # the last line will appear in the SABnzb History GUI |
|
|
|
sys.exit(0) # The result code towards SABnzbd |
|
|
|
|
|
|
|
print("Script done. All OK.") # the last line will appear in the SABnzb History GUI |
|
|
|
sys.exit(0) # The result code towards SABnzbd |
|
|
|