Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- #
- ##############################################################################
- ### NZBGET POST-PROCESSING SCRIPT ###
- # Post-Process to CouchPotato.
- #
- # This script sends the download to your automated media management servers.
- #
- # NOTE: This script requires Python to be installed on your system.
- ##############################################################################
- ### OPTIONS ###
- ## CouchPotato
- # CouchPotato script category.
- #
- # category that gets called for post-processing with CouchPotatoServer.
- #cpsCategory=movie
- # CouchPotato api key.
- #cpsapikey=
- # CouchPotato host.
- #cpshost=localhost
- # CouchPotato port.
- #cpsport=5050
- # CouchPotato username.
- #cpsusername=
- # CouchPotato password.
- #cpspassword=
- # CouchPotato uses ssl (0, 1).
- #
- # Set to 1 if using ssl, else set to 0.
- #cpsssl=0
- # CouchPotato URL_Base
- #
- # set this if using a reverse proxy.
- #cpsweb_root=
- # CouchPotato Postprocess Delay.
- #
- # must be at least 60 seconds.
- #cpsdelay=65
- # CouchPotato Postprocess Method (renamer, manage).
- #
- # use "renamer" for CPS renamer (default) or "manage" to call a manage update.
- #cpsmethod=renamer
- # CouchPotato Delete Failed Downloads (0, 1).
- #
- # set to 1 to delete failed, or 0 to leave files in place.
- #cpsdelete_failed=0
- ## Extensions
- # Media Extensions
- #
- # This is a list of media extensions that may be transcoded if transcoder is enabled below.
- #mediaExtensions=.mkv,.avi,.divx,.xvid,.mov,.wmv,.mp4,.mpg,.mpeg,.vob,.iso
- ## Transcoder
- # Transcode (0, 1).
- #
- # set to 1 to transcode, otherwise set to 0.
- #transcode=0
- # create a duplicate, or replace the original (0, 1).
- #
- # set to 1 to cretae a new file or 0 to replace the original
- #duplicate=1
- # ignore extensions
- #
- # list of extensions that won't be transcoded.
- #ignoreExtensions=.avi,.mkv
- # ffmpeg output settings.
- #outputVideoExtension=.mp4
- #outputVideoCodec=libx264
- #outputVideoPreset=medium
- #outputVideoFramerate=24
- #outputVideoBitrate=800k
- #outputAudioCodec=libmp3lame
- #outputAudioBitrate=128k
- #outputSubtitleCodec=
- ## WakeOnLan
- # use WOL (0, 1).
- #
- # set to 1 to send WOL broadcast to the mac and test the server (e.g. xbmc) on the host and port specified.
- #wolwake=0
- # WOL MAC
- #
- # enter the mac address of the system to be woken.
- #wolmac=00:01:2e:2D:64:e1
- # Set the Host and Port of a server to verify system has woken.
- #wolhost=192.168.1.37
- #wolport=80
- ### NZBGET POST-PROCESSING SCRIPT ###
- ##############################################################################
- import os
- import sys
- import logging
- import shlex
- import autoProcess.migratecfg as migratecfg
- import autoProcess.autoProcessMovie as autoProcessMovie
- from autoProcess.nzbToMediaEnv import *
- from autoProcess.nzbToMediaUtil import *
- #check to migrate old cfg before trying to load.
- if os.path.isfile(os.path.join(os.path.dirname(sys.argv[0]), "autoProcessMedia.cfg.sample")):
- migratecfg.migrate()
- nzbtomedia_configure_logging(os.path.dirname(sys.argv[0]))
- Logger = logging.getLogger(__name__)
- Logger.info("====================") # Seperate old from new log
- Logger.info("nzbToCouchPotato %s", VERSION)
- #WakeUp()
- # SABnzbd
- if len(sys.argv) == SABNZB_NO_OF_ARGUMENTS:
- # SABnzbd argv:
- # 1 The final directory of the job (full path)
- # 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
- # 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.info("Script triggered from SABnzbd, starting autoProcessMovie...")
- clientAgent = "sabnzbd"
- Logger.info('SABnzbd command-line arguments ( ' + str(len(sys.argv)) + ' ): ' + str(sys.argv))
- result = autoProcessMovie.process(sys.argv[1], sys.argv[2], sys.argv[7], clientAgent)
- else:
- Logger.warn("Invalid number of arguments received from client.")
- Logger.info("Running autoProcessMovie as a manual run...")
- clientAgent = "manual"
- result = autoProcessMovie.process('Manual Run', 'Manual Run', 0, clientAgent)
- if result == 0:
- # Logger.info("Checking SABnzbd status...")
- # autoProcessMovie.check_sabnzbd()
- # Run Ember Media Manager to scrapre additional data
- Logger.info("Launching Ember Media Manager to scrape additional data...")
- result = autoProcessMovie.run_ember()
- if result == 0:
- # SUCCESS: Ember Media Manager ran successfully!
- Logger.info("Ember Media Manager ran successfully.")
- # Update XBMC Video Library
- Logger.info("Building XBMC JSON Object")
- xbmc = autoProcessMovie.get_xbmc_json_obj()
- Logger.info("Update XBMC Video Library...")
- autoProcessMovie.update_videolibrary(xbmc)
- # SUCCESS: autoProcessMovie script ran successfully!
- Logger.info("The autoProcessMovie script completed successfully.")
- else:
- # FAILURE: Ember Media Manager didn't run as expected!
- Logger.info("Ember Media Manager didn't run as expected!")
- Logger.info("MUST Run Ember Media Manager manually before updating XBMC Video Library!")
- else:
- Logger.info("A problem was reported in the autoProcessMovie script.")
Advertisement
Add Comment
Please, Sign In to add comment