mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-20 13:23:18 -07:00
Updated logger code to now include the section, formatting has been modified as well.
Logging of debug messages is now optional via log_debug option location in autoProcessMedia.cfg Lots of code cleanup has been performed including cleanup log messages and corrections of spelling errors. Improved release lookup code for autoProcessMovie, narrows search results down by making API calls to the download clients to compare results in CouchPotato's database.
This commit is contained in:
parent
dd41ff3b2f
commit
eb7822b60b
16 changed files with 420 additions and 441 deletions
|
@ -7,7 +7,7 @@ from nzbtomedia import logger
|
|||
|
||||
class autoProcessMusic:
|
||||
def get_status(self, baseURL, apikey, dirName):
|
||||
logger.debug("Attempting to get current status for release:%s", os.path.basename(dirName))
|
||||
logger.debug("Attempting to get current status for release:%s" % (os.path.basename(dirName)))
|
||||
|
||||
url = baseURL
|
||||
|
||||
|
@ -15,7 +15,7 @@ class autoProcessMusic:
|
|||
params['apikey'] = apikey
|
||||
params['cmd'] = "getHistory"
|
||||
|
||||
logger.debug("Opening URL: %s", url)
|
||||
logger.debug("Opening URL: %s" % (url))
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params)
|
||||
|
@ -31,21 +31,13 @@ class autoProcessMusic:
|
|||
except:pass
|
||||
|
||||
def process(self, dirName, nzbName=None, status=0, clientAgent="manual", inputCategory=None):
|
||||
if dirName is None:
|
||||
logger.error("No directory was given!")
|
||||
return 1 # failure
|
||||
|
||||
# auto-detect correct section
|
||||
section = nzbtomedia.CFG.findsection(inputCategory)
|
||||
if len(section) == 0:
|
||||
logger.error(
|
||||
"We were unable to find a section for category %s, please check your autoProcessMedia.cfg file.", inputCategory)
|
||||
"We were unable to find a section for category %s, please check your autoProcessMedia.cfg file." % (inputCategory))
|
||||
return 1
|
||||
|
||||
logger.postprocess("#########################################################")
|
||||
logger.postprocess("## ..::[%s]::.. :: CATEGORY:[%s]", section, inputCategory)
|
||||
logger.postprocess("#########################################################")
|
||||
|
||||
status = int(status)
|
||||
|
||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||
|
@ -92,29 +84,29 @@ class autoProcessMusic:
|
|||
|
||||
if release_status:
|
||||
if release_status not in ["unprocessed", "snatched"]:
|
||||
logger.warning("%s is marked with a status of %s on HeadPhones, skipping ...", nzbName, release_status)
|
||||
logger.warning("%s is marked with a status of %s, skipping ..." % (nzbName, release_status),section)
|
||||
return 0
|
||||
else:
|
||||
logger.error("Could not find a status for %s on HeadPhones", nzbName)
|
||||
logger.error("Could not find a status for %s" % (nzbName),section)
|
||||
return 1
|
||||
|
||||
logger.debug("Opening URL: %s", url)
|
||||
logger.debug("Opening URL: %s" % (url),section)
|
||||
|
||||
try:
|
||||
r = requests.get(url, params=params)
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL")
|
||||
logger.error("Unable to open URL %s" % (url),section)
|
||||
return 1 # failure
|
||||
|
||||
logger.postprocess("HeadPhones returned %s", r.text)
|
||||
logger.debug("Result: %s" % (r.text),section)
|
||||
if r.text == "OK":
|
||||
logger.postprocess("Post-processing started on HeadPhones for %s in folder %s", nzbName, dirName)
|
||||
logger.postprocess("SUCCESS: Post-Processing started for %s in folder %s ..." % (nzbName, dirName),section)
|
||||
else:
|
||||
logger.error("Post-proecssing has NOT started on HeadPhones for %s in folder %s. Exiting", nzbName, dirName)
|
||||
logger.error("FAILED: Post-Processing has NOT started for %s in folder %s. exiting!" % (nzbName, dirName),section)
|
||||
return 1 # failure
|
||||
|
||||
else:
|
||||
logger.postprocess("The download failed. Nothing to process")
|
||||
logger.warning("FAILED DOWNLOAD DETECTED", section)
|
||||
return 0 # Success (as far as this script is concerned)
|
||||
|
||||
# we will now wait 1 minutes for this album to be processed before returning to TorrentToMedia and unpausing.
|
||||
|
@ -122,11 +114,11 @@ class autoProcessMusic:
|
|||
while (time.time() < timeout): # only wait 2 (default) minutes, then return.
|
||||
current_status = self.get_status(url, apikey, dirName)
|
||||
if current_status is not None and current_status != release_status: # Something has changed. CPS must have processed this movie.
|
||||
logger.postprocess("SUCCESS: This release is now marked as status [%s] in HeadPhones",current_status)
|
||||
logger.postprocess("SUCCESS: This release is now marked as status [%s]" % (current_status),section)
|
||||
return 0
|
||||
|
||||
time.sleep(10 * wait_for)
|
||||
|
||||
# The status hasn't changed. we have waited 2 minutes which is more than enough. uTorrent can resule seeding now.
|
||||
logger.warning("The music album does not appear to have changed status after %s minutes. Please check HeadPhones Logs",2)
|
||||
logger.warning("The music album does not appear to have changed status after %s minutes. Please check your Logs" % (wait_for))
|
||||
return 1 # failure
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue