mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-19 21:03:14 -07:00
nzbTo* files will now send section variable to nzbToMedia script so that manually processing doesn't bother with trying to post-process unrequired folders, also I've changed the way we call nzbToMedia so this should resolve issue #328 encoding issues.
Custom userscripts folder added to avoid auto-update conflicts so long as the custom scripts are stored in said folder, this folder is added to .gitignore
This commit is contained in:
parent
94354bb7d9
commit
eac9619dcb
12 changed files with 47 additions and 70 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,5 +3,6 @@
|
|||
*.pyc
|
||||
*.pyo
|
||||
*.log
|
||||
/userscripts/
|
||||
/logs/
|
||||
/.idea/
|
|
@ -323,7 +323,7 @@ def external_script(outputDestination, torrentName, torrentLabel):
|
|||
logger.postprocess("%s files were processed, but %s still remain. outputDirectory will not be cleaned.", num_files, num_files_new)
|
||||
return final_result
|
||||
|
||||
def main():
|
||||
def main(args):
|
||||
# Initialize the config
|
||||
nzbtomedia.initialize()
|
||||
|
||||
|
@ -332,7 +332,7 @@ def main():
|
|||
logger.postprocess("#########################################################")
|
||||
|
||||
# debug command line options
|
||||
logger.debug("Options passed into TorrentToMedia: " + str(sys.argv))
|
||||
logger.debug("Options passed into TorrentToMedia: " + str(args))
|
||||
|
||||
# Post-Processing Result
|
||||
result = 0
|
||||
|
@ -341,7 +341,7 @@ def main():
|
|||
clientAgent = nzbtomedia.CLIENTAGENT
|
||||
|
||||
try:
|
||||
inputDirectory, inputName, inputCategory, inputHash, inputID = parse_args(clientAgent)
|
||||
inputDirectory, inputName, inputCategory, inputHash, inputID = parse_args(clientAgent, args)
|
||||
except:
|
||||
logger.error("There was a problem loading variables")
|
||||
return -1
|
||||
|
@ -366,7 +366,7 @@ def main():
|
|||
result = processTorrent(inputDirectory, inputName, inputCategory, inputHash, inputID, clientAgent)
|
||||
|
||||
logger.postprocess("All done.")
|
||||
return result
|
||||
sys.exit(result)
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
main(sys.argv)
|
||||
|
|
|
@ -179,8 +179,8 @@
|
|||
user_script_categories = NONE
|
||||
#What extension do you want to process? Specify all the extension, or use "ALL" to process all files.
|
||||
user_script_mediaExtensions = .mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg
|
||||
#Specify the path of the script
|
||||
user_script_path = /media/test/script/script.sh
|
||||
#Specify the path to your custom script
|
||||
user_script_path = /nzbToMedia/userscripts/script.sh
|
||||
#Specify the argument(s) passed to script, comma separated in order.
|
||||
#for example FP,FN,DN, TN, TL for file path (absolute file name with path), file name, absolute directory name (with path), Torrent Name, Torrent Label/Category.
|
||||
#So the result is /media/test/script/script.sh FP FN DN TN TL. Add other arguments as needed eg -f, -r
|
||||
|
|
|
@ -127,13 +127,8 @@
|
|||
|
||||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
# Stub file to call nzbToMedia
|
||||
import sys
|
||||
import nzbToMedia
|
||||
|
||||
def main():
|
||||
# call nzbToMedia
|
||||
nzbToMedia.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
section = "CouchPotato"
|
||||
nzbToMedia.main(sys.argv, section)
|
|
@ -64,13 +64,8 @@
|
|||
|
||||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
# Stub file to call nzbToMedia
|
||||
import sys
|
||||
import nzbToMedia
|
||||
|
||||
def main():
|
||||
# call nzbToMedia
|
||||
nzbToMedia.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
section = "Gamez"
|
||||
nzbToMedia.main(sys.argv, section)
|
|
@ -68,12 +68,8 @@
|
|||
|
||||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
# Stub file to call nzbToMedia
|
||||
import sys
|
||||
import nzbToMedia
|
||||
|
||||
def main():
|
||||
# call nzbToMedia
|
||||
nzbToMedia.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
section = "HeadPhones"
|
||||
nzbToMedia.main(sys.argv, section)
|
|
@ -329,16 +329,16 @@ def process(nzbDir, inputName=None, status=0, clientAgent='manual', download_id=
|
|||
|
||||
return result
|
||||
|
||||
def main():
|
||||
def main(args, section=None):
|
||||
# Initialize the config
|
||||
nzbtomedia.initialize()
|
||||
nzbtomedia.initialize(section)
|
||||
|
||||
logger.postprocess("#########################################################")
|
||||
logger.postprocess("## ..::[%s]::.. :: STARTING", os.path.splitext(os.path.basename(os.path.normpath(os.path.abspath(__file__))))[0])
|
||||
logger.postprocess("#########################################################")
|
||||
|
||||
# debug command line options
|
||||
logger.debug("Options passed into nzbToMedia: " + str(sys.argv))
|
||||
logger.debug("Options passed into nzbToMedia: " + str(args))
|
||||
|
||||
# Post-Processing Result
|
||||
result = 0
|
||||
|
@ -393,7 +393,7 @@ def main():
|
|||
# All checks done, now launching the script.
|
||||
result = process(os.environ['NZBPP_DIRECTORY'], inputName=os.environ['NZBPP_NZBFILENAME'], status=status, clientAgent = "nzbget", download_id=download_id, inputCategory=os.environ['NZBPP_CATEGORY'])
|
||||
# SABnzbd Pre 0.7.17
|
||||
elif len(sys.argv) == nzbtomedia.SABNZB_NO_OF_ARGUMENTS:
|
||||
elif len(args) == nzbtomedia.SABNZB_NO_OF_ARGUMENTS:
|
||||
# SABnzbd argv:
|
||||
# 1 The final directory of the job (full path)
|
||||
# 2 The original name of the NZB file
|
||||
|
@ -403,9 +403,9 @@ def main():
|
|||
# 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+2
|
||||
logger.postprocess("Script triggered from SABnzbd")
|
||||
result = process(sys.argv[1], inputName=sys.argv[2], status=sys.argv[7], inputCategory=sys.argv[5], clientAgent = "sabnzbd", download_id='')
|
||||
result = process(args[1], inputName=args[2], status=args[7], inputCategory=args[5], clientAgent = "sabnzbd", download_id='')
|
||||
# SABnzbd 0.7.17+
|
||||
elif len(sys.argv) >= nzbtomedia.SABNZB_0717_NO_OF_ARGUMENTS:
|
||||
elif len(args) >= nzbtomedia.SABNZB_0717_NO_OF_ARGUMENTS:
|
||||
# SABnzbd argv:
|
||||
# 1 The final directory of the job (full path)
|
||||
# 2 The original name of the NZB file
|
||||
|
@ -416,7 +416,7 @@ def main():
|
|||
# 7 Status of post processing. 0 = OK, 1=failed verification, 2=failed unpack, 3=1+2
|
||||
# 8 Failure URL
|
||||
logger.postprocess("Script triggered from SABnzbd 0.7.17+")
|
||||
result = process(sys.argv[1], inputName=sys.argv[2], status=sys.argv[7], inputCategory=sys.argv[5], clientAgent = "sabnzbd", download_id='')
|
||||
result = process(args[1], inputName=args[2], status=args[7], inputCategory=args[5], clientAgent = "sabnzbd", download_id='')
|
||||
else:
|
||||
# Perform Manual Run
|
||||
logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...")
|
||||
|
@ -437,15 +437,15 @@ def main():
|
|||
logger.postprocess("nzbToMedia %s:%s is DISABLED, you can enable this in autoProcessMedia.cfg ...", section, category)
|
||||
|
||||
if result == 0:
|
||||
logger.postprocess("The nzbToMedia script completed successfully.")
|
||||
logger.postprocess("The %s script completed successfully.", args[0])
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_SUCCESS)
|
||||
else:
|
||||
logger.error("A problem was reported in the nzbToMedia script.")
|
||||
logger.error("A problem was reported in the nzbToMedia script.", args[0])
|
||||
if os.environ.has_key('NZBOP_SCRIPTDIR'): # return code for nzbget v11
|
||||
sys.exit(nzbtomedia.NZBGET_POSTPROCESS_ERROR)
|
||||
|
||||
return result
|
||||
sys.exit(result)
|
||||
|
||||
if __name__ == '__main__':
|
||||
exit(main())
|
||||
main(sys.argv)
|
|
@ -67,13 +67,8 @@
|
|||
|
||||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
# Stub file to call nzbToMedia
|
||||
import sys
|
||||
import nzbToMedia
|
||||
|
||||
def main():
|
||||
# call nzbToMedia
|
||||
nzbToMedia.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
section = "Mylar"
|
||||
nzbToMedia.main(sys.argv, section)
|
|
@ -110,13 +110,8 @@
|
|||
|
||||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
# Stub file to call nzbToMedia
|
||||
import sys
|
||||
import nzbToMedia
|
||||
|
||||
def main():
|
||||
# call nzbToMedia
|
||||
nzbToMedia.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
section = "NzbDrone"
|
||||
nzbToMedia.main(sys.argv, section)
|
|
@ -130,13 +130,8 @@
|
|||
|
||||
### NZBGET POST-PROCESSING SCRIPT ###
|
||||
##############################################################################
|
||||
|
||||
# Stub file to call nzbToMedia
|
||||
import sys
|
||||
import nzbToMedia
|
||||
|
||||
def main():
|
||||
# call nzbToMedia
|
||||
nzbToMedia.main()
|
||||
|
||||
if __name__ == "__main__":
|
||||
exit(main())
|
||||
section = "SickBeard"
|
||||
nzbToMedia.main(sys.argv, section)
|
|
@ -97,7 +97,7 @@ USER_SCRIPT_RUNONCE = None
|
|||
|
||||
__INITIALIZED__ = False
|
||||
|
||||
def initialize():
|
||||
def initialize(section=None):
|
||||
global NZBGET_POSTPROCESS_ERROR, NZBGET_POSTPROCESS_NONE, NZBGET_POSTPROCESS_PARCHECK, NZBGET_POSTPROCESS_SUCCESS,\
|
||||
NZBTOMEDIA_TIMEOUT, FORKS, FORK_DEFAULT, FORK_FAILED_TORRENT, FORK_FAILED, SICKBEARD_TORRENT, SICKBEARD_FAILED,\
|
||||
PROGRAM_DIR, CFG, CFG_LOGGING, CONFIG_FILE, CONFIG_MOVIE_FILE, CONFIG_SPEC_FILE, LOG_DIR, NZBTOMEDIA_BRANCH,\
|
||||
|
@ -222,7 +222,12 @@ def initialize():
|
|||
MINSAMPLESIZE = int(CFG["Extensions"]["minSampleSize"]) # 200 (in MB)
|
||||
SAMPLEIDS = (CFG["Extensions"]["SampleIDs"]) # sample,-s.
|
||||
|
||||
# check for script-defied section and if None set to allow sections
|
||||
if section:
|
||||
SECTIONS = (section,)
|
||||
else:
|
||||
SECTIONS = ("CouchPotato", "SickBeard", "NzbDrone", "HeadPhones", "Mylar", "Gamez")
|
||||
|
||||
SUBSECTIONS = CFG[SECTIONS]
|
||||
CATEGORIES += SUBSECTIONS.sections
|
||||
|
||||
|
|
|
@ -367,7 +367,7 @@ def parse_transmission(args):
|
|||
inputID = os.getenv('TR_TORRENT_ID')
|
||||
return inputDirectory, inputName, inputCategory, inputHash, inputID
|
||||
|
||||
def parse_args(clientAgent):
|
||||
def parse_args(clientAgent, args):
|
||||
clients = {
|
||||
'other': parse_other,
|
||||
'rtorrent': parse_rtorrent,
|
||||
|
@ -377,7 +377,7 @@ def parse_args(clientAgent):
|
|||
}
|
||||
|
||||
try:
|
||||
return clients[clientAgent](sys.argv)
|
||||
return clients[clientAgent](args)
|
||||
except:return None, None, None, None, None
|
||||
|
||||
def get_dirnames(section, subsections=None):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue