Skip to content

Commit

Permalink
NZBGet Support
Browse files Browse the repository at this point in the history
  • Loading branch information
SierraJC committed Oct 1, 2014
1 parent 3e5c182 commit 1126d6f
Show file tree
Hide file tree
Showing 3 changed files with 47 additions and 9 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Postprocessing Script for SABnzbd+
# Postprocessing Script for Anime

This script will hash your downloaded Anime from SABnzbd+ and sync it with your anidb.net account. The file will be renamed and moved to your specified target-directory.
This script will hash your downloaded Anime from **SABnzbd+** or **NZBGet** and sync it with your anidb.net account. The file will be renamed and moved to your specified target-directory.

## Installation

Expand Down
8 changes: 4 additions & 4 deletions nzbToAniDB.libs/anidb.py
Original file line number Diff line number Diff line change
Expand Up @@ -465,10 +465,10 @@ def removeDisallowedFilenameChars(filename):
try:
urllib.urlopen(req)
except urllib.HTTPError, e:
print(red('could not notify Plex Media Server'))
print(red('Could not notify Plex Media Server'))
print e.code
else:
print(green('notified Plex Media Server'))
print(green('Notified Plex Media Server'))
except:
pass

Expand All @@ -493,10 +493,10 @@ def removeDisallowedFilenameChars(filename):
try:
urllib.urlopen(req)
except urllib.HTTPError, e:
print(red('could not notify XBMC'))
print(red('Could not notify XBMC'))
print e.code
else:
print(green('notified XBMC'))
print(green('Notified XBMC'))
except:
pass

Expand Down
44 changes: 41 additions & 3 deletions nzbToAniDB.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,16 +3,38 @@
# Author: Benjamin Waller <benjamin@mycontact.eu>
# based on pyanidb

##############################################################################
### NZBGET POST-PROCESSING SCRIPT ###

# Anime renaming & sync with AniDB.net
#
# This script will rename Anime files after syncing with AniDB.
# Renaming can be done using AniDB or TheTVDB as source.
#
#
# NOTE: Edit "anidb.cfg" in your scripts folder to configure nzbToAniDB
#
#
# NOTE: This script requires Python to be installed on your system.

### NZBGET POST-PROCESSING SCRIPT ###
##############################################################################

import sys, os
import shlex, subprocess
try:
import ConfigParser
except ImportError:
import configparser as ConfigParser

if len(sys.argv) < 2:
# Exit codes used by NZBGet
POSTPROCESS_SUCCESS=93
POSTPROCESS_ERROR=94
POSTPROCESS_NONE=95

if len(sys.argv) < 2 and not 'NZBPP_DIRECTORY' in os.environ:
print "No folder supplied"
sys.exit()
sys.exit(1)
else:
config = {}
try:
Expand All @@ -23,12 +45,28 @@
except:
pass

command = sys.executable + " " + os.path.join(os.path.dirname(sys.argv[0]), "nzbToAniDB.libs", "anidb.py") + " " + config['nzbtoanidb_switches'] + " '" + sys.argv[1] + "'"
if 'NZBPP_DIRECTORY' in os.environ: #NZBGet
TargetPath=os.environ['NZBPP_DIRECTORY']
else: # SAB or manual
TargetPath=sys.argv[1]

if not os.path.exists(TargetPath):
print('Destination directory does not exist')
sys.exit(1)

command = sys.executable + " " + os.path.join(os.path.dirname(sys.argv[0]), "nzbToAniDB.libs", "anidb.py") + " " + config['nzbtoanidb_switches'] + " '" + TargetPath + "'"
if (os.name != "posix"):
args = shlex.split(command, posix=False)
else:
args = shlex.split(command)

retcode = subprocess.call(args)


if 'NZBPP_DIRECTORY' in os.environ: #NZBGet
if retcode == 0:
retcode = POSTPROCESS_SUCCESS
else:
retcode = POSTPROCESS_ERROR

sys.exit(retcode)

0 comments on commit 1126d6f

Please sign in to comment.