FIX: When retrieving a .torrent from a torrent provider (such as KAT), if the torrent was sent to the client but was unable to complete the send without an error (usually a 404), Mylar would stop searching - now will either log it and continue searching, or if Failed Handling is enabled will mark it as Failed and continue searching.

This commit is contained in:
evilhero 2014-10-13 15:49:55 -04:00
parent dadc4baec0
commit f55c6f22e0
2 changed files with 53 additions and 2 deletions

View File

@ -247,3 +247,40 @@ class FailedProcessor(object):
else:
logger.info(module + ' result has a status of ' + chk_fail['status'] + '. I am not sure what to do now.')
return "nope"
def markFailed(self):
#use this to forcibly mark a single issue as being Failed (ie. if a search result is sent to a client, but the result
#ends up passing in a 404 or something that makes it so that the download can't be initiated).
module = '[FAILED-DOWNLOAD]'
myDB = db.DBConnection()
logger.info(module + ' Marking as a Failed Download.')
logger.fdebug(module + 'nzb_name: ' + self.nzb_name)
logger.fdebug(module + 'issueid: ' + str(self.issueid))
logger.fdebug(module + 'nzb_id: ' + str(self.id))
logger.fdebug(module + 'prov: ' + self.prov)
if 'annual' in self.nzb_name.lower():
logger.info(module + ' Annual detected.')
annchk = "yes"
issuenzb = myDB.selectone("SELECT * from annuals WHERE IssueID=? AND ComicName NOT NULL", [self.issueid]).fetchone()
else:
issuenzb = myDB.selectone("SELECT * from issues WHERE IssueID=? AND ComicName NOT NULL", [self.issueid]).fetchone()
ctrlVal = {"IssueID": self.issueid}
Vals = {"Status": 'Failed'}
myDB.upsert("issues", Vals, ctrlVal)
ctrlVal = {"ID": self.id,
"Provider": self.prov,
"NZBName": self.nzb_name}
Vals = {"Status": 'Failed',
"ComicName": issuenzb['ComicName'],
"Issue_Number": issuenzb['Issue_Number']}
myDB.upsert("failed", Vals, ctrlVal)
logger.info(module + ' Successfully marked as Failed.')

View File

@ -1693,8 +1693,12 @@ def searcher(nzbprov, nzbname, comicinfo, link, IssueID, ComicID, tmpprov, direc
rcheck = rsscheck.torsend2client(ComicName, IssueNumber, comyear, link, nzbprov)
if rcheck == "fail":
logger.error("Unable to send torrent - check logs and settings.")
return "torrent-fail"
if mylar.FAILED_DOWNLOAD_HANDLING:
logger.error('Unable to send torrent to client. Assuming incomplete link - sending to Failed Handler and continuing search.')
return FailedMark(ComicID=ComicID, IssueID=IssueID, id=nzbid, nzbname=nzbname, prov=nzbprov)
else:
logger.error('Unable to send torrent - check logs and settings (this would be marked as a BAD torrent if Failed Handling was enabled)')
return "torrent-fail"
if mylar.TORRENT_LOCAL:
sent_to = "your local Watch folder"
else:
@ -1828,3 +1832,13 @@ def notify_snatch(nzbname, sent_to, modcomicname, comyear, IssueNumber, nzbprov)
pushbullet.notify(snline=snline,snatched=nzbname,sent_to=sent_to,prov=nzbprov)
return
def FailedMark(IssueID, ComicID, id, nzbname, prov):
# Used to pass a failed attempt at sending a download to a client, to the failed handler, and then back again to continue searching.
from mylar import Failed
FailProcess = Failed.FailedProcessor(issueid=IssueID, comicid=ComicID, id=id, nzb_name=nzbname, prov=prov)
Markit = FailProcess.markFailed()
return "torrent-fail"