FIX: Fix for filechecker returning traceback on some invalid date patterns, FIX: When a title contained the word special, but was not a part of a series (ie. annual integration) would fail to recognize it for post-processing

This commit is contained in:
evilhero 2018-12-10 12:05:42 -05:00
parent 25267995cc
commit 5503a363ba
2 changed files with 109 additions and 72 deletions

View File

@ -421,10 +421,11 @@ class PostProcessor(object):
self.matched = False
as_d = filechecker.FileChecker()
as_dinfo = as_d.dynamic_replace(helpers.conversion(fl['series_name']))
orig_seriesname = as_dinfo['mod_seriesname']
mod_seriesname = as_dinfo['mod_seriesname']
loopchk = []
if fl['alt_series'] is not None:
logger.info('%s Alternate series naming detected: %s' % (module, fl['alt_series']))
logger.fdebug('%s Alternate series naming detected: %s' % (module, fl['alt_series']))
as_sinfo = as_d.dynamic_replace(helpers.conversion(fl['alt_series']))
mod_altseriesname = as_sinfo['mod_seriesname']
if all([mylar.CONFIG.ANNUALS_ON, 'annual' in mod_altseriesname.lower()]) or all([mylar.CONFIG.ANNUALS_ON, 'special' in mod_altseriesname.lower()]):
@ -456,10 +457,15 @@ class PostProcessor(object):
tmpsql = "SELECT * FROM comics WHERE DynamicComicName IN ({seq}) COLLATE NOCASE".format(seq=','.join('?' * len(loopchk)))
comicseries = myDB.select(tmpsql, tuple(loopchk))
if comicseries is None:
if not comicseries:
if (['special' in mod_seriesname.lower(), mylar.CONFIG.ANNUALS_ON, orig_seriesname != mod_seriesname]):
loopchk.append(re.sub('[\|\s]', '', orig_seriesname.lower()))
tmpsql = "SELECT * FROM comics WHERE DynamicComicName IN ({seq}) COLLATE NOCASE".format(seq=','.join('?' * len(loopchk)))
comicseries = myDB.select(tmpsql, tuple(loopchk))
if not comicseries:
logger.error(module + ' No Series in Watchlist - checking against Story Arcs (just in case). If I do not find anything, maybe you should be running Import?')
break
else:
watchvals = []
for wv in comicseries:
#do some extra checks in here to ignore these types:
@ -472,7 +478,10 @@ class PostProcessor(object):
wv_comicpublisher = wv['ComicPublisher']
wv_alternatesearch = wv['AlternateSearch']
wv_comicid = wv['ComicID']
if all([wv['Type'] != 'Print', wv['Type'] != 'Digital']) or wv['Corrected_Type'] == 'TPB':
wv_type = 'TPB'
else:
wv_type = None
wv_seriesyear = wv['ComicYear']
wv_comicversion = wv['ComicVersion']
wv_publisher = wv['ComicPublisher']
@ -524,6 +533,7 @@ class PostProcessor(object):
"WatchValues": {"SeriesYear": wv_seriesyear,
"LatestDate": latestdate,
"ComicVersion": wv_comicversion,
"Type": wv_type,
"Publisher": wv_publisher,
"Total": wv_total,
"ComicID": wv_comicid,
@ -539,9 +549,13 @@ class PostProcessor(object):
nm+=1
continue
else:
temploc= watchmatch['justthedigits'].replace('_', ' ')
if cs['WatchValues']['Type'] == 'TPB' and cs['WatchValues']['Total'] > 1:
just_the_digits = re.sub('[^0-9]', '', watchmatch['seriesvolume']).strip()
else:
just_the_digits = watchmatch['justthedigits']
temploc= just_the_digits.replace('_', ' ')
temploc = re.sub('[\#\']', '', temploc)
logger.info('temploc: %s' % temploc)
logger.fdebug('temploc: %s' % temploc)
datematch = "False"
if any(['annual' in temploc.lower(), 'special' in temploc.lower()]) and mylar.CONFIG.ANNUALS_ON is True:

View File

@ -1445,7 +1445,7 @@ class FileChecker(object):
return {'AS_Alt': AS_Alt,
'AS_Tuple': AS_Tuple}
def checkthedate(self, txt, fulldate=False):
def checkthedate(self, txt, fulldate=False, cnt=0):
# txt='''\
# Jan 19, 1990
# January 19, 1990
@ -1457,8 +1457,9 @@ class FileChecker(object):
# January1990'''
fmts = ('%Y','%b %d, %Y','%B %d, %Y','%B %d %Y','%m/%d/%Y','%m/%d/%y','(%m/%d/%Y)','%b %Y','%B%Y','%b %d,%Y','%m-%Y','%B %Y','%Y-%m-%d','%Y-%m','%Y%m')
mnths = ('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec')
parsed=[]
if fulldate is False:
for e in txt.splitlines():
for fmt in fmts:
@ -1470,7 +1471,29 @@ class FileChecker(object):
pass
else:
for e in txt.split():
logger.info('word: %s' % e)
if cnt == 0:
for x in mnths:
mnth = re.sub('\.', '', e.lower())
if x.lower() in mnth and len(mnth) <= 4:
add_date = x + ' '
cnt+=1
break
elif cnt == 1:
issnumb = re.sub(',', '', e).strip()
if issnumb.isdigit() and int(issnumb) < 31:
add_date += issnumb + ', '
cnt+=1
elif cnt == 2:
possyear = helpers.cleanhtml(re.sub('\.', '', e).strip())
if possyear.isdigit() and int(possyear) > 1970 and int(possyear) < 2020:
add_date += possyear
cnt +=1
if cnt == 3:
return self.checkthedate(add_date, fulldate=False, cnt=-1)
if cnt <= 0:
for fmt in fmts:
try:
t = dt.datetime.strptime(e, fmt)
@ -1485,13 +1508,13 @@ class FileChecker(object):
if e not in success:
pass #print e
dateyear = None
dateline = None
#logger.info('parsed: %s' % parsed)
for t in parsed:
# logger.fdebug('"{:20}" => "{:20}" => {}'.format(*t)
if fulldate is False:
#logger.fdebug('"{:20}" => "{:20}" => {}'.format(*t))
if fulldate is False and cnt != -1:
dateline = t[2].year
else:
dateline = t[2].strftime('%Y-%m-%d')