def pullitcheck(comic1off_name=None,comic1off_id=None,forcecheck=None, futurepull=None, issue=None): if futurepull is None: logger.info(u"Checking the Weekly Releases list for comics I'm watching...") else: logger.info('Checking the Future Releases list for upcoming comics I am watching for...') myDB = db.DBConnection() not_t = ['TP', 'NA', 'HC', 'PI'] not_c = ['PTG', 'COMBO PACK', '(PP #'] lines = [] unlines = [] llen = [] ccname = [] pubdate = [] latestissue = [] w = 0 wc = 0 tot = 0 chkout = [] watchfnd = [] watchfndiss = [] watchfndextra = [] alternate = [] #print ("----------WATCHLIST--------") a_list = [] b_list = [] comicid = [] mylardb = os.path.join(mylar.DATA_DIR, "mylar.db") con = sqlite3.connect(str(mylardb)) with con: cur = con.cursor() # if it's a one-off check (during an add series), load the comicname here and ignore below. if comic1off_name: logger.fdebug("this is a one-off" + comic1off_name) lines.append(comic1off_name.strip()) unlines.append(comic1off_name.strip()) comicid.append(comic1off_id) latestissue.append(issue) w = 1 else: #let's read in the comic.watchlist from the db here cur.execute("SELECT ComicID, ComicName, ComicYear, ComicPublisher, ComicPublished, LatestDate, ForceContinuing, AlternateSearch, LatestIssue from comics") while True: watchd = cur.fetchone() #print ("watchd: " + str(watchd)) if watchd is None: break if 'Present' in watchd[4] or (helpers.now()[:4] in watchd[4]) or watchd[6] == 1: # this gets buggered up when series are named the same, and one ends in the current # year, and the new series starts in the same year - ie. Avengers # lets' grab the latest issue date and see how far it is from current # anything > 45 days we'll assume it's a false match ;) logger.fdebug("ComicName: " + watchd[1]) latestdate = watchd[5] logger.fdebug("latestdate: " + str(latestdate)) if latestdate[8:] == '': logger.fdebug("invalid date " + str(latestdate) + " appending 01 for day for continuation.") latest_day = '01' else: latest_day = latestdate[8:] c_date = datetime.date(int(latestdate[:4]),int(latestdate[5:7]),int(latest_day)) n_date = datetime.date.today() logger.fdebug("c_date : " + str(c_date) + " ... n_date : " + str(n_date)) recentchk = (n_date - c_date).days logger.fdebug("recentchk: " + str(recentchk) + " days") chklimit = helpers.checkthepub(watchd[0]) logger.fdebug("Check date limit set to : " + str(chklimit)) logger.fdebug(" ----- ") if recentchk < int(chklimit) or watchd[6] == 1: if watchd[6] == 1: logger.fdebug('Forcing Continuing Series enabled for series...') # let's not even bother with comics that are not in the Present. a_list.append(watchd[1]) b_list.append(watchd[2]) comicid.append(watchd[0]) pubdate.append(watchd[4]) latestissue.append(watchd[8]) lines.append(a_list[w].strip()) unlines.append(a_list[w].strip()) w+=1 # we need to increment the count here, so we don't count the same comics twice (albeit with alternate names) #here we load in the alternate search names for a series and assign them the comicid and #alternate names Altload = helpers.LoadAlternateSearchNames(watchd[7], watchd[0]) if Altload == 'no results': pass else: wc = 0 alt_cid = Altload['ComicID'] n = 0 iscnt = Altload['Count'] while (n <= iscnt): try: altval = Altload['AlternateName'][n] except IndexError: break cleanedname = altval['AlternateName'] a_list.append(altval['AlternateName']) b_list.append(watchd[2]) comicid.append(alt_cid) pubdate.append(watchd[4]) latestissue.append(watchd[8]) lines.append(a_list[w+wc].strip()) unlines.append(a_list[w+wc].strip()) logger.fdebug('loading in Alternate name for ' + str(cleanedname)) n+=1 wc+=1 w+=wc #-- to be removed - #print ( "Comic:" + str(a_list[w]) + " Year: " + str(b_list[w]) ) #if "WOLVERINE AND THE X-MEN" in str(a_list[w]): a_list[w] = "WOLVERINE AND X-MEN" #lines.append(a_list[w].strip()) #unlines.append(a_list[w].strip()) #llen.append(a_list[w].splitlines()) #ccname.append(a_list[w].strip()) #tmpwords = a_list[w].split(None) #ltmpwords = len(tmpwords) #ltmp = 1 #-- end to be removed else: logger.fdebug("Determined to not be a Continuing series at this time.") cnt = int(w-1) cntback = int(w-1) kp = [] ki = [] kc = [] otot = 0 logger.fdebug("You are watching for: " + str(w) + " comics") #print ("----------THIS WEEK'S PUBLISHED COMICS------------") if w > 0: while (cnt > -1): latestiss = latestissue[cnt] lines[cnt] = lines[cnt].upper() #llen[cnt] = str(llen[cnt]) logger.fdebug("looking for : " + lines[cnt]) sqlsearch = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\'\?\@]', ' ', lines[cnt]) sqlsearch = re.sub("\&", '%', sqlsearch) sqlsearch = re.sub("\\bAND\\b", '%', sqlsearch) sqlsearch = re.sub("\\bTHE\\b", '', sqlsearch) if '+' in sqlsearch: sqlsearch = re.sub('\+', '%PLUS%', sqlsearch) sqlsearch = re.sub(r'\s', '%', sqlsearch) sqlsearch = sqlsearch + '%' #logger.fdebug("searchsql: " + sqlsearch) if futurepull is None: weekly = myDB.select('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [sqlsearch]) else: weekly = myDB.select('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM future WHERE COMIC LIKE (?)', [sqlsearch]) #cur.execute('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [lines[cnt]]) for week in weekly: if week == None: break for nono in not_t: if nono in week['PUBLISHER']: #logger.fdebug("nono present") break if nono in week['ISSUE']: #logger.fdebug("graphic novel/tradeback detected..ignoring.") break for nothere in not_c: if nothere in week['EXTRA']: #logger.fdebug("nothere present") break else: comicnm = week['COMIC'] #here's the tricky part, ie. BATMAN will match on #every batman comic, not exact logger.fdebug("comparing" + comicnm + "..to.." + unlines[cnt].upper()) #-NEW- # strip out all special characters and compare watchcomic = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\'\?\@]', '', unlines[cnt]) comicnm = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\'\?\@]', '', comicnm) if "THE" in watchcomic.upper() or "THE" in comicnm.upper(): modwatchcomic = re.sub("\\bTHE\\b", "", watchcomic.upper()) modcomicnm = re.sub("\\bTHE\\b", "", comicnm) else: modwatchcomic = watchcomic modcomicnm = comicnm if '&' in watchcomic.upper(): modwatchcomic = re.sub('\&', 'AND', modwatchcomic.upper()) modcomicnm = re.sub('\&', 'AND', modcomicnm) if '&' in comicnm: modwatchcom = re.sub('\&', 'AND', modwatchcomic.upper()) modcomicnm = re.sub('\&', 'AND', modcomicnm) #thnx to A+X for this... if '+' in watchcomic: logger.fdebug("+ detected...adjusting.") #logger.fdebug("comicnm:" + comicnm) #logger.fdebug("watchcomic:" + watchcomic) modwatchcomic = re.sub('\+', 'PLUS', modwatchcomic) #logger.fdebug("modcomicnm:" + modcomicnm) #logger.fdebug("modwatchcomic:" + modwatchcomic) #annuals! if 'ANNUAL' in comicnm.upper(): modcomicnm = re.sub("\\bANNUAL\\b", "", modcomicnm.upper()) watchcomic = re.sub(r'\s', '', watchcomic) comicnm = re.sub(r'\s', '', comicnm) modwatchcomic = re.sub(r'\s', '', modwatchcomic) modcomicnm = re.sub(r'\s', '', modcomicnm) logger.fdebug("watchcomic : " + str(watchcomic) + " / mod :" + str(modwatchcomic)) logger.fdebug("comicnm : " + str(comicnm) + " / mod :" + str(modcomicnm)) if comicnm == watchcomic.upper() or modcomicnm == modwatchcomic.upper(): logger.fdebug("matched on:" + comicnm + "..." + watchcomic.upper()) pass # elif ("ANNUAL" in week['EXTRA']): # pass # print ( row[3] + " matched on ANNUAL") else: break if ("NA" not in week['ISSUE']) and ("HC" not in week['ISSUE']): if ("COMBO PACK" not in week['EXTRA']) and ("2ND PTG" not in week['EXTRA']) and ("3RD PTG" not in week['EXTRA']): #this all needs to get redone, so the ability to compare issue dates can be done systematically. #Everything below should be in it's own function - at least the callable sections - in doing so, we can #then do comparisons when two titles of the same name exist and are by definition 'current'. Issue date comparisons #would identify the difference between two #1 titles within the same series year, but have different publishing dates. #Wolverine (2013) & Wolverine (2014) are good examples of this situation. #of course initially, the issue data for the newer series wouldn't have any issue data associated with it so it would be #a null value, but given that the 2013 series (as an example) would be from 2013-05-01, it obviously wouldn't be a match to #the current date & year (2014). Throwing out that, we could just assume that the 2014 would match the #1. #get the issue number of the 'weeklypull' series. #load in the actual series issue number's store-date (not publishing date) #---use a function to check db, then return the results in a tuple/list to avoid db locks. #if the store-date is >= weeklypull-list date then continue processing below. #if the store-date is <= weeklypull-list date then break. ### week['ISSUE'] #issue # from pullist ### week['SHIPDATE'] #weeklypull-list date ### comicid[cnt] #comicid of matched series ## if it's a futurepull, the dates get mixed up when two titles exist of the same name ## ie. Wolverine-2011 & Wolverine-2014 ## we need to set the compare date to today's date ( Now() ) in this case. if futurepull: usedate = datetime.datetime.now().strftime('%Y%m%d') #convert to yyyymmdd else: usedate = re.sub("[^0-9]", "", week['SHIPDATE']) if 'ANNUAL' in comicnm.upper(): chktype = 'annual' else: chktype = 'series' datevalues = loaditup(watchcomic, comicid[cnt], week['ISSUE'], chktype) date_downloaded = None altissuenum = None if datevalues == 'no results': #if a series is a .NOW on the pullist, it won't match up against anything (probably) on CV #let's grab the digit from the .NOW, poll it against CV to see if there's any data #if there is, check the store date to make sure it's a 'new' release. #if it is a new release that has the same store date as the .NOW, then we assume #it's the same, and assign it the AltIssueNumber to do extra searches. if week['ISSUE'].isdigit() == False and '.' not in week['ISSUE']: altissuenum = re.sub("[^0-9]", "", week['ISSUE']) # carry this through to get added to db later if matches logger.fdebug('altissuenum is: ' + str(altissuenum)) altvalues = loaditup(watchcomic, comicid[cnt], altissuenum, chktype) if altvalues == 'no results': logger.fdebug('No alternate Issue numbering - something is probably wrong somewhere.') pass validcheck = checkthis(altvalues[0]['issuedate'], altvalues[0]['status'], usedate) if validcheck == False: if date_downloaded is None: break if chktype == 'series': latest_int = helpers.issuedigits(latestiss) weekiss_int = helpers.issuedigits(week['ISSUE']) logger.fdebug('comparing ' + str(latest_int) + ' to ' + str(weekiss_int)) if (latest_int > weekiss_int) or (latest_int == 0 or weekiss_int == 0): logger.fdebug(str(week['ISSUE']) + ' should not be the next issue in THIS volume of the series.') logger.fdebug('it should be either greater than ' + str(latestiss) + ' or an issue #0') break else: #logger.fdebug('issuedate:' + str(datevalues[0]['issuedate'])) #logger.fdebug('status:' + str(datevalues[0]['status'])) datestatus = datevalues[0]['status'] validcheck = checkthis(datevalues[0]['issuedate'], datestatus, usedate) if validcheck == True: if datestatus != 'Downloaded' and datestatus != 'Archived': pass else: logger.fdebug('Issue #' + str(week['ISSUE']) + ' already downloaded.') date_downloaded = datestatus else: if date_downloaded is None: break otot+=1 dontadd = "no" if dontadd == "no": #print (row[0], row[1], row[2]) tot+=1 #kp.append(row[0]) #ki.append(row[1]) #kc.append(comicnm) if "ANNUAL" in comicnm.upper(): watchfndextra.append("annual") ComicName = str(unlines[cnt]) + " Annual" else: ComicName = str(unlines[cnt]) watchfndextra.append("none") watchfnd.append(comicnm) watchfndiss.append(week['ISSUE']) ComicID = comicid[cnt] if not mylar.CV_ONLY: ComicIssue = str(watchfndiss[tot -1] + ".00") else: ComicIssue = str(watchfndiss[tot -1]) ComicDate = str(week['SHIPDATE']) #ComicName = str(unlines[cnt]) logger.fdebug("Watchlist hit for : " + ComicName + " ISSUE: " + str(watchfndiss[tot -1])) if futurepull is None: # here we add to comics.latest updater.latest_update(ComicID=ComicID, LatestIssue=ComicIssue, LatestDate=ComicDate) # here we add to upcoming table... statusupdate = updater.upcoming_update(ComicID=ComicID, ComicName=ComicName, IssueNumber=ComicIssue, IssueDate=ComicDate, forcecheck=forcecheck) else: # here we add to upcoming table... statusupdate = updater.upcoming_update(ComicID=ComicID, ComicName=ComicName, IssueNumber=ComicIssue, IssueDate=ComicDate, forcecheck=forcecheck, futurepull='yes', altissuenumber=altissuenum) # here we update status of weekly table... if statusupdate is not None: cstatus = statusupdate['Status'] cstatusid = statusupdate['ComicID'] else: cstatus = None cstatusid = None #set the variable fp to denote updating the futurepull list ONLY if futurepull is None: fp = None else: cstatusid = ComicID fp = "yes" if date_downloaded is None: updater.weekly_update(ComicName=week['COMIC'], IssueNumber=ComicIssue, CStatus=cstatus, CID=cstatusid, futurepull=fp, altissuenumber=altissuenum) else: updater.weekly_update(ComicName=week['COMIC'], IssueNumber=ComicIssue, CStatus=date_downloaded, CID=cstatusid, futurepull=fp, altissuenumber=altissuenum) break break break cnt-=1 #print ("-------------------------") logger.fdebug("There are " + str(otot) + " comics this week to get!") #print ("However I've already grabbed " + str(btotal) ) #print ("I need to get " + str(tot) + " comic(s)!" ) logger.info(u"Finished checking for comics on my watchlist.") #con.close() return
def pullitcheck(comic1off_name=None,comic1off_id=None,forcecheck=None): logger.info(u"Checking the Weekly Releases list for comics I'm watching...") myDB = db.DBConnection() not_t = ['TP', 'NA', 'HC', 'PI'] not_c = ['PTG', 'COMBO PACK', '(PP #'] lines = [] unlines = [] llen = [] ccname = [] pubdate = [] w = 0 tot = 0 chkout = [] watchfnd = [] watchfndiss = [] watchfndextra = [] #print ("----------WATCHLIST--------") a_list = [] b_list = [] comicid = [] mylardb = os.path.join(mylar.DATA_DIR, "mylar.db") con = sqlite3.connect(str(mylardb)) with con: cur = con.cursor() # if it's a one-off check (during an add series), load the comicname here and ignore below. if comic1off_name: logger.fdebug("this is a one-off" + str(comic1off_name)) lines.append(comic1off_name.strip()) unlines.append(comic1off_name.strip()) comicid.append(comic1off_id) w = 1 else: #let's read in the comic.watchlist from the db here cur.execute("SELECT ComicID, ComicName, ComicYear, ComicPublisher, ComicPublished, LatestDate from comics") while True: watchd = cur.fetchone() #print ("watchd: " + str(watchd)) if watchd is None: break if 'Present' in watchd[4] or (helpers.now()[:4] in watchd[4]): # this gets buggered up when series are named the same, and one ends in the current # year, and the new series starts in the same year - ie. Avengers # lets' grab the latest issue date and see how far it is from current # anything > 45 days we'll assume it's a false match ;) #logger.fdebug("ComicName: " + watchd[1]) latestdate = watchd[5] #logger.fdebug("latestdate: " + str(latestdate)) c_date = datetime.date(int(latestdate[:4]),int(latestdate[5:7]),1) n_date = datetime.date.today() #logger.fdebug("c_date : " + str(c_date) + " ... n_date : " + str(n_date)) recentchk = (n_date - c_date).days #logger.fdebug("recentchk: " + str(recentchk) + " days") #logger.fdebug(" ----- ") if recentchk < 55: # let's not even bother with comics that are in the Present. a_list.append(watchd[1]) b_list.append(watchd[2]) comicid.append(watchd[0]) pubdate.append(watchd[4]) #print ( "Comic:" + str(a_list[w]) + " Year: " + str(b_list[w]) ) #if "WOLVERINE AND THE X-MEN" in str(a_list[w]): a_list[w] = "WOLVERINE AND X-MEN" lines.append(a_list[w].strip()) unlines.append(a_list[w].strip()) llen.append(a_list[w].splitlines()) ccname.append(a_list[w].strip()) tmpwords = a_list[w].split(None) ltmpwords = len(tmpwords) ltmp = 1 w+=1 cnt = int(w-1) cntback = int(w-1) kp = [] ki = [] kc = [] otot = 0 logger.fdebug("You are watching for: " + str(w) + " comics") #print ("----------THIS WEEK'S PUBLISHED COMICS------------") if w > 0: while (cnt > -1): lines[cnt] = lines[cnt].upper() #llen[cnt] = str(llen[cnt]) #logger.fdebug("looking for : " + str(lines[cnt])) sqlsearch = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\'\?\@]', ' ', lines[cnt]) sqlsearch = re.sub(r'\s', '%', sqlsearch) if 'THE' in sqlsearch: sqlsearch = re.sub('THE', '', sqlsearch) if '+' in sqlsearch: sqlsearch = re.sub('\+', '%PLUS%', sqlsearch) #logger.fdebug("searchsql: " + str(sqlsearch)) weekly = myDB.select('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [sqlsearch]) #cur.execute('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [lines[cnt]]) for week in weekly: if week == None: break for nono in not_t: if nono in week['PUBLISHER']: #logger.fdebug("nono present") break if nono in week['ISSUE']: #logger.fdebug("graphic novel/tradeback detected..ignoring.") break for nothere in not_c: if nothere in week['EXTRA']: #logger.fdebug("nothere present") break else: comicnm = week['COMIC'] #here's the tricky part, ie. BATMAN will match on #every batman comic, not exact #logger.fdebug("comparing" + str(comicnm) + "..to.." + str(unlines[cnt]).upper()) #-NEW- # strip out all special characters and compare watchcomic = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\'\?\@]', '', unlines[cnt]) comicnm = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\'\?\@]', '', comicnm) watchcomic = re.sub(r'\s', '', watchcomic) comicnm = re.sub(r'\s', '', comicnm) #logger.fdebug("Revised_Watch: " + watchcomic) #logger.fdebug("ComicNM: " + comicnm) if 'THE' in watchcomic.upper(): modwatchcomic = re.sub('THE', '', watchcomic.upper()) modcomicnm = re.sub('THE', '', comicnm) else: modwatchcomic = watchcomic modcomicnm = comicnm #thnx to A+X for this... if '+' in watchcomic: logger.fdebug("+ detected...adjusting.") #logger.fdebug("comicnm:" + comicnm) #logger.fdebug("watchcomic:" + watchcomic) modwatchcomic = re.sub('\+', 'PLUS', modwatchcomic) #logger.fdebug("modcomicnm:" + modcomicnm) #logger.fdebug("modwatchcomic:" + modwatchcomic) if comicnm == watchcomic.upper() or modcomicnm == modwatchcomic.upper(): logger.fdebug("matched on:" + str(comicnm) + "..." + str(watchcomic).upper()) pass elif ("ANNUAL" in week['EXTRA']): pass #print ( row[3] + " matched on ANNUAL") else: break if ("NA" not in week['ISSUE']) and ("HC" not in week['ISSUE']): if ("COMBO PACK" not in week['EXTRA']) and ("2ND PTG" not in week['EXTRA']) and ("3RD PTG" not in week['EXTRA']): otot+=1 dontadd = "no" if dontadd == "no": #print (row[0], row[1], row[2]) tot+=1 #kp.append(row[0]) #ki.append(row[1]) #kc.append(comicnm) if ("ANNUAL" in week['EXTRA']): watchfndextra.append("annual") else: watchfndextra.append("none") watchfnd.append(comicnm) watchfndiss.append(week['ISSUE']) ComicID = comicid[cnt] if not mylar.CV_ONLY: ComicIssue = str(watchfndiss[tot -1] + ".00") else: ComicIssue = str(watchfndiss[tot -1]) ComicDate = str(week['SHIPDATE']) ComicName = str(unlines[cnt]) logger.fdebug("Watchlist hit for : " + ComicName + " ISSUE: " + str(watchfndiss[tot -1])) # here we add to comics.latest updater.latest_update(ComicID=ComicID, LatestIssue=ComicIssue, LatestDate=ComicDate) # here we add to upcoming table... statusupdate = updater.upcoming_update(ComicID=ComicID, ComicName=ComicName, IssueNumber=ComicIssue, IssueDate=ComicDate, forcecheck=forcecheck) # here we update status of weekly table... if statusupdate is not None: cstatus = statusupdate['Status'] cstatusid = statusupdate['ComicID'] else: cstatus = None cstatusid = None updater.weekly_update(ComicName=week['COMIC'], IssueNumber=ComicIssue, CStatus=cstatus, CID=cstatusid) break break break cnt-=1 #print ("-------------------------") logger.fdebug("There are " + str(otot) + " comics this week to get!") #print ("However I've already grabbed " + str(btotal) ) #print ("I need to get " + str(tot) + " comic(s)!" ) logger.info(u"Finished checking for comics on my watchlist.") #con.close() return
def pullitcheck(comic1off_name=None, comic1off_id=None, forcecheck=None): logger.info(u"Checking the Weekly Releases list for comics I'm watching...") myDB = db.DBConnection() not_t = ["TP", "NA", "HC", "PI"] not_c = ["PTG", "COMBO PACK", "(PP #"] lines = [] unlines = [] llen = [] ccname = [] pubdate = [] w = 0 tot = 0 chkout = [] watchfnd = [] watchfndiss = [] watchfndextra = [] # print ("----------WATCHLIST--------") a_list = [] b_list = [] comicid = [] mylardb = os.path.join(mylar.DATA_DIR, "mylar.db") con = sqlite3.connect(str(mylardb)) with con: cur = con.cursor() # if it's a one-off check (during an add series), load the comicname here and ignore below. if comic1off_name: lines.append(comic1off_name.strip()) unlines.append(comic1off_name.strip()) comicid.append(comic1off_id) w = 1 else: # let's read in the comic.watchlist from the db here cur.execute("SELECT ComicID, ComicName, ComicYear, ComicPublisher, ComicPublished from comics") while True: watchd = cur.fetchone() # print ("watchd: " + str(watchd)) if watchd is None: break if "Present" in watchd[4] or (helpers.now()[:4] in watchd[4]): # let's not even bother with comics that are in the Present. a_list.append(watchd[1]) b_list.append(watchd[2]) comicid.append(watchd[0]) pubdate.append(watchd[4]) # print ( "Comic:" + str(a_list[w]) + " Year: " + str(b_list[w]) ) # if "WOLVERINE AND THE X-MEN" in str(a_list[w]): a_list[w] = "WOLVERINE AND X-MEN" lines.append(a_list[w].strip()) unlines.append(a_list[w].strip()) llen.append(a_list[w].splitlines()) ccname.append(a_list[w].strip()) tmpwords = a_list[w].split(None) ltmpwords = len(tmpwords) ltmp = 1 w += 1 cnt = int(w - 1) cntback = int(w - 1) kp = [] ki = [] kc = [] otot = 0 logger.fdebug("You are watching for: " + str(w) + " comics") # print ("----------THIS WEEK'S PUBLISHED COMICS------------") if w > 0: while cnt > -1: lines[cnt] = lines[cnt].upper() # llen[cnt] = str(llen[cnt]) logger.fdebug("looking for : " + str(lines[cnt])) sqlsearch = re.sub("[\_\#\,\/\:\;\.\-\!\$\%\&'\?\@]", " ", lines[cnt]) sqlsearch = re.sub(r"\s", "%", sqlsearch) if "THE" in sqlsearch: sqlsearch = re.sub("THE", "", sqlsearch) if "+" in sqlsearch: sqlsearch = re.sub("\+", "%PLUS%", sqlsearch) logger.fdebug("searchsql: " + str(sqlsearch)) weekly = myDB.select( "SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)", [sqlsearch] ) # cur.execute('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [lines[cnt]]) for week in weekly: if week == None: break for nono in not_t: if nono in week["PUBLISHER"]: logger.fdebug("nono present") break if nono in week["ISSUE"]: # logger.fdebug("graphic novel/tradeback detected..ignoring.") break for nothere in not_c: if nothere in week["EXTRA"]: # logger.fdebug("nothere present") break else: comicnm = week["COMIC"] # here's the tricky part, ie. BATMAN will match on # every batman comic, not exact # logger.fdebug("comparing" + str(comicnm) + "..to.." + str(unlines[cnt]).upper()) # -NEW- # strip out all special characters and compare watchcomic = re.sub("[\_\#\,\/\:\;\.\-\!\$\%\&'\?\@]", "", unlines[cnt]) comicnm = re.sub("[\_\#\,\/\:\;\.\-\!\$\%\&'\?\@]", "", comicnm) watchcomic = re.sub(r"\s", "", watchcomic) comicnm = re.sub(r"\s", "", comicnm) # logger.fdebug("Revised_Watch: " + watchcomic) # logger.fdebug("ComicNM: " + comicnm) if "THE" in watchcomic.upper(): modwatchcomic = re.sub("THE", "", watchcomic.upper()) modcomicnm = re.sub("THE", "", comicnm) else: modwatchcomic = watchcomic modcomicnm = comicnm # thnx to A+X for this... if "+" in watchcomic: logger.fdebug("+ detected...adjusting.") logger.fdebug("comicnm:" + comicnm) logger.fdebug("watchcomic:" + watchcomic) modwatchcomic = re.sub("\+", "PLUS", modwatchcomic) logger.fdebug("modcomicnm:" + modcomicnm) logger.fdebug("modwatchcomic:" + modwatchcomic) if comicnm == watchcomic.upper() or modcomicnm == modwatchcomic.upper(): logger.fdebug("matched on:" + str(comicnm) + "..." + str(watchcomic).upper()) pass elif "ANNUAL" in week["EXTRA"]: pass # print ( row[3] + " matched on ANNUAL") else: break if ("NA" not in week["ISSUE"]) and ("HC" not in week["ISSUE"]): if ( ("COMBO PACK" not in week["EXTRA"]) and ("2ND PTG" not in week["EXTRA"]) and ("3RD PTG" not in week["EXTRA"]) ): otot += 1 dontadd = "no" if dontadd == "no": # print (row[0], row[1], row[2]) tot += 1 # kp.append(row[0]) # ki.append(row[1]) # kc.append(comicnm) if "ANNUAL" in week["EXTRA"]: watchfndextra.append("annual") else: watchfndextra.append("none") watchfnd.append(comicnm) watchfndiss.append(week["ISSUE"]) ComicID = comicid[cnt] if not mylar.CV_ONLY: ComicIssue = str(watchfndiss[tot - 1] + ".00") else: ComicIssue = str(watchfndiss[tot - 1]) ComicDate = str(week["SHIPDATE"]) ComicName = str(unlines[cnt]) logger.fdebug( "Watchlist hit for : " + ComicName + " ISSUE: " + str(watchfndiss[tot - 1]) ) # here we add to comics.latest updater.latest_update( ComicID=ComicID, LatestIssue=ComicIssue, LatestDate=ComicDate ) # here we add to upcoming table... statusupdate = updater.upcoming_update( ComicID=ComicID, ComicName=ComicName, IssueNumber=ComicIssue, IssueDate=ComicDate, forcecheck=forcecheck, ) # here we update status of weekly table... updater.weekly_update( ComicName=week["COMIC"], IssueNumber=ComicIssue, CStatus=statusupdate ) break break break cnt -= 1 # print ("-------------------------") logger.fdebug("There are " + str(otot) + " comics this week to get!") # print ("However I've already grabbed " + str(btotal) ) # print ("I need to get " + str(tot) + " comic(s)!" ) logger.info(u"Finished checking for comics on my watchlist.") # con.close() return
def pullitcheck(): myDB = db.DBConnection() not_t = ['TP', 'NA', 'HC', 'PI'] not_c = ['PTG', 'COMBO PACK', '(PP #'] lines = [] unlines = [] llen = [] ccname = [] w = 0 tot = 0 chkout = [] watchfnd = [] watchfndiss = [] watchfndextra = [] #print ("----------WATCHLIST--------") a_list = [] b_list = [] comicid = [] mylardb = os.path.join(mylar.DATA_DIR, "mylar.db") con = sqlite3.connect(str(mylardb)) with con: cur = con.cursor() #let's read in the comic.watchlist from the db here cur.execute("SELECT ComicID, ComicName, ComicYear, ComicPublisher from comics") while True: watchd = cur.fetchone() if watchd == None: break a_list.append(watchd[1]) b_list.append(watchd[2]) comicid.append(watchd[0]) #print ( "Comic:" + str(a_list[w]) + " Year: " + str(b_list[w]) ) if "WOLVERINE AND THE X-MEN" in str(a_list[w]): a_list[w] = "WOLVERINE AND X-MEN" lines.append(a_list[w].strip()) unlines.append(a_list[w].strip()) llen.append(a_list[w].splitlines()) ccname.append(a_list[w].strip()) tmpwords = a_list[w].split(None) ltmpwords = len(tmpwords) ltmp = 1 w+=1 cnt = int(w-1) cntback = int(w-1) kp = [] ki = [] kc = [] otot = 0 #print ("You are watching for: " + str(w) + " comics") #print ("----------THIS WEEK'S PUBLISHED COMICS------------") if w > 0: while (cnt > -1): lines[cnt] = str(lines[cnt]).upper() llen[cnt] = str(llen[cnt]) #print ("looking for : " + str(lines[cnt])) weekly = myDB.select('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [lines[cnt]]) #cur.execute('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [lines[cnt]]) for week in weekly: if week == None: break for nono in not_t: if nono in week['PUBLISHER']: #print ("nono present") break for nothere in not_c: if nothere in week['EXTRA']: #print ("nothere present") break else: comicnm = week['COMIC'] #here's the tricky part, ie. BATMAN will match on #every batman comic, not exact #print ("comparing" + str(comicnm) + "..to.." + str(unlines[cnt]).upper()) if str(comicnm) == str(unlines[cnt]).upper(): #print ("matched on:") pass elif ("ANNUAL" in week['EXTRA']): pass #print ( row[3] + " matched on ANNUAL") else: #print ( row[2] + " not an EXACT match...") break if "WOLVERINE AND X-MEN" in str(comicnm): comicnm = "WOLVERINE AND THE X-MEN" #print ("changed wolvy") if ("NA" not in week['ISSUE']) and ("HC" not in week['ISSUE']): if ("COMBO PACK" not in week['EXTRA']) and ("2ND PTG" not in week['EXTRA']) and ("3RD PTG" not in week['EXTRA']): otot+=1 dontadd = "no" if dontadd == "no": #print (row[0], row[1], row[2]) tot+=1 #kp.append(row[0]) #ki.append(row[1]) #kc.append(comicnm) if ("ANNUAL" in week['EXTRA']): watchfndextra.append("annual") else: watchfndextra.append("none") watchfnd.append(comicnm) watchfndiss.append(week['ISSUE']) ComicID = comicid[cnt] ComicIssue = str(watchfndiss[tot -1] + ".00") ComicDate = str(week['SHIPDATE']) ComicName = str(unlines[cnt]) #print ("added: " + str(watchfnd[tot -1]) + " ISSUE: " + str(watchfndiss[tot -1])) # here we add to comics.latest updater.latest_update(ComicID=ComicID, LatestIssue=ComicIssue, LatestDate=ComicDate) # here we add to upcoming table... updater.upcoming_update(ComicID=ComicID, ComicName=ComicName, IssueNumber=ComicIssue, IssueDate=ComicDate) # here we update status of weekly table... updater.weekly_update(ComicName=comicnm) break break break cnt-=1 #print ("-------------------------") #print ("There are " + str(otot) + " comics this week to get!") #print ("However I've already grabbed " + str(btotal) ) #print ("I need to get " + str(tot) + " comic(s)!" ) #con.close() return
def pullitcheck(comic1off_name=None,comic1off_id=None): logger.info(u"Checking the Weekly Releases list for comics I'm watching...") myDB = db.DBConnection() not_t = ['TP', 'NA', 'HC', 'PI'] not_c = ['PTG', 'COMBO PACK', '(PP #'] lines = [] unlines = [] llen = [] ccname = [] pubdate = [] w = 0 tot = 0 chkout = [] watchfnd = [] watchfndiss = [] watchfndextra = [] #print ("----------WATCHLIST--------") a_list = [] b_list = [] comicid = [] mylardb = os.path.join(mylar.DATA_DIR, "mylar.db") con = sqlite3.connect(str(mylardb)) with con: cur = con.cursor() # if it's a one-off check (during an add series), load the comicname here and ignore below. if comic1off_name: lines.append(comic1off_name.strip()) unlines.append(comic1off_name.strip()) comicid.append(comic1off_id) w = 1 else: #let's read in the comic.watchlist from the db here cur.execute("SELECT ComicID, ComicName, ComicYear, ComicPublisher, ComicPublished from comics") while True: watchd = cur.fetchone() #print ("watchd: " + str(watchd)) if watchd is None: break if 'Present' in watchd[4]: # let's not even bother with comics that are in the Present. a_list.append(watchd[1]) b_list.append(watchd[2]) comicid.append(watchd[0]) pubdate.append(watchd[4]) #print ( "Comic:" + str(a_list[w]) + " Year: " + str(b_list[w]) ) #if "WOLVERINE AND THE X-MEN" in str(a_list[w]): a_list[w] = "WOLVERINE AND X-MEN" lines.append(a_list[w].strip()) unlines.append(a_list[w].strip()) llen.append(a_list[w].splitlines()) ccname.append(a_list[w].strip()) tmpwords = a_list[w].split(None) ltmpwords = len(tmpwords) ltmp = 1 w+=1 cnt = int(w-1) cntback = int(w-1) kp = [] ki = [] kc = [] otot = 0 logger.fdebug("You are watching for: " + str(w) + " comics") #print ("----------THIS WEEK'S PUBLISHED COMICS------------") if w > 0: while (cnt > -1): lines[cnt] = str(lines[cnt]).upper() #llen[cnt] = str(llen[cnt]) logger.fdebug("looking for : " + str(lines[cnt])) sqlsearch = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\+\'\?\@]', ' ', str(lines[cnt])) sqlsearch = re.sub(r'\s', '%', sqlsearch) if 'THE' in sqlsearch: sqlsearch = re.sub('THE', '', sqlsearch) logger.fdebug("searchsql: " + str(sqlsearch)) weekly = myDB.select('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [sqlsearch]) #cur.execute('SELECT PUBLISHER, ISSUE, COMIC, EXTRA, SHIPDATE FROM weekly WHERE COMIC LIKE (?)', [lines[cnt]]) for week in weekly: if week == None: break for nono in not_t: if nono in week['PUBLISHER']: logger.fdebug("nono present") break if nono in week['ISSUE']: logger.fdebug("graphic novel/tradeback detected..ignoring.") break for nothere in not_c: if nothere in week['EXTRA']: logger.fdebug("nothere present") break else: comicnm = week['COMIC'] #here's the tricky part, ie. BATMAN will match on #every batman comic, not exact # logger.fdebug("comparing" + str(comicnm) + "..to.." + str(unlines[cnt]).upper()) logger.fdebug("comparing" + str(sqlsearch) + "..to.." + str(unlines[cnt]).upper()) #-NEW- # strip out all special characters and compare watchcomic = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\+\'\?\@]', '', str(sqlsearch)) comicnm = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\&\+\'\?\@]', '', str(comicnm)) watchcomic = re.sub(r'\s', '', watchcomic) comicnm = re.sub(r'\s', '', comicnm) modcomicnm = '' logger.fdebug("Revised_Watch: " + str(watchcomic)) logger.fdebug("ComicNM: " + str(comicnm)) if 'THE' in str(watchcomic): modcomicnm = re.sub('THE', '', comicnm) if str(comicnm) == str(watchcomic).upper() or str(modcomicnm) == str(watchcomic).upper(): logger.fdebug("matched on:" + str(comicnm) + "..." + str(watchcomic).upper()) #pass elif ("ANNUAL" in week['EXTRA']): pass #print ( row[3] + " matched on ANNUAL") else: if 'THE' in str(comicnm): modcomicnm = re.sub('THE', '', comicnm) #print ( row[2] + " not an EXACT match...") break #if "WOLVERINE AND X-MEN" in str(comicnm): # comicnm = "WOLVERINE AND THE X-MEN" #print ("changed wolvy") if ("NA" not in week['ISSUE']) and ("HC" not in week['ISSUE']): if ("COMBO PACK" not in week['EXTRA']) and ("2ND PTG" not in week['EXTRA']) and ("3RD PTG" not in week['EXTRA']): otot+=1 dontadd = "no" if dontadd == "no": #print (row[0], row[1], row[2]) tot+=1 #kp.append(row[0]) #ki.append(row[1]) #kc.append(comicnm) if ("ANNUAL" in week['EXTRA']): watchfndextra.append("annual") else: watchfndextra.append("none") watchfnd.append(comicnm) watchfndiss.append(week['ISSUE']) ComicID = comicid[cnt] ComicIssue = str(watchfndiss[tot -1] + ".00") ComicDate = str(week['SHIPDATE']) ComicName = str(unlines[cnt]) logger.fdebug("Watchlist hit for : " + str(ComicName) + " ISSUE: " + str(watchfndiss[tot -1])) # here we add to comics.latest updater.latest_update(ComicID=ComicID, LatestIssue=ComicIssue, LatestDate=ComicDate) # here we add to upcoming table... updater.upcoming_update(ComicID=ComicID, ComicName=ComicName, IssueNumber=ComicIssue, IssueDate=ComicDate) # here we update status of weekly table... updater.weekly_update(ComicName=week['COMIC']) break break break cnt-=1 #print ("-------------------------") logger.fdebug("There are " + str(otot) + " comics this week to get!") #print ("However I've already grabbed " + str(btotal) ) #print ("I need to get " + str(tot) + " comic(s)!" ) logger.info(u"Finished checking for comics on my watchlist.") #con.close() return