Added ability to post-processing folders for HeadPhones via thier API, to use this feature HeadPhones needs to support sending folder names to there API for post processing, echel0n already has a fork of HeadPhones that does this at http://github.com/echel0n/HeadPhones

This commit is contained in:
echel0n 2014-04-07 09:33:50 -07:00
commit 3c5e46c212

View file

@ -2,6 +2,7 @@ import time
import datetime import datetime
import logging import logging
import socket import socket
import urllib
from lib import requests from lib import requests
from nzbtomedia.nzbToMediaConfig import config from nzbtomedia.nzbToMediaConfig import config
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, getDirectorySize from nzbtomedia.nzbToMediaUtil import convert_to_ascii, getDirectorySize
@ -60,12 +61,16 @@ class autoProcessMusic:
TIME_OUT += 60 # Add an extra minute for over-head/processing/metadata. TIME_OUT += 60 # Add an extra minute for over-head/processing/metadata.
socket.setdefaulttimeout(int(TIME_OUT)) #initialize socket timeout. socket.setdefaulttimeout(int(TIME_OUT)) #initialize socket timeout.
baseURL = protocol + host + ":" + port + web_root + "/api?apikey=" + apikey + "&cmd=" baseURL = protocol + host + ":" + port + web_root + "/api?"
if status == 0: if status == 0:
command = "forceProcess"
url = baseURL + command params = {}
params['apikey'] = apikey
params['cmd'] = "forceProcess"
params['dir'] = dirName
url = baseURL + + urllib.urlencode(params)
Logger.info("Waiting for %s seconds to allow HeadPhones to process newly extracted files", str(delay)) Logger.info("Waiting for %s seconds to allow HeadPhones to process newly extracted files", str(delay))
@ -81,9 +86,9 @@ class autoProcessMusic:
Logger.info("HeadPhones returned %s", r.text) Logger.info("HeadPhones returned %s", r.text)
if r.text == "OK": if r.text == "OK":
Logger.info("%s started on HeadPhones for %s", command, nzbName) Logger.info("Post-processing started on HeadPhones for %s in folder %s", nzbName, dirName)
else: else:
Logger.error("%s has NOT started on HeadPhones for %s. Exiting", command, nzbName) Logger.error("Post-proecssing has NOT started on HeadPhones for %s in folder %s. Exiting", nzbName, dirName)
return 1 # failure return 1 # failure
else: else: