diff --git a/mylar/filechecker.py b/mylar/filechecker.py index e9471a50..23cb3c38 100755 --- a/mylar/filechecker.py +++ b/mylar/filechecker.py @@ -145,59 +145,70 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None,sarc=None): charpos = 0 detneg = "no" leavehyphen = False - for nono in not_these: - if nono in subname: - subcnt = subname.count(nono) - charpos = indices(subname,nono) # will return a list of char positions in subname - #print "charpos: " + str(charpos) - if nono == '-': - i=0 - while (i < len(charpos)): - for i,j in enumerate(charpos): - #print i,j - if subname[j+1:j+2].isdigit(): - logger.fdebug('possible negative issue detected.') - nonocount = nonocount + subcnt - 1 - detneg = "yes" - elif '-' in watchcomic and i < len(watchcomic): - logger.fdebug('- appears in series title.') - leavehyphen = True - i+=1 - if detneg == "no" or leavehyphen == False: - subname = re.sub(str(nono), ' ', subname) - nonocount = nonocount + subcnt + should_restart = True + while should_restart: + should_restart = False + for nono in not_these: + if nono in subname: + subcnt = subname.count(nono) + charpos = indices(subname,nono) # will return a list of char positions in subname + #print "charpos: " + str(charpos) + if nono == '-': + i=0 + while (i < len(charpos)): + for i,j in enumerate(charpos): + if j+2 > len(subname): + sublimit = subname[j+1:] + else: + sublimit = subname[j+1:j+2] + if sublimit.isdigit(): + logger.fdebug('possible negative issue detected.') + nonocount = nonocount + subcnt - 1 + detneg = "yes" + elif '-' in watchcomic and i < len(watchcomic): + logger.fdebug('- appears in series title.') + logger.fdebug('up to - :' + subname[:j+1].replace('-', ' ')) + logger.fdebug('after - :' + subname[j+1:]) + subname = subname[:j+1].replace('-', ' ') + subname[j+1:] + logger.fdebug('new subname is : ' + str(subname)) + should_restart = True + leavehyphen = True + i+=1 + if detneg == "no" or leavehyphen == False: + subname = re.sub(str(nono), ' ', subname) + nonocount = nonocount + subcnt #logger.fdebug(str(nono) + " detected " + str(subcnt) + " times.") # segment '.' having a . by itself will denote the entire string which we don't want - elif nono == '.': - x = 0 - fndit = 0 - dcspace = 0 - while x < subcnt: - fndit = subname.find(nono, fndit) - if subname[fndit-1:fndit].isdigit() and subname[fndit+1:fndit+2].isdigit(): - logger.fdebug('decimal issue detected.') - dcspace+=1 - x+=1 - if dcspace == 1: - nonocount = nonocount + subcnt + dcspace + elif nono == '.': + x = 0 + fndit = 0 + dcspace = 0 + while x < subcnt: + fndit = subname.find(nono, fndit) + if subname[fndit-1:fndit].isdigit() and subname[fndit+1:fndit+2].isdigit(): + logger.fdebug('decimal issue detected.') + dcspace+=1 + x+=1 + if dcspace == 1: + nonocount = nonocount + subcnt + dcspace + else: + subname = re.sub('\.', ' ', subname) + nonocount = nonocount + subcnt - 1 #(remove the extension from the length) else: - subname = re.sub('\.', ' ', subname) - nonocount = nonocount + subcnt - 1 #(remove the extension from the length) - else: - #this is new - if it's a symbol seperated by a space on each side it drags in an extra char. - x = 0 - fndit = 0 - blspc = 0 - while x < subcnt: - fndit = subname.find(nono, fndit) - #print ("space before check: " + str(subname[fndit-1:fndit])) - #print ("space after check: " + str(subname[fndit+1:fndit+2])) - if subname[fndit-1:fndit] == ' ' and subname[fndit+1:fndit+2] == ' ': - logger.fdebug('blankspace detected before and after ' + str(nono)) - blspc+=1 - x+=1 - subname = re.sub(str(nono), ' ', subname) - nonocount = nonocount + subcnt + blspc + #this is new - if it's a symbol seperated by a space on each side it drags in an extra char. + x = 0 + fndit = 0 + blspc = 0 + while x < subcnt: + fndit = subname.find(nono, fndit) + #print ("space before check: " + str(subname[fndit-1:fndit])) + #print ("space after check: " + str(subname[fndit+1:fndit+2])) + if subname[fndit-1:fndit] == ' ' and subname[fndit+1:fndit+2] == ' ': + logger.fdebug('blankspace detected before and after ' + str(nono)) + blspc+=1 + x+=1 + subname = re.sub(str(nono), ' ', subname) + nonocount = nonocount + subcnt + blspc #subname = re.sub('[\_\#\,\/\:\;\.\-\!\$\%\+\'\?\@]',' ', subname) modwatchcomic = re.sub('[\_\#\,\/\:\;\.\!\$\%\'\?\@\-]', ' ', u_watchcomic) @@ -391,6 +402,18 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None,sarc=None): if a4dec.isdigit() and b4dec.isdigit(): logger.fdebug('DECIMAL ISSUE DETECTED') digitsvalid = "true" + else: + try: + x = float(justthedigits) + #validity check + if x < 0: + logger.info("I've encountered a negative issue #: " + str(justthedigits) + ". Trying to accomodate.") + digitsvalid = "true" + else: raise ValueError + except ValueError, e: + logger.info('Cannot determine issue number from given issue #: ' + str(justthedigits)) + + # else: # logger.fdebug('NO DECIMALS DETECTED') # digitsvalid = "false" diff --git a/mylar/helpers.py b/mylar/helpers.py index 85554dce..a805434f 100755 --- a/mylar/helpers.py +++ b/mylar/helpers.py @@ -665,7 +665,7 @@ def cleanhtml(raw_html): def issuedigits(issnum): import db, logger #print "issnum : " + str(issnum) - if issnum.isdigit(): + if str(issnum).isdigit(): int_issnum = int( issnum ) * 1000 else: if 'au' in issnum.lower() and issnum[:1].isdigit(): diff --git a/mylar/importer.py b/mylar/importer.py index d5623609..6183164e 100755 --- a/mylar/importer.py +++ b/mylar/importer.py @@ -868,6 +868,8 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None,c else: logger.info('Already have the latest issue : #' + str(latestiss)) + if calledfrom == 'addbyid': + return comic['ComicName'], SeriesYear def GCDimport(gcomicid, pullupd=None,imported=None,ogcname=None): # this is for importing via GCD only and not using CV. diff --git a/mylar/rsscheck.py b/mylar/rsscheck.py index c9f7e146..9d52af5e 100755 --- a/mylar/rsscheck.py +++ b/mylar/rsscheck.py @@ -271,7 +271,7 @@ def nzbs(provider=None): elif nzbprovider[nzbpr] == 'dognzb': if mylar.DOGNZB_UID is None: mylar.DOGNZB_UID = '1' - feed = 'http://dognzb.cr/rss?t=7030&dl=1&i=' + mylar.DOGNZB_UID + '&r=' + mylar.DOGNZB_APIKEY + feed = 'https://dognzb.cr/rss.cfm?r=' + mylar.DOGNZB_APIKEY + '&t=7030' feedme = feedparser.parse(feed) site = nzbprovider[nzbpr] ft+=1 diff --git a/mylar/search.py b/mylar/search.py index 06897a15..8d924e72 100755 --- a/mylar/search.py +++ b/mylar/search.py @@ -39,7 +39,7 @@ import urllib2 from datetime import datetime def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueID, AlternateSearch=None, UseFuzzy=None, ComicVersion=None, SARC=None, IssueArcID=None, mode=None, rsscheck=None, ComicID=None): - if ComicYear == None: ComicYear = '2013' + if ComicYear == None: ComicYear = '2014' else: ComicYear = str(ComicYear)[:4] if mode == 'want_ann': @@ -134,9 +134,9 @@ def search_init(ComicName, IssueNumber, ComicYear, SeriesYear, IssueDate, IssueI # end provider order sequencing - #fix for issue dates between Nov-Dec/Jan + #fix for issue dates between Nov-Dec/(Jan-Feb-Mar) IssDt = str(IssueDate)[5:7] - if IssDt == "12" or IssDt == "11" or IssDt == "01" or IssDt == "02": + if IssDt == "12" or IssDt == "11" or IssDt == "01" or IssDt == "02" or IssDt == "03": IssDateFix = IssDt else: IssDateFix = "no" @@ -628,15 +628,19 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is #bypass for local newznabs #remove the protocol string (http/https) - if host_newznab_fix.startswith('http'): - hnc = host_newznab_fix.replace('http://', '') - elif host_newznab_fix.startswith('https'): - hnc = host_newznab_fix.replace('https://', '') - else: - hnc = host_newznab_fix - if nzbprov == 'newznab' and (hnc[:3] == '10.' or hnc[:4] == '172.' or hnc[:4] == '192.' or hnc.startswith('localhost')): - pass - else: + localbypass = False + if nzbprov == 'newznab': + if host_newznab_fix.startswith('http'): + hnc = host_newznab_fix.replace('http://', '') + elif host_newznab_fix.startswith('https'): + hnc = host_newznab_fix.replace('https://', '') + else: + hnc = host_newznab_fix + + if hnc[:3] == '10.' or hnc[:4] == '172.' or hnc[:4] == '192.' or hnc.startswith('localhost'): + localbypass = True + + if localbypass == False: logger.info("pausing for " + str(pause_the_search) + " seconds before continuing to avoid hammering") time.sleep(pause_the_search) @@ -833,7 +837,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is #let's do this here and save a few extra loops ;) #fix for issue dates between Nov-Dec/Jan if IssDateFix != "no" and UseFuzzy is not "2": - if IssDateFix == "01" or IssDateFix == "02": ComicYearFix = int(ComicYear) - 1 + if IssDateFix == "01" or IssDateFix == "02" or IssDateFix == "03": ComicYearFix = int(ComicYear) - 1 else: ComicYearFix = int(ComicYear) + 1 if str(ComicYearFix) in result_comyear: logger.fdebug("further analysis reveals this was published inbetween Nov-Jan, incrementing year to " + str(ComicYearFix) + " has resulted in a match!") @@ -1128,7 +1132,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is elif nzbprov == 'KAT': url_parts = urlparse.urlparse(entry['link']) path_parts = url_parts[2].rpartition('/') - nzbtempid = pathparts[2] + nzbtempid = path_parts[2] nzbid = re.sub('.torrent', '', nzbtempid).rstrip() elif nzbprov == 'nzb.su': pass diff --git a/mylar/updater.py b/mylar/updater.py index f9a9b781..b7040153 100755 --- a/mylar/updater.py +++ b/mylar/updater.py @@ -755,7 +755,7 @@ def forceRescan(ComicID,archive=None): else: for chk in chkthis: old_status = chk['Status'] - logger.fdebug('old_status:' + str(old_status)) + #logger.fdebug('old_status:' + str(old_status)) if old_status == "Skipped": if mylar.AUTOWANT_ALL: issStatus = "Wanted" @@ -774,7 +774,7 @@ def forceRescan(ComicID,archive=None): else: issStatus = "Skipped" - logger.fdebug("new status: " + str(issStatus)) + #logger.fdebug("new status: " + str(issStatus)) update_iss.append({"IssueID": chk['IssueID'], "Status": issStatus}) diff --git a/mylar/webserve.py b/mylar/webserve.py index a368f18d..bf24c4ff 100755 --- a/mylar/webserve.py +++ b/mylar/webserve.py @@ -279,7 +279,11 @@ class WebInterface(object): mismatch = "no" logger.info('Attempting to add directly by ComicVineID: ' + str(comicid)) if comicid.startswith('4050-'): comicid = re.sub('4050-','', comicid) - importer.addComictoDB(comicid,mismatch) + comicname, year = importer.addComictoDB(comicid,mismatch) + if comicname is None: + logger.error('There was an error during the add, check the mylar.log file for futher details.') + else: + logger.info('Sucessfully added ' + comicname + ' (' + str(year) + ') to your watchlist') raise cherrypy.HTTPRedirect("home") addbyid.exposed = True @@ -1904,10 +1908,13 @@ class WebInterface(object): implog = implog + "adding..." + str(result['ComicYear']) + "\n" yearRANGE.append(result['ComicYear']) yearTOP = str(result['ComicYear']) - if int(getiss) > int(minISSUE): + getiss_num = helpers.issuedigits(getiss) + miniss_num = helpers.issuedigits(minISSUE) + startiss_num = helpers.issuedigits(startISSUE) + if int(getiss_num) > int(miniss_num): implog = implog + "issue now set to : " + str(getiss) + " ... it was : " + str(minISSUE) + "\n" minISSUE = str(getiss) - if int(getiss) < int(startISSUE): + if int(getiss_num) < int(startiss_num): implog = implog + "issue now set to : " + str(getiss) + " ... it was : " + str(startISSUE) + "\n" startISSUE = str(getiss)