FIX: Annuals were not being refreshed properly which caused various errors when trying to refresh/update/add series that had annuals integrated, FIX: If an annual had a volume label in the filename prior to the word 'annual', file parser would assume it was a non-annual and mark wrong issues

This commit is contained in:
evilhero 2017-09-19 11:41:48 -04:00
parent 0f1a3578f3
commit c6a7f4dbdf
3 changed files with 76 additions and 35 deletions

View File

@ -751,7 +751,10 @@ class FileChecker(object):
if sep_volume:
highest_series_pos = issue_number_position -2
else:
highest_series_pos = issue_number_position -1
if split_file[issue_number_position -1].lower() == 'annual':
highest_series_pos = issue_number_position
else:
highest_series_pos = issue_number_position - 1
#make sure if we have multiple years detected, that the right one gets picked for the actual year vs. series title
if len(possible_years) > 1:

View File

@ -420,37 +420,50 @@ def addComictoDB(comicid, mismatch=None, pullupd=None, imported=None, ogcname=No
#move to own function so can call independently to only refresh issue data
#issued is from cv.getComic, comic['ComicName'] & comicid would both be already known to do independent call.
issuedata, anndata = updateissuedata(comicid, comic['ComicName'], issued, comicIssues, calledfrom, SeriesYear=SeriesYear, latestissueinfo=latestissueinfo)
updateddata = updateissuedata(comicid, comic['ComicName'], issued, comicIssues, calledfrom, SeriesYear=SeriesYear, latestissueinfo=latestissueinfo)
issuedata = updateddata['issuedata']
anndata = updateddata['annualchk']
nostatus = updateddata['nostatus']
importantdates = updateddata['importantdates']
if issuedata is None:
logger.warn('Unable to complete Refreshing / Adding issue data - this WILL create future problems if not addressed.')
return
return {'status': 'incomplete'}
if calledfrom is None:
issue_collection(issuedata, nostatus='True')
#need to update annuals at this point too....
if anndata:
manualAnnual(annchk=anndata)
if mylar.CVINFO or (mylar.CV_ONLY and mylar.CVINFO):
if not os.path.exists(os.path.join(comlocation, "cvinfo")) or mylar.CV_ONETIMER:
with open(os.path.join(comlocation, "cvinfo"), "w") as text_file:
text_file.write(str(comic['ComicURL']))
logger.info('Updating complete for: ' + comic['ComicName'])
if calledfrom == 'weekly':
logger.info('Successfully refreshed ' + comic['ComicName'] + ' (' + str(SeriesYear) + '). Returning to Weekly issue comparison.')
logger.info('Update issuedata for ' + str(issuechk) + ' of : ' + str(weeklyissue_check))
return issuedata # this should be the weeklyissue_check data from updateissuedata function
return {'status': 'complete',
'issuedata': issuedata} # this should be the weeklyissue_check data from updateissuedata function
elif calledfrom == 'dbupdate':
logger.info('returning to dbupdate module')
return issuedata, anndata # this should be the issuedata data from updateissuedata function
return {'status': 'complete',
'issuedata': issuedata,
'anndata': anndata } # this should be the issuedata data from updateissuedata function
elif calledfrom == 'weeklycheck':
logger.info('Successfully refreshed ' + comic['ComicName'] + ' (' + str(SeriesYear) + '). Returning to Weekly issue update.')
return #no need to return any data here.
logger.info('Updating complete for: ' + comic['ComicName'])
#if it made it here, then the issuedata contains dates, let's pull the data now.
latestiss = issuedata['LatestIssue']
latestdate = issuedata['LatestDate']
lastpubdate = issuedata['LastPubDate']
series_status = issuedata['SeriesStatus']
latestiss = importantdates['LatestIssue']
latestdate = importantdates['LatestDate']
lastpubdate = importantdates['LastPubDate']
series_status = importantdates['SeriesStatus']
#move the files...if imported is not empty & not futurecheck (meaning it's not from the mass importer.)
#logger.info('imported is : ' + str(imported))
if imported is None or imported == 'None' or imported == 'futurecheck':
@ -546,13 +559,17 @@ def addComictoDB(comicid, mismatch=None, pullupd=None, imported=None, ogcname=No
if imported == 'futurecheck':
logger.info('Returning to Future-Check module to complete the add & remove entry.')
return
elif imported:
logger.info('Successfully imported : ' + comic['ComicName'])
return
if calledfrom == 'addbyid':
logger.info('Sucessfully added ' + comic['ComicName'] + ' (' + str(SeriesYear) + ') by directly using the ComicVine ID')
return
return {'status': 'complete'}
else:
return {'status': 'complete'}
if imported:
logger.info('Successfully imported : ' + comic['ComicName'])
# if imported['Volume'] is None or imported['Volume'] == 'None':
# results = myDB.select("SELECT * FROM importresults WHERE (WatchMatch is Null OR WatchMatch LIKE 'C%') AND DynamicName=? AND Volume IS NULL",[imported['DynamicName']])
# else:
@ -1276,12 +1293,12 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
lastpubdate = 'Present'
publishfigure = str(SeriesYear) + ' - ' + str(lastpubdate)
else:
if len(issuedata) >= 1 and not calledfrom == 'dbupdate':
logger.fdebug('initiating issue updating - info & status')
issue_collection(issuedata, nostatus='False')
else:
logger.fdebug('initiating issue updating - just the info')
#issue_collection(issuedata, nostatus='True')
#if len(issuedata) >= 1 and not calledfrom == 'dbupdate':
# logger.fdebug('initiating issue updating - info & status')
# #issue_collection(issuedata, nostatus='False')
#else:
# logger.fdebug('initiating issue updating - just the info')
# #issue_collection(issuedata, nostatus='True')
styear = str(SeriesYear)
@ -1354,10 +1371,20 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
if calledfrom == 'weekly':
return weeklyissue_check
elif calledfrom == 'dbupdate':
return issuedata, annualchk
elif len(issuedata) >= 1 and not calledfrom == 'dbupdate':
return {'issuedata': issuedata,
'annualchk': annualchk,
'importantdates': importantdates,
'nostatus': False}
return importantdates
elif calledfrom == 'dbupdate':
return {'issuedata': issuedata,
'annualchk': annualchk,
'importantdates': importantdates,
'nostatus': True}
else:
return importantdates
def annual_check(ComicName, SeriesYear, comicid, issuetype, issuechk, annualslist):
annualids = [] #to be used to make sure an ID isn't double-loaded

View File

@ -177,16 +177,16 @@ def dbUpdate(ComicIDList=None, calledfrom=None, sched=False):
logger.fdebug("Refreshing the series and pulling in new data using only CV.")
if whack == False:
cchk, annchk = mylar.importer.addComictoDB(ComicID, mismatch, calledfrom='dbupdate', annload=annload, csyear=csyear)
if cchk:
chkstatus = mylar.importer.addComictoDB(ComicID, mismatch, calledfrom='dbupdate', annload=annload, csyear=csyear)
if chkstatus['status'] == 'complete':
#delete the data here if it's all valid.
logger.fdebug("Deleting all old issue data to make sure new data is clean...")
myDB.action('DELETE FROM issues WHERE ComicID=?', [ComicID])
myDB.action('DELETE FROM annuals WHERE ComicID=?', [ComicID])
mylar.importer.issue_collection(cchk, nostatus='True')
mylar.importer.issue_collection(chkstatus['issuedata'], nostatus='True')
#need to update annuals at this point too....
if annchk:
mylar.importer.manualAnnual(annchk=annchk)
if chkstatus['anndata'] is not None:
mylar.importer.manualAnnual(annchk=chkstatus['anndata'])
else:
logger.warn('There was an error when refreshing this series - Make sure directories are writable/exist, etc')
return
@ -301,10 +301,19 @@ def dbUpdate(ComicIDList=None, calledfrom=None, sched=False):
forceRescan(ComicID)
else:
cchk = mylar.importer.addComictoDB(ComicID, mismatch, annload=annload, csyear=csyear)
chkstatus = mylar.importer.addComictoDB(ComicID, mismatch, annload=annload, csyear=csyear)
#if cchk:
# #delete the data here if it's all valid.
# #logger.fdebug("Deleting all old issue data to make sure new data is clean...")
# myDB.action('DELETE FROM issues WHERE ComicID=?', [ComicID])
# myDB.action('DELETE FROM annuals WHERE ComicID=?', [ComicID])
# mylar.importer.issue_collection(cchk, nostatus='True')
# #need to update annuals at this point too....
# if annchk:
# mylar.importer.manualAnnual(annchk=annchk)
else:
cchk = mylar.importer.addComictoDB(ComicID, mismatch)
chkstatus = mylar.importer.addComictoDB(ComicID, mismatch)
cnt +=1
if sched is False:
@ -368,7 +377,7 @@ def upcoming_update(ComicID, ComicName, IssueNumber, IssueDate, forcecheck=None,
#update the PULL_REFRESH
mylar.config_write()
logger.fdebug('pull_refresh: ' + str(mylar.PULL_REFRESH))
c_obj_date = mylar.PULL_REFRESH
c_obj_date = datetime.datetime.strptime(str(mylar.PULL_REFRESH),"%Y-%m-%d %H:%M:%S")
#logger.fdebug('c_obj_date: ' + str(c_obj_date))
n_date = datetime.datetime.now()
#logger.fdebug('n_date: ' + str(n_date))
@ -1196,14 +1205,14 @@ def forceRescan(ComicID, archive=None, module=None):
except IndexError:
break
int_iss = helpers.issuedigits(reann['Issue_Number'])
logger.fdebug(module + ' int_iss:' + str(int_iss))
#logger.fdebug(module + ' int_iss:' + str(int_iss))
issyear = reann['IssueDate'][:4]
old_status = reann['Status']
fcdigit = helpers.issuedigits(re.sub('annual', '', temploc.lower()).strip())
if int(fcdigit) == int_iss:
if int(fcdigit) == int_iss and ANNComicID is not None:
logger.fdebug(module + ' [' + str(ANNComicID) + '] Annual match - issue : ' + str(int_iss))
#baseline these to default to normal scanning
@ -1436,8 +1445,9 @@ def forceRescan(ComicID, archive=None, module=None):
logger.fdebug(module + ' Adjusting have total to ' + str(havefiles) + ' because of this many archive files already in Archive status :' + str(arcfiles))
else:
#if files exist in the given directory, but are in an archived state - the numbers will get botched up here.
logger.fdebug(module + ' ' + str(int(arcfiles + arcanns)) + ' issue(s) are in an Archive status already. Increasing Have total from ' + str(havefiles) + ' to include these archives.')
havefiles = havefiles + (arcfiles + arcanns)
if (arcfiles + arcanns) > 0:
logger.fdebug(module + ' ' + str(int(arcfiles + arcanns)) + ' issue(s) are in an Archive status already. Increasing Have total from ' + str(havefiles) + ' to include these archives.')
havefiles = havefiles + (arcfiles + arcanns)
ignorecount = 0
if mylar.IGNORE_HAVETOTAL: # if this is enabled, will increase Have total as if in Archived Status
@ -1493,7 +1503,8 @@ def forceRescan(ComicID, archive=None, module=None):
newValue = {"Status": "Archived"}
myDB.upsert("issues", newValue, controlValue)
archivedissues+=1
logger.fdebug(module + ' I have changed the status of ' + str(archivedissues) + ' issues to a status of Archived, as I now cannot locate them in the series directory.')
if archivedissues > 0:
logger.fdebug(module + ' I have changed the status of ' + str(archivedissues) + ' issues to a status of Archived, as I now cannot locate them in the series directory.')
totalarc = arcfiles + archivedissues
havefiles = havefiles + archivedissues #arcfiles already tallied in havefiles in above segment