mirror of https://github.com/evilhero/mylar
FIX: Searching was broken due to API changes.
This commit is contained in:
parent
e9485a0b23
commit
b4f76daf29
21
mylar/mb.py
21
mylar/mb.py
|
@ -28,11 +28,15 @@ mb_lock = threading.Lock()
|
|||
|
||||
|
||||
def pullsearch(comicapi,comicquery,offset):
|
||||
PULLURL='http://api.comicvine.com/search?api_key=' + str(comicapi) + '&resources=volume&query=' + str(comicquery) + '&field_list=id,name,start_year,site_detail_url,count_of_issues,image,publisher&format=xml&offset=' + str(offset)
|
||||
PULLURL='http://api.comicvine.com/search?api_key=' + str(comicapi) + '&resources=volume&query=' + str(comicquery) + '&field_list=id,name,start_year,site_detail_url,count_of_issues,image,publisher&format=xml&page=' + str(offset)
|
||||
|
||||
#all these imports are standard on most modern python implementations
|
||||
#download the file:
|
||||
file = urllib2.urlopen(PULLURL)
|
||||
try:
|
||||
file = urllib2.urlopen(PULLURL)
|
||||
except urllib2.HTTPError, err:
|
||||
logger.error("There was a major problem retrieving data from ComicVine - on their end. You'll have to try again later most likely.")
|
||||
return
|
||||
#convert to string:
|
||||
data = file.read()
|
||||
#close file because we dont need it anymore:
|
||||
|
@ -56,10 +60,11 @@ def findComic(name, mode, issue, limityear=None):
|
|||
|
||||
comicquery=name.replace(" ", "%20")
|
||||
comicapi='583939a3df0a25fc4e8b7a29934a13078002dc27'
|
||||
offset = 20
|
||||
offset = 1
|
||||
|
||||
#let's find out how many results we get from the query...
|
||||
searched = pullsearch(comicapi,comicquery,0)
|
||||
searched = pullsearch(comicapi,comicquery,1)
|
||||
if searched is None: return False
|
||||
totalResults = searched.getElementsByTagName('number_of_total_results')[0].firstChild.wholeText
|
||||
#print ("there are " + str(totalResults) + " search results...")
|
||||
if not totalResults:
|
||||
|
@ -68,7 +73,9 @@ def findComic(name, mode, issue, limityear=None):
|
|||
while (countResults < totalResults):
|
||||
#print ("querying " + str(countResults))
|
||||
if countResults > 0:
|
||||
searched = pullsearch(comicapi,comicquery,countResults)
|
||||
#new api - have to change to page # instead of offset count
|
||||
offsetcount = (countResults/100) + 1
|
||||
searched = pullsearch(comicapi,comicquery,offsetcount)
|
||||
comicResults = searched.getElementsByTagName('volume')
|
||||
body = ''
|
||||
n = 0
|
||||
|
@ -115,8 +122,8 @@ def findComic(name, mode, issue, limityear=None):
|
|||
else:
|
||||
print ("year: " + str(xmlYr) + " - contraint not met. Has to be within " + str(limityear))
|
||||
n+=1
|
||||
#search results are limited to 20/page...let's account for this.
|
||||
countResults = countResults + 20
|
||||
#search results are limited to 100 and by pagination now...let's account for this.
|
||||
countResults = countResults + 100
|
||||
|
||||
return comiclist
|
||||
|
||||
|
|
Loading…
Reference in New Issue