forked from mdhiggins/sickbeard_mp4_automator
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Michael Higginis
committed
Jan 31, 2017
1 parent
b277362
commit 730ddc3
Showing
7 changed files
with
131 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import sys | ||
import os | ||
import logging | ||
import json | ||
|
||
|
||
def processMovie(dirName, settings, nzbGet=False, logger=None): | ||
|
||
if nzbGet: | ||
errorprefix = "[ERROR] " | ||
infoprefix = "[INFO] " | ||
else: | ||
errorprefix = "" | ||
infoprefix = "" | ||
|
||
# Setup logging | ||
if logger: | ||
log = logger | ||
else: | ||
log = logging.getLogger(__name__) | ||
|
||
log.info("%sRadarr notifier started." % infoprefix) | ||
|
||
# Import Requests | ||
try: | ||
import requests | ||
except ImportError: | ||
log.exception("%sPython module REQUESTS is required. Install with 'pip install requests' then try again." % errorprefix) | ||
log.error("%sPython executable path is %s" % (errorprefix, sys.executable)) | ||
return False | ||
|
||
host = settings.Radarr['host'] | ||
port = settings.Radarr['port'] | ||
apikey = settings.Radarr['apikey'] | ||
|
||
if apikey == '': | ||
log.error("%sYour Radarr API Key can not be blank. Update autoProcess.ini." % errorprefix) | ||
return False | ||
|
||
try: | ||
ssl = int(settings.Radarr['ssl']) | ||
except: | ||
ssl = 0 | ||
if ssl: | ||
protocol = "https://" | ||
else: | ||
protocol = "http://" | ||
|
||
url = protocol + host + ":" + port + "/api/command" | ||
payload = {'name': 'downloadedepisodesscan', 'path': dirName} | ||
headers = {'X-Api-Key': apikey} | ||
|
||
log.debug("Radarr host: %s." % host) | ||
log.debug("Radarr port: %s." % port) | ||
log.debug("Radarr apikey: %s." % apikey) | ||
log.debug("Radarr protocol: %s." % protocol) | ||
log.debug("URL '%s' with payload '%s.'" % (url, payload)) | ||
|
||
log.info("%sRequesting Radarr to scan directory '%s'." % (infoprefix, dirName)) | ||
|
||
try: | ||
r = requests.post(url, data=json.dumps(payload), headers=headers) | ||
rstate = r.json() | ||
log.info("%sRadarr response: %s." % (infoprefix, rstate['state'])) | ||
return True | ||
except: | ||
log.exception("%sUpdate to Radarr failed, check if Radarr is running, autoProcess.ini settings and make sure your Radarr settings are correct (apikey?), or check install of python modules requests." % errorprefix) | ||
return False |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters