Fix: for endless downloading when Experimental Search was enabled.

This commit is contained in:
evilhero 2013-01-02 12:56:46 -05:00
parent f977bb3d87
commit 0035046379
3 changed files with 31 additions and 77 deletions

View File

@ -5,6 +5,7 @@ import sys
import lib.feedparser as feedparser
#import feedparser
import re
import logger
def Startit(searchName, searchIssue, searchYear):
#searchName = "Uncanny Avengers"
@ -12,12 +13,9 @@ def Startit(searchName, searchIssue, searchYear):
#searchYear = "2012"
#clean up searchName due to webparse.
searchName = searchName.replace("%20", " ")
print "name:"+searchName
print "issue:"+searchIssue
print "year:"+searchYear
# searchName = input("Enter a Title: ")
# searchIssue =input("Enter an Issue #: ")
# searchYear = input("Enter a year: ")
logger.fdebug("name:" + str(searchName))
logger.fdebug("issue:" + str(searchIssue))
logger.fdebug("year:" + str(searchYear))
splitSearch = searchName.split(" ")
joinSearch = "+".join(splitSearch)+"+"+searchIssue
searchIsOne = "0"+searchIssue
@ -34,7 +32,7 @@ def Startit(searchName, searchIssue, searchYear):
mres = {}
countUp = 0
print (str(totNum))+" results"
logger.fdebug(str(totNum) + " results")
while countUp < totNum:
urlParse = feed.entries[countUp].enclosures[0]
@ -58,18 +56,18 @@ def Startit(searchName, searchIssue, searchYear):
splitTitle = title.split("\"")
for subs in splitTitle:
print("looking at: " + str(subs))
logger.fdebug("looking at: " + str(subs))
regEx = re.findall("\\b%s\\b\\s*\\b%s\\b\\s*[(]\\b%s\\b[)]" %(searchName, searchIssue, searchYear), subs, flags=re.IGNORECASE)
regExOne = re.findall("\\b%s\\b\\s*\\b%s\\b\\s*[(]\\b%s\\b[)]" %(searchName, searchIsOne, searchYear), subs, flags=re.IGNORECASE)
regExTwo = re.findall("\\b%s\\b\\s*\\b%s\\b\\s*[(]\\b%s\\b[)]" %(searchName, searchIsTwo, searchYear), subs, flags=re.IGNORECASE)
#print("regex: " + str(regEx))
if regEx or regExOne or regExTwo:
print("name: " + str(title))
print("sub: " + str(subs))
print("-----")
print("url: " + str(link))
print("-----")
logger.fdebug("name: " + str(title))
logger.fdebug("sub: " + str(subs))
logger.fdebug("-----")
logger.fdebug("url: " + str(link))
logger.fdebug("-----")
#regList.append(title)
#regList.append(subs)
entries.append({
@ -83,7 +81,7 @@ def Startit(searchName, searchIssue, searchYear):
# print("Title: "+regList[0])
# print("Link: "+keyPair[regList[0]])
else:
print("No Results Found")
logger.fdebug("No Results Found")
return "no results"

View File

@ -95,23 +95,13 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID, newznab_host)
if findit == 'yes':
logger.fdebug("findit = found!")
continue
break
else:
if AlternateSearch is not None:
logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + " " + str(ComicYear))
findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID, newznab_host)
if findit == 'yes':
break
# if IssDateFix == "yes":
# logger.info(u"Hang on - this issue was published between Nov/Dec of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
# findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID, newznab_host)
# if findit == 'yes':
# break
# elif AlternateSearch is not None:
# logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + " " + str(ComicYearFix))
# findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID, newznab_host)
# if findit == 'yes':
# break
nzbpr-=1
@ -121,53 +111,29 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
if findit == 'yes':
logger.fdebug("findit = found!")
continue
break
else:
if AlternateSearch is not None:
logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + str(ComicYear))
findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
if findit == 'yes':
break
# if IssDateFix == "yes":
# logger.info(u"Hang on - this issue was published between Nov/Dec of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
# findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
# if findit == 'yes':
# break
# elif AlternateSearch is not None:
# logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + str(ComicYearFix))
# findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
# if findit == 'yes':
# break
nzbpr-=1
elif nzbprovider[nzbpr] == 'nzb.su':
# ----
# this is for nzb.su
#d = feedparser.parse("http://nzb.su/rss?t=7030&dl=1&i=" + str(nzbsu_APIID) + "&r=" + str(nzbsu_APIkey))
#--LATER ?search.rss_find = RSS_SEARCH(ComicName, IssueNumber)
#if rss_find == 0:
nzbprov = 'nzb.su'
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
if findit == 'yes':
logger.fdebug("findit = found!")
continue
break
else:
if AlternateSearch is not None:
logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + str(ComicYear))
findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
if findit == 'yes':
break
#if IssDateFix == "yes":
# logger.info(u"Hang on - this issue was published between Nov/Dec of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
# findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
# if findit == 'yes':
# break
# elif AlternateSearch is not None:
# logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + str(ComicYearFix))
# findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
# if findit == 'yes':
# break
nzbpr-=1
@ -175,30 +141,18 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI
elif nzbprovider[nzbpr] == 'dognzb':
# this is for dognzb.com
#d = feedparser.parse("http://dognzb.cr/rss.cfm?r=" + str(dognzb_APIkey) + "&t=7030&num=100")
#RSS_SEARCH(ComicName, IssueNumber)
nzbprov = 'dognzb'
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
if findit == 'yes':
logger.fdebug("findit = found!")
continue
break
else:
if AlternateSearch is not None:
logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + str(ComicYear))
findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
if findit == 'yes':
break
#if IssDateFix == "yes":
# logger.info(u"Hang on - this issue was published between Nov/Dec of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
# findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
# if findit == 'yes':
# break
# elif AlternateSearch is not None:
# logger.info(u"Alternate Search pattern detected...re-adjusting to : " + str(AlternateSearch) + str(ComicYearFix))
# findit = NZB_SEARCH(AlternateSearch, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix, IssueID)
# if findit == 'yes':
# break
nzbpr-=1
@ -720,7 +674,8 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
logger.fdebug("Found matching comic...preparing to send to Updater with IssueID: " + str(IssueID) + " and nzbname: " + str(nzbname))
updater.nzblog(IssueID, nzbname)
nzbpr == 0
break
#break
return foundc
elif foundc == "no" and nzbpr == 0:
foundcomic.append("no")
logger.fdebug("couldn't find a matching comic")

View File

@ -230,7 +230,7 @@ def forceRescan(ComicID):
fcnew[som] = fcnew[som].replace(".cbr", "")
elif ".cbz" in fcnew[som]:
fcnew[som] = fcnew[som].replace(".cbz", "")
elif fcnew[som].isdigit():
if fcnew[som].isdigit():
#this won't match on decimal issues - need to fix.
#print ("digit detected")
if int(fcnew[som]) > 0:
@ -248,18 +248,19 @@ def forceRescan(ComicID):
isschk_b4dec = IssueChk[:isschk_find]
isschk_decval = IssueChk[isschk_find+1:]
if isschk_b4dec.isdigit():
logger.fdebug("digit detected prior to decimal.")
#logger.fdebug("digit detected prior to decimal.")
if isschk_decval.isdigit():
logger.fdebug("digit detected after decimal.")
pass
#logger.fdebug("digit detected after decimal.")
else:
logger.fdebug("not an issue - no digit detected after decimal")
#logger.fdebug("not an issue - no digit detected after decimal")
continue
else:
logger.fdebug("not an issue - no digit detected prior to decimal")
#logger.fdebug("not an issue - no digit detected prior to decimal")
continue
logger.fdebug("IssueNumber: " + str(IssueChk))
logger.fdebug("..before decimal: " + str(isschk_b4dec))
logger.fdebug("...after decimal: " + str(isschk_decval))
#logger.fdebug("IssueNumber: " + str(IssueChk))
#logger.fdebug("..before decimal: " + str(isschk_b4dec))
#logger.fdebug("...after decimal: " + str(isschk_decval))
#--let's make sure we don't wipe out decimal issues ;)
if int(isschk_decval) == 0:
iss = isschk_b4dec
@ -272,10 +273,10 @@ def forceRescan(ComicID):
iss = isschk_b4dec + "." + isschk_decval.rstrip('0')
intdec = int(isschk_decval.rstrip('0')) * 10
fcdigit = (int(isschk_b4dec) * 1000) + intdec
logger.fdebug("b4dec: " + str(isschk_b4dec))
logger.fdebug("decval: " + str(isschk_decval))
logger.fdebug("intdec: " + str(intdec))
logger.fdebug("let's compare with this issue value: " + str(fcdigit))
#logger.fdebug("b4dec: " + str(isschk_b4dec))
#logger.fdebug("decval: " + str(isschk_decval))
#logger.fdebug("intdec: " + str(intdec))
#logger.fdebug("let's compare with this issue value: " + str(fcdigit))
else:
# it's a word, skip it.
fcdigit = 1000000