Advertisement
lordjynx

NZBGet + Sonarr = Save the Subtitles!

Jan 20th, 2015
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.15 KB | None | 0 0
  1. #!/usr/bin/env python
  2. #
  3. ##############################################################################
  4. ### NZBGET POST-PROCESSING SCRIPT                                          ###
  5. # Save Subtitles so Sonarr doesn't delete them perm!
  6. ##############################################################################
  7. ### NZBGET POST-PROCESSING SCRIPT                                          ###
  8. ##############################################################################
  9. import os
  10. import sys
  11. import shutil
  12. POSTPROCESS_SUCCESS=93
  13.  
  14. nzbfulldir = os.environ.get('NZBPP_DIRECTORY','')
  15. #installdir = os.environ.get('NZBOP_APPDIR','')
  16. nzbname = os.environ.get('NZBPP_NZBNAME','')
  17.  
  18. for file in os.listdir(nzbfulldir):
  19.     if (file.endswith(".srt")) or (file.endswith(".sub")) or (file.endswith(".idx")):
  20.         print ("[INFO] SUBTITLE FOUND: " + file)
  21.         print ("[INFO] MOVING: " + file)
  22.         source = nzbfulldir + "\\" + file
  23.         print ("[INFO] SOURCE: " + source)
  24.         dest = "X:\SUBTITLE_FOLDER\\" + nzbname
  25.         if not os.path.exists(dest):
  26.             os.makedirs(dest)
  27.         dest = "X:\SUBTITLE_FOLDER\\" + nzbname + "\\" + file
  28.         shutil.move(source,dest)
  29. sys.exit(POSTPROCESS_SUCCESS)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement