will now search for issues published in December, but dated in next year...also added some extra info to ComicRN.py

This commit is contained in:
evilhero 2012-10-09 02:33:14 -04:00
parent a9936d4f70
commit 4c348c2f6b
3 changed files with 55 additions and 21 deletions

View File

@ -36,7 +36,7 @@ import urllib2
from datetime import datetime
def search_init(ComicName, IssueNumber, ComicYear, SeriesYear):
def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate):
if ComicYear == None: ComicYear = '2012'
else: ComicYear = str(ComicYear)[:4]
##nzb provider selection##
@ -57,15 +57,29 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear):
# --------
nzbpr = nzbp-1
findit = 'no'
#fix for issue dates between Dec/Jan
IssDt = str(IssueDate)[5:7]
if IssDt == "12":
ComicYearFix = str(int(ComicYear) + 1)
IssDateFix = "yes"
else:
IssDateFix = "no"
while (nzbpr >= 0 ):
if nzbprovider[nzbpr] == 'experimental':
#this is for experimental
nzbprov = 'experimental'
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr)
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix)
if findit == 'yes':
break
else:
nzbpr-=1
if IssDateFix == "yes":
logger.info(u"Hang on - this issue was published between Dec/Jan of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix)
if findit == 'yes':
break
nzbpr-=1
if nzbprovider[nzbpr] == 'nzb.su':
# ----
@ -74,11 +88,17 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear):
#--LATER ?search.rss_find = RSS_SEARCH(ComicName, IssueNumber)
#if rss_find == 0:
nzbprov = 'nzb.su'
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr)
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix)
if findit == 'yes':
break
else:
nzbpr-=1
if IssDateFix == "yes":
logger.info(u"Hang on - this issue was published between Dec/Jan of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix)
if findit == 'yes':
break
nzbpr-=1
# ----
elif nzbprovider[nzbpr] == 'dognzb':
@ -86,11 +106,17 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear):
#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)
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix)
if findit == 'yes':
break
else:
nzbpr-=1
if IssDateFix == "yes":
logger.info(u"Hang on - this issue was published between Dec/Jan of " + str(ComicYear) + "...adjusting to " + str(ComicYearFix) + " and retrying...")
findit = NZB_SEARCH(ComicName, IssueNumber, ComicYearFix, SeriesYear, nzbprov, nzbpr, IssDateFix)
if findit == 'yes':
break
nzbpr-=1
# ----
return findit
@ -155,7 +181,7 @@ def RSS_Search(ComicName, IssueNumber):
print ("snatched " + str(ssabcount) + " out of " + str(tot) + " comics via rss...")
return ssabcount
def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, IssDateFix):
logger.info(u"Shhh be very quiet...I'm looking for " + ComicName + " issue: " + str(IssueNumber) + " using " + str(nzbprov))
if nzbprov == 'nzb.su':
apikey = mylar.NZBSU_APIKEY
@ -392,7 +418,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
else:
#let's make the dir.
try:
os.makedirs(str(mylar.CACHE_DIR))
os.makedirs(str(mylar.CACHE_DIR))
logger.info(u"Cache Directory successfully created at: " + str(mylar.CACHE_DIR))
savefile = str(mylar.CACHE_DIR) + "/" + str(filenzb) + ".nzb"
@ -539,8 +565,9 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr):
logger.info(u"More than one search provider given - trying next one.")
elif foundc == "no" and nzbpr == 0:
foundcomic.append("no")
logger.info(u"Couldn't find Issue " + str(IssueNumber) + " of " + str(ComicName) + "(" + str(comyear) + "). Status kept as wanted." )
break
if IssDateFix == "no":
logger.info(u"Couldn't find Issue " + str(IssueNumber) + " of " + str(ComicName) + "(" + str(comyear) + "). Status kept as wanted." )
break
return foundc
def searchforissue(issueid=None, new=False):
@ -558,13 +585,14 @@ def searchforissue(issueid=None, new=False):
comic = myDB.action('SELECT * from comics WHERE ComicID=?', [result['ComicID']]).fetchone()
foundNZB = "none"
SeriesYear = comic['ComicYear']
IssueDate = result['IssueDate']
if result['IssueDate'] == None:
ComicYear = comic['ComicYear']
else:
ComicYear = str(result['IssueDate'])[:4]
if (mylar.NZBSU or mylar.DOGNZB or mylar.EXPERIMENTAL) and (mylar.SAB_HOST):
foundNZB = search_init(result['ComicName'], result['Issue_Number'], str(ComicYear), comic['ComicYear'])
foundNZB = search_init(result['ComicName'], result['Issue_Number'], str(ComicYear), comic['ComicYear'], IssueDate)
if foundNZB == "yes":
#print ("found!")
updater.foundsearch(result['ComicID'], result['IssueID'])
@ -576,6 +604,7 @@ def searchforissue(issueid=None, new=False):
ComicID = result['ComicID']
comic = myDB.action('SELECT * FROM comics where ComicID=?', [ComicID]).fetchone()
SeriesYear = comic['ComicYear']
IssueDate = result['IssueDate']
if result['IssueDate'] == None:
IssueYear = comic['ComicYear']
else:
@ -583,7 +612,7 @@ def searchforissue(issueid=None, new=False):
foundNZB = "none"
if (mylar.NZBSU or mylar.DOGNZB or mylar.EXPERIMENTAL) and (mylar.SAB_HOST):
foundNZB = search_init(result['ComicName'], result['Issue_Number'], str(IssueYear), comic['ComicYear'])
foundNZB = search_init(result['ComicName'], result['Issue_Number'], str(IssueYear), comic['ComicYear'], IssueDate)
if foundNZB == "yes":
#print ("found!")
updater.foundsearch(ComicID=result['ComicID'], IssueID=result['IssueID'])

View File

@ -156,10 +156,10 @@ class WebInterface(object):
myDB.upsert("issues", newValueDict, controlValueDict)
if action == 'Skipped': pass
elif action == 'Wanted':
foundcoms = search.search_init(mi['ComicName'], mi['Issue_Number'], mi['IssueDate'][:4], miyr['ComicYear'])
foundcoms = search.search_init(mi['ComicName'], mi['Issue_Number'], mi['IssueDate'][:4], miyr['ComicYear'], mi['IssueDate'])
#searcher.searchforissue(mbid, new=False)
elif action == 'WantedNew':
foundcoms = search.search_init(mi['ComicName'], mi['Issue_Number'], mi['IssueDate'][:4], miyr['ComicYear'])
foundcoms = search.search_init(mi['ComicName'], mi['Issue_Number'], mi['IssueDate'][:4], miyr['ComicYear'], mi['IssueDate'])
#searcher.searchforissue(mbid, new=True)
if foundcoms == "yes":
logger.info(u"Found " + mi['ComicName'] + " issue: " + mi['Issue_Number'] + " ! Marking as Snatched...")
@ -212,7 +212,7 @@ class WebInterface(object):
ComicYear = str(cyear['SHIPDATE'])[:4]
if ComicYear == '': ComicYear = "2012"
logger.info(u"Marking " + ComicName + " " + ComicIssue + " as wanted...")
foundcom = search.search_init(ComicName, ComicIssue, ComicYear, SeriesYear=None)
foundcom = search.search_init(ComicName, ComicIssue, ComicYear, SeriesYear=None, cyear['SHIPDATE'])
if foundcom == "yes":
logger.info(u"Downloaded " + ComicName + " " + ComicIssue )
return
@ -227,12 +227,12 @@ class WebInterface(object):
newStatus = {"Status": "Wanted"}
myDB.upsert("issues", newStatus, controlValueDict)
#for future reference, the year should default to current year (.datetime)
issues = myDB.action("SELECT IssueDate FROM issues WHERE IssueID=?", [IssueID]).fetchone()
if ComicYear == None:
issues = myDB.action("SELECT IssueDate FROM issues WHERE IssueID=?", [IssueID]).fetchone()
ComicYear = str(issues['IssueDate'])[:4]
miyr = myDB.action("SELECT ComicYear FROM comics WHERE ComicID=?", [ComicID]).fetchone()
SeriesYear = miyr['ComicYear']
foundcom = search.search_init(ComicName, ComicIssue, ComicYear, SeriesYear)
foundcom = search.search_init(ComicName, ComicIssue, ComicYear, SeriesYear, issues['IssueDate'])
#print ("foundcom:" + str(foundcom))
if foundcom == "yes":
# file check to see if issue exists and update 'have' count

View File

@ -15,9 +15,11 @@
# directory of your SABnzbd install.
# In SABnzbd:
# create a category - call it whatever you want (ie.Comics).
# point the default dir to wherever you want - but make sure it is identical
# to the "Path to root of Comics directory" indicated in CONFIG below.
# Create a category - call it whatever you want (ie.Comics).
# Point the default dir to wherever you want - but make sure it is identical
# to the Mylar - "Comic Location" as indicated in the comdir CONFIG option
# below. Not doing this will mean that downloads that this script processed
# probably won't get marked as being present in Mylar.
# In Mylar:
# Sabnzbd tab (in the Configuration):
@ -234,10 +236,13 @@ for root, dirnames, filenames in os.walk(maindir):
if maindir is not "/" or maindir is not comdir:
shutil.rmtree(maindir)
print ("Removed useless directory: " + maindir)
print ("Result: Completed")
else:
print ("incorrect directory passed to Removal: " + maindir)
print ("Result: FAIL - incorrect directory.")
else:
print ("Could not find a match for : " + str(comyx) )
print ("I compared it to : " + str(confile) )
print ("Result: FAIL - could not locate comic")
countit+=1