mirror of https://github.com/evilhero/mylar
FIX: Ongoing Limited Series wouldn't have status of Continuing and wouldn't get marked on weekly pull list (ie.Alpha:Big Time), IMP: Comic Volume is now autopopulated (v2,v3,etc) - can also be edited
This commit is contained in:
parent
b290be3d47
commit
fad92c7745
|
@ -73,7 +73,7 @@
|
||||||
<td id="status">
|
<td id="status">
|
||||||
%if comic['ComicPublished'] is None or comic['ComicPublished'] == '':
|
%if comic['ComicPublished'] is None or comic['ComicPublished'] == '':
|
||||||
Unknown
|
Unknown
|
||||||
%elif 'present' in comic['ComicPublished'].lower():
|
%elif 'present' in comic['ComicPublished'].lower() or ( helpers.today()[:4] in comic['LatestDate']):
|
||||||
Continuing
|
Continuing
|
||||||
%else:
|
%else:
|
||||||
Ended
|
Ended
|
||||||
|
|
52
mylar/cv.py
52
mylar/cv.py
|
@ -16,6 +16,7 @@
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import logger
|
import logger
|
||||||
import string
|
import string
|
||||||
import urllib
|
import urllib
|
||||||
|
@ -25,7 +26,7 @@ from bs4 import BeautifulSoup as Soup
|
||||||
def getComic(comicid,type):
|
def getComic(comicid,type):
|
||||||
comicapi='583939a3df0a25fc4e8b7a29934a13078002dc27'
|
comicapi='583939a3df0a25fc4e8b7a29934a13078002dc27'
|
||||||
#api
|
#api
|
||||||
PULLURL='http://api.comicvine.com/volume/' + str(comicid) + '/?api_key=' + str(comicapi) + '&format=xml&field_list=name,count_of_issues,start_year,last_issue,site_detail_url,image,publisher'
|
PULLURL='http://api.comicvine.com/volume/' + str(comicid) + '/?api_key=' + str(comicapi) + '&format=xml&field_list=name,count_of_issues,start_year,last_issue,site_detail_url,image,publisher,description'
|
||||||
|
|
||||||
#import library to do http requests:
|
#import library to do http requests:
|
||||||
import urllib2
|
import urllib2
|
||||||
|
@ -90,6 +91,34 @@ def GetComicInfo(comicid,dom):
|
||||||
comic['ComicName'] = comic['ComicName'].rstrip()
|
comic['ComicName'] = comic['ComicName'].rstrip()
|
||||||
comic['ComicYear'] = dom.getElementsByTagName('start_year')[0].firstChild.wholeText
|
comic['ComicYear'] = dom.getElementsByTagName('start_year')[0].firstChild.wholeText
|
||||||
comic['ComicURL'] = dom.getElementsByTagName('site_detail_url')[0].firstChild.wholeText
|
comic['ComicURL'] = dom.getElementsByTagName('site_detail_url')[0].firstChild.wholeText
|
||||||
|
#the description field actually holds the Volume# - so let's grab it
|
||||||
|
try:
|
||||||
|
comic['ComicDescription'] = dom.getElementsByTagName('description')[0].firstChild.wholeText
|
||||||
|
except:
|
||||||
|
comic['ComicDescription'] = 'None'
|
||||||
|
#extract the first 60 characters
|
||||||
|
comicDes = comic['ComicDescription'][:60]
|
||||||
|
if 'volume' in comicDes.lower():
|
||||||
|
#found volume - let's grab it.
|
||||||
|
v_find = comicDes.lower().find('volume')
|
||||||
|
#arbitrarily grab the next 10 chars (6 for volume + 1 for space + 3 for the actual vol #)
|
||||||
|
#increased to 10 to allow for text numbering (+5 max)
|
||||||
|
vfind = comicDes[v_find:v_find+15]
|
||||||
|
volconv = ''
|
||||||
|
basenums = {'zero':'0','one':'1','two':'2','three':'3','four':'4','five':'5','six':'6','seven':'7','eight':'8'}
|
||||||
|
for nums in basenums:
|
||||||
|
if nums in vfind.lower():
|
||||||
|
sconv = basenums[nums]
|
||||||
|
volconv = re.sub(nums, sconv, vfind.lower())
|
||||||
|
break
|
||||||
|
if volconv != '':
|
||||||
|
vfind = volconv
|
||||||
|
|
||||||
|
comic['ComicVersion'] = re.sub("[^0-9]", "", vfind)
|
||||||
|
logger.info("Volume information found! Adding to series record : volume " + comic['ComicVersion'])
|
||||||
|
else:
|
||||||
|
comic['ComicVersion'] = "noversion"
|
||||||
|
|
||||||
if vari == "yes":
|
if vari == "yes":
|
||||||
comic['ComicIssues'] = str(cntit)
|
comic['ComicIssues'] = str(cntit)
|
||||||
else:
|
else:
|
||||||
|
@ -97,17 +126,18 @@ def GetComicInfo(comicid,dom):
|
||||||
comic['ComicImage'] = dom.getElementsByTagName('super_url')[0].firstChild.wholeText
|
comic['ComicImage'] = dom.getElementsByTagName('super_url')[0].firstChild.wholeText
|
||||||
comic['ComicPublisher'] = dom.getElementsByTagName('name')[trackcnt+1].firstChild.wholeText
|
comic['ComicPublisher'] = dom.getElementsByTagName('name')[trackcnt+1].firstChild.wholeText
|
||||||
|
|
||||||
comicchoice.append({
|
# comicchoice.append({
|
||||||
'ComicName': comic['ComicName'],
|
# 'ComicName': comic['ComicName'],
|
||||||
'ComicYear': comic['ComicYear'],
|
# 'ComicYear': comic['ComicYear'],
|
||||||
'Comicid': comicid,
|
# 'Comicid': comicid,
|
||||||
'ComicURL': comic['ComicURL'],
|
# 'ComicURL': comic['ComicURL'],
|
||||||
'ComicIssues': comic['ComicIssues'],
|
# 'ComicIssues': comic['ComicIssues'],
|
||||||
'ComicImage': comic['ComicImage'],
|
# 'ComicImage': comic['ComicImage'],
|
||||||
'ComicPublisher': comic['ComicPublisher']
|
# 'ComicVolume': ParseVol,
|
||||||
})
|
# 'ComicPublisher': comic['ComicPublisher']
|
||||||
|
# })
|
||||||
|
|
||||||
comic['comicchoice'] = comicchoice
|
# comic['comicchoice'] = comicchoice
|
||||||
return comic
|
return comic
|
||||||
|
|
||||||
def GetIssuesInfo(comicid,dom):
|
def GetIssuesInfo(comicid,dom):
|
||||||
|
|
|
@ -195,19 +195,23 @@ def is_number(s):
|
||||||
|
|
||||||
def decimal_issue(iss):
|
def decimal_issue(iss):
|
||||||
iss_find = iss.find('.')
|
iss_find = iss.find('.')
|
||||||
iss_b4dec = iss[:iss_find]
|
if iss_find == -1:
|
||||||
iss_decval = iss[iss_find+1:]
|
#no matches for a decimal, assume we're converting from decimal to int.
|
||||||
if int(iss_decval) == 0:
|
deciss = int(iss) * 1000
|
||||||
iss = iss_b4dec
|
|
||||||
issdec = int(iss_decval)
|
|
||||||
else:
|
else:
|
||||||
if len(iss_decval) == 1:
|
iss_b4dec = iss[:iss_find]
|
||||||
iss = iss_b4dec + "." + iss_decval
|
iss_decval = iss[iss_find+1:]
|
||||||
issdec = int(iss_decval) * 10
|
if int(iss_decval) == 0:
|
||||||
|
iss = iss_b4dec
|
||||||
|
issdec = int(iss_decval)
|
||||||
else:
|
else:
|
||||||
iss = iss_b4dec + "." + iss_decval.rstrip('0')
|
if len(iss_decval) == 1:
|
||||||
issdec = int(iss_decval.rstrip('0')) * 10
|
iss = iss_b4dec + "." + iss_decval
|
||||||
deciss = (int(iss_b4dec) * 1000) + issdec
|
issdec = int(iss_decval) * 10
|
||||||
|
else:
|
||||||
|
iss = iss_b4dec + "." + iss_decval.rstrip('0')
|
||||||
|
issdec = int(iss_decval.rstrip('0')) * 10
|
||||||
|
deciss = (int(iss_b4dec) * 1000) + issdec
|
||||||
return deciss
|
return deciss
|
||||||
|
|
||||||
def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=None):
|
def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=None):
|
||||||
|
|
|
@ -208,7 +208,10 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None):
|
||||||
except IOError as e:
|
except IOError as e:
|
||||||
logger.error(u"Unable to save cover locally at this time.")
|
logger.error(u"Unable to save cover locally at this time.")
|
||||||
|
|
||||||
|
if comic['ComicVersion'].isdigit():
|
||||||
|
comicVol = "v" + comic['ComicVersion']
|
||||||
|
else:
|
||||||
|
comicVol = None
|
||||||
|
|
||||||
controlValueDict = {"ComicID": comicid}
|
controlValueDict = {"ComicID": comicid}
|
||||||
newValueDict = {"ComicName": comic['ComicName'],
|
newValueDict = {"ComicName": comic['ComicName'],
|
||||||
|
@ -216,6 +219,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None):
|
||||||
"ComicYear": comic['ComicYear'],
|
"ComicYear": comic['ComicYear'],
|
||||||
"ComicImage": ComicImage,
|
"ComicImage": ComicImage,
|
||||||
"Total": comicIssues,
|
"Total": comicIssues,
|
||||||
|
"ComicVersion": comicVol,
|
||||||
"ComicLocation": comlocation,
|
"ComicLocation": comlocation,
|
||||||
"ComicPublisher": comic['ComicPublisher'],
|
"ComicPublisher": comic['ComicPublisher'],
|
||||||
"ComicPublished": gcdinfo['resultPublished'],
|
"ComicPublished": gcdinfo['resultPublished'],
|
||||||
|
|
|
@ -39,7 +39,8 @@ def GCDScraper(ComicName, ComicYear, Total, ComicID, quickmatch=None):
|
||||||
#print ( "comicyear: " + str(comicyr) )
|
#print ( "comicyear: " + str(comicyr) )
|
||||||
#print ( "comichave: " + str(comicis) )
|
#print ( "comichave: " + str(comicis) )
|
||||||
#print ( "comicid: " + str(comicid) )
|
#print ( "comicid: " + str(comicid) )
|
||||||
comicnm = re.sub(' ', '+', comicnm)
|
comicnm_1 = re.sub('\+', '%2B', comicnm)
|
||||||
|
comicnm = re.sub(' ', '+', comicnm_1)
|
||||||
input = 'http://www.comics.org/search/advanced/process/?target=series&method=icontains&logic=False&order2=date&order3=&start_date=' + str(comicyr) + '-01-01&end_date=' + str(NOWyr) + '-12-31&series=' + str(comicnm) + '&is_indexed=None'
|
input = 'http://www.comics.org/search/advanced/process/?target=series&method=icontains&logic=False&order2=date&order3=&start_date=' + str(comicyr) + '-01-01&end_date=' + str(NOWyr) + '-12-31&series=' + str(comicnm) + '&is_indexed=None'
|
||||||
response = urllib2.urlopen ( input )
|
response = urllib2.urlopen ( input )
|
||||||
soup = BeautifulSoup ( response)
|
soup = BeautifulSoup ( response)
|
||||||
|
@ -48,7 +49,7 @@ def GCDScraper(ComicName, ComicYear, Total, ComicID, quickmatch=None):
|
||||||
|
|
||||||
cnt = int(cnt1 + cnt2)
|
cnt = int(cnt1 + cnt2)
|
||||||
|
|
||||||
#print (str(cnt) + " results")
|
print (str(cnt) + " results")
|
||||||
|
|
||||||
resultName = []
|
resultName = []
|
||||||
resultID = []
|
resultID = []
|
||||||
|
@ -224,6 +225,8 @@ def GCDdetails(comseries, resultURL, vari_loop, ComicID, TotalIssues, issvariati
|
||||||
if resultFormat != '':
|
if resultFormat != '':
|
||||||
if 'ongoing series' in resultFormat.lower() and 'was' not in resultFormat.lower() and 'present' not in resultPublished.lower():
|
if 'ongoing series' in resultFormat.lower() and 'was' not in resultFormat.lower() and 'present' not in resultPublished.lower():
|
||||||
resultPublished = resultPublished + " - Present"
|
resultPublished = resultPublished + " - Present"
|
||||||
|
if 'limited series' in resultFormat.lower() and '?' in resultPublished:
|
||||||
|
resultPublished = resultPublished + " (Limited Series)"
|
||||||
coverst = soup.find("div", {"id" : "series_cover"})
|
coverst = soup.find("div", {"id" : "series_cover"})
|
||||||
if coverst < 0:
|
if coverst < 0:
|
||||||
gcdcover = "None"
|
gcdcover = "None"
|
||||||
|
|
Loading…
Reference in New Issue