Added in NzbDrone support!

This commit is contained in:
echel0n 2014-04-07 03:48:12 -07:00
commit 6cc0d38483
3 changed files with 22 additions and 5 deletions

View file

@ -47,6 +47,7 @@
#### ndCategory - category that gets called for post-processing with NzbDrone
[[tv]]
enabled = 0
apikey =
host = localhost
port = 8989
username =

View file

@ -230,7 +230,7 @@ else:
result = 0
# init sub-sections
subsections = config.get_subsections(["SickBeard", "NzbDrone"])
subsections = config.get_subsections(["SickBeard"])
Logger.warn("MAIN: Invalid number of arguments received from client.")
for section, subsection in subsections.items():

View file

@ -1,4 +1,5 @@
import copy
import json
import logging
import os
import socket
@ -47,6 +48,11 @@ class autoProcessTV:
username = config()[section][inputCategory]["username"]
password = config()[section][inputCategory]["password"]
try:
apikey = config()[section][inputCategory]["apikey"]
except:
apikey = ""
try:
ssl = int(config()[section][inputCategory]["ssl"])
except:
@ -162,7 +168,7 @@ class autoProcessTV:
[fork_params.pop(k) for k,v in fork_params.items() if v is None]
if status == 0:
Logger.info("The download succeeded. Sending process request to SickBeard's %s branch", fork)
Logger.info("The download succeeded. Sending process request to %s", section)
elif fork in config.SICKBEARD_FAILED:
Logger.info("The download failed. Sending 'failed' process request to SickBeard's %s branch", fork)
else:
@ -184,17 +190,27 @@ class autoProcessTV:
else:
protocol = "http://"
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(fork_params)
url = None
if section == "SickBeard":
url = protocol + host + ":" + port + web_root + "/home/postprocess/processEpisode?" + urllib.urlencode(fork_params)
elif section == "NzbDrone":
url = protocol + host + ":" + port + web_root + "/api/command"
if clientAgent == "manual":delay = 0
Logger.info("Waiting for %s seconds to allow SB to process newly extracted files", str(delay))
Logger.info("Waiting for %s seconds to allow %s to process newly extracted files", str(delay), section)
time.sleep(delay)
Logger.debug("Opening URL: %s", url)
try:
r = requests.get(url, auth=(username, password), stream=True)
if section == "SickBeard":
r = requests.get(url, auth=(username, password), stream=True)
elif section == "NzbDrone":
data = json.dumps({"name": "DownloadedEpisodesScan", "path": dirName})
headers = {"X-Api-Key": apikey}
r = requests.get(url, data=data, headers=headers, stream=True)
except requests.ConnectionError:
Logger.exception("Unable to open URL")
return 1 # failure