mirror of
https://github.com/clinton-hall/nzbToMedia.git
synced 2025-08-21 05:43:16 -07:00
add report back to nzbget and dognzb/indexer. #531
This commit is contained in:
parent
f57b194162
commit
8a201e2489
4 changed files with 33 additions and 9 deletions
|
@ -499,7 +499,7 @@ from nzbtomedia.nzbToMediaUserScript import external_script
|
|||
from nzbtomedia import logger, nzbToMediaDB
|
||||
|
||||
# post-processing
|
||||
def process(inputDirectory, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None):
|
||||
def process(inputDirectory, inputName=None, status=0, clientAgent='manual', download_id=None, inputCategory=None, failureLink=None):
|
||||
if nzbtomedia.SAFE_MODE and inputDirectory == nzbtomedia.NZB_DEFAULTDIR:
|
||||
logger.error(
|
||||
'The input directory:[%s] is the Default Download Directory. Please configure category directories to prevent processing of other media.' % (
|
||||
|
@ -577,10 +577,10 @@ def process(inputDirectory, inputName=None, status=0, clientAgent='manual', down
|
|||
|
||||
if sectionName == "CouchPotato":
|
||||
result = autoProcessMovie().process(sectionName, inputDirectory, inputName, status, clientAgent, download_id,
|
||||
inputCategory)
|
||||
inputCategory, failureLink)
|
||||
elif sectionName in ["SickBeard", "NzbDrone"]:
|
||||
result = autoProcessTV().processEpisode(sectionName, inputDirectory, inputName, status, clientAgent,
|
||||
inputCategory)
|
||||
inputCategory, failureLink)
|
||||
elif sectionName == "HeadPhones":
|
||||
result = autoProcessMusic().process(sectionName, inputDirectory, inputName, status, clientAgent, inputCategory)
|
||||
elif sectionName == "Mylar":
|
||||
|
@ -670,7 +670,8 @@ def main(args, section=None):
|
|||
# All checks done, now launching the script.
|
||||
clientAgent = 'nzbget'
|
||||
result = process(os.environ['NZBPP_DIRECTORY'], inputName=os.environ['NZBPP_NZBNAME'], status=status,
|
||||
clientAgent=clientAgent, download_id=download_id, inputCategory=os.environ['NZBPP_CATEGORY'])
|
||||
clientAgent=clientAgent, download_id=download_id, inputCategory=os.environ['NZBPP_CATEGORY'],
|
||||
failureLink=os.environ.get('NZBPR__DNZB_FAILURE'))
|
||||
# SABnzbd Pre 0.7.17
|
||||
elif len(args) == nzbtomedia.SABNZB_NO_OF_ARGUMENTS:
|
||||
# SABnzbd argv:
|
||||
|
@ -699,7 +700,7 @@ def main(args, section=None):
|
|||
clientAgent = 'sabnzbd'
|
||||
logger.info("Script triggered from SABnzbd 0.7.17+")
|
||||
result = process(args[1], inputName=args[2], status=args[7], inputCategory=args[5], clientAgent=clientAgent,
|
||||
download_id='')
|
||||
download_id='', failureLink=args[8])
|
||||
else:
|
||||
# Perform Manual Post-Processing
|
||||
logger.warning("Invalid number of arguments received from client, Switching to manual run mode ...")
|
||||
|
|
|
@ -4,7 +4,7 @@ import requests
|
|||
import nzbtomedia
|
||||
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_download, listMediaFiles, remoteDir, import_subs, server_responding
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, rmDir, find_imdbid, find_download, listMediaFiles, remoteDir, import_subs, server_responding, reportNzb
|
||||
from nzbtomedia import logger
|
||||
from nzbtomedia.transcoder import transcoder
|
||||
|
||||
|
@ -97,7 +97,7 @@ class autoProcessMovie:
|
|||
|
||||
return results
|
||||
|
||||
def process(self, section, dirName, inputName=None, status=0, clientAgent="manual", download_id="", inputCategory=None):
|
||||
def process(self, section, dirName, inputName=None, status=0, clientAgent="manual", download_id="", inputCategory=None, failureLink=None):
|
||||
|
||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||
|
@ -189,6 +189,10 @@ class autoProcessMovie:
|
|||
status = 0
|
||||
elif num_files > 0 and good_files < num_files:
|
||||
logger.info("Status shown as success from Downloader, but corrupt video files found. Setting as failed.", section)
|
||||
if ('NZBNA_EVENT' in os.environ or 'NZBPP_DIRECTORY' in os.environ) and 'NZBOP_ARTICLECACHE' in os.environ:
|
||||
print('[NZB] MARK=BAD')
|
||||
if failureLink:
|
||||
failureLink = failureLink + '&corrupt=true'
|
||||
status = 1
|
||||
elif clientAgent == "manual":
|
||||
logger.warning("No media files found in directory %s to manually process." % (dirName), section)
|
||||
|
@ -246,6 +250,8 @@ class autoProcessMovie:
|
|||
|
||||
else:
|
||||
logger.postprocess("FAILED DOWNLOAD DETECTED FOR %s" % (inputName), section)
|
||||
if failureLink:
|
||||
reportNzb(failureLink)
|
||||
|
||||
if delete_failed and os.path.isdir(dirName) and not os.path.dirname(dirName) == dirName:
|
||||
logger.postprocess("Deleting failed files and folder %s" % dirName, section)
|
||||
|
|
|
@ -8,7 +8,7 @@ import nzbtomedia
|
|||
|
||||
from nzbtomedia.nzbToMediaAutoFork import autoFork
|
||||
from nzbtomedia.nzbToMediaSceneExceptions import process_all_exceptions
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles, remoteDir, import_subs, server_responding
|
||||
from nzbtomedia.nzbToMediaUtil import convert_to_ascii, flatten, rmDir, listMediaFiles, remoteDir, import_subs, server_responding, reportNzb
|
||||
from nzbtomedia import logger
|
||||
from nzbtomedia.transcoder import transcoder
|
||||
|
||||
|
@ -31,7 +31,7 @@ class autoProcessTV:
|
|||
pass
|
||||
return missing
|
||||
|
||||
def processEpisode(self, section, dirName, inputName=None, failed=False, clientAgent = "manual", inputCategory=None):
|
||||
def processEpisode(self, section, dirName, inputName=None, failed=False, clientAgent = "manual", inputCategory=None, failureLink=None):
|
||||
host = nzbtomedia.CFG[section][inputCategory]["host"]
|
||||
port = nzbtomedia.CFG[section][inputCategory]["port"]
|
||||
try:
|
||||
|
@ -130,6 +130,10 @@ class autoProcessTV:
|
|||
logger.info('Found corrupt videos. Setting status Failed')
|
||||
status = 1
|
||||
failed = 1
|
||||
if ('NZBNA_EVENT' in os.environ or 'NZBPP_DIRECTORY' in os.environ) and 'NZBOP_ARTICLECACHE' in os.environ:
|
||||
print('[NZB] MARK=BAD')
|
||||
if failureLink:
|
||||
failureLink = failureLink + '&corrupt=true'
|
||||
elif clientAgent == "manual" and not listMediaFiles(dirName, media=True, audio=False, meta=False, archives=True):
|
||||
logger.warning("No media files found in directory %s to manually process." % (dirName), section)
|
||||
return [0, ""] # Success (as far as this script is concerned)
|
||||
|
@ -200,6 +204,8 @@ class autoProcessTV:
|
|||
if status == 0:
|
||||
logger.postprocess("SUCCESS: The download succeeded, sending a post-process request", section)
|
||||
else:
|
||||
if failureLink:
|
||||
reportNzb(failureLink)
|
||||
if fork in nzbtomedia.SICKBEARD_FAILED or section == "NzbDrone":
|
||||
logger.postprocess("FAILED: The download failed. Sending 'failed' process request to %s branch" % (fork), section)
|
||||
else:
|
||||
|
|
|
@ -22,6 +22,17 @@ from nzbtomedia.utorrent.client import UTorrentClient
|
|||
from nzbtomedia.transmissionrpc.client import Client as TransmissionClient
|
||||
from nzbtomedia import logger, nzbToMediaDB
|
||||
|
||||
def reportNzb(failure_link):
|
||||
# Contact indexer site
|
||||
logger.info("Sending failure notification to indexer site")
|
||||
headers = None
|
||||
try:
|
||||
headers = {'User-Agent' : 'NZBGet / nzbToMedia.py'}
|
||||
r = requests.post(failure_link, headers=headers)
|
||||
except requests.ConnectionError:
|
||||
logger.error("Unable to open URL %s" % failure_link)
|
||||
return
|
||||
|
||||
def sanitizeName(name):
|
||||
'''
|
||||
>>> sanitizeName('a/b/c')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue