More code tweaks for autoProcessMusic and autoProcessMovie relating to checking of release statuses

This commit is contained in:
echel0n 2014-04-14 10:15:03 -07:00
commit df6e85467a
2 changed files with 22 additions and 26 deletions

View file

@ -152,6 +152,15 @@ class autoProcessMovie:
media_id, download_id, release_id, release_status = self.find_release_info(baseURL, download_id, dirName, nzbName)
if release_status:
if release_status != "snatched":
logger.warning("%s is marked with a status of %s on CouchPotato, skipping ...", nzbName, release_status)
return 0
else:
if clientAgent != 'manual':
logger.error("Could not find a status for %s on CouchPotato, skipping ...", nzbName)
return 1
process_all_exceptions(nzbName.lower(), dirName)
nzbName, dirName = convert_to_ascii(nzbName, dirName)
@ -237,11 +246,7 @@ class autoProcessMovie:
timeout = time.time() + 60 * int(wait_for)
while (time.time() < timeout): # only wait 2 (default) minutes, then return.
current_status = self.get_status(baseURL, media_id, release_id)
if current_status is None:
logger.error("Could not find a current status for %s on CouchPotatoServer", nzbName)
return 1
if current_status != release_status: # Something has changed. CPS must have processed this movie.
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 CouchPotatoServer", current_status.upper())
return 0 # success

View file

@ -9,8 +9,6 @@ from nzbtomedia import logger
class autoProcessMusic:
def get_status(self, baseURL, apikey, dirName):
release_status = None
logger.debug("Attempting to get current status for release:%s", os.path.basename(dirName))
url = baseURL
@ -31,11 +29,8 @@ class autoProcessMusic:
result = r.json()
for album in result:
if os.path.basename(dirName) == album['FolderName']:
release_status = album["Status"]
except:
pass
return release_status
return album["Status"].lower()
except:pass
def process(self, dirName, nzbName=None, status=0, clientAgent="manual", inputCategory=None):
if dirName is None:
@ -89,9 +84,13 @@ class autoProcessMusic:
release_status = self.get_status(url, apikey, dirName)
if release_status not in ["Unprocessed", "Snatched"]:
logger.error("%s is marked with a status of %s on HeadPhones, skipping ...", nzbName, release_status)
return 0
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)
return 0
else:
logger.error("Could not find a status for %s on HeadPhones", nzbName)
return 1
logger.debug("Opening URL: %s", url)
@ -112,21 +111,13 @@ class autoProcessMusic:
logger.postprocess("The download failed. Nothing to process")
return 0 # Success (as far as this script is concerned)
if release_status is None:
logger.error("Could not find a current status for %s on HeadPhones", nzbName)
return 1
# we will now wait 1 minutes for this album to be processed before returning to TorrentToMedia and unpausing.
timeout = time.time() + 60 * 2
while (time.time() < timeout): # only wait 2 (default) minutes, then return.
current_status = self.get_status(url, apikey, dirName)
if current_status is None:
logger.error("Could not find a current status for %s on HeadPhones", nzbName)
return 1
if 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.upper())
return 0 # success
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)
return 0
time.sleep(10 * 2)