FIX:(#533) Decimal issues not detected when filescanning, FIX:(#532) Decimal issues/Annuals count not being included in count totals, FIX: During Post-Processing, if decimal issue MetaTagging would error out, IMP: Removed some verbose logging in file checker

This commit is contained in:
evilhero 2013-09-09 00:39:08 -04:00
parent 9491d5f9ca
commit 5859b17e5e
4 changed files with 79 additions and 43 deletions

View File

@ -213,7 +213,8 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
if filename.endswith('.cbr'):
f = os.path.join( comicpath, filename)
base = os.path.splitext( f )[0]
shutil.move( f, base + ".rar" )
baserar = base + ".rar"
shutil.move( f, baserar )
## Changes any cbr files to cbz files for insertion of metadata ##
if file_conversion:
@ -227,11 +228,11 @@ def run (dirName, nzbName=None, issueid=None, manual=None, filename=None):
os.chdir( unrar_folder )
# Extract and zip up
logger.fdebug('{0}: Comicpath is ' + os.path.join(comicpath,basename))
logger.fdebug('{0}: Comicpath is ' + baserar) #os.path.join(comicpath,basename))
logger.fdebug('{0}: Unrar is ' + unrar_folder )
try:
#subprocess.Popen( [ unrar_cmd, "x", os.path.join(comicpath,basename) ] ).communicate()
output = check_output( [ unrar_cmd, "x", os.path.join(comicpath,basename) ] )
output = check_output( [ unrar_cmd, "x", baserar ] ) #os.path.join(comicpath,basename) ] )
except CalledProcessError as e:
if e.returncode == 3:
logger.fdebug('[Unrar Error 3] - Broken Archive.')

View File

@ -67,6 +67,7 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None):
#print item
#subname = os.path.join(basedir, item)
subname = item
#versioning - remove it
subsplit = subname.replace('_', ' ').split()
volrem = None
@ -261,9 +262,9 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None):
logger.fdebug('after title removed from FILENAME [' + str(item[jtd_len:]) + ']')
logger.fdebug('creating just the digits using SUBNAME, pruning first [' + str(jtd_len) + '] chars from [' + subname + ']')
justthedigits = subname[jtd_len:].strip()
justthedigits_1 = subname[jtd_len:].strip()
logger.fdebug('after title removed from SUBNAME [' + justthedigits + ']')
logger.fdebug('after title removed from SUBNAME [' + justthedigits_1 + ']')
#remove the title if it appears
#findtitle = justthedigits.find('-')
@ -271,43 +272,68 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None):
# justthedigits = justthedigits[:findtitle]
# logger.fdebug("removed title from name - is now : " + str(justthedigits))
tmpthedigits = justthedigits
justthedigits = justthedigits.split(' ', 1)[0]
justthedigits = justthedigits_1.split(' ', 1)[0]
try:
tmpthedigits = justthedigits_1.split(' ', 1)[1]
logger.fdebug('If the series has a decimal, this should be a number [' + tmpthedigits + ']')
if 'cbr' in tmpthedigits.lower() or 'cbz' in tmpthedigits.lower():
tmpthedigits = tmpthedigits[:-3].strip()
logger.fdebug('Removed extension - now we should just have a number [' + tmpthedigits + ']')
poss_alpha = tmpthedigits
if poss_alpha.isdigit():
digitsvalid = "true"
if justthedigits.lower() == 'annual':
logger.fdebug('ANNUAL DETECTED [' + poss_alpha + ']')
justthedigits += ' ' + poss_alpha
digitsvalid = "true"
else:
justthedigits += '.' + poss_alpha
logger.fdebug('DECIMAL ISSUE DETECTED [' + justthedigits + ']')
else:
for issexcept in issue_exceptions:
if issexcept.lower() in poss_alpha.lower() and len(poss_alpha) <= len(issexcept):
justthedigits += poss_alpha
logger.fdebug('ALPHANUMERIC EXCEPTION. COMBINING : [' + justthedigits + ']')
digitsvalid = "true"
break
except:
tmpthedigits = None
# justthedigits = justthedigits.split(' ', 1)[0]
#if the issue has an alphanumeric (issue_exceptions, join it and push it through)
logger.fdebug('JUSTTHEDIGITS [' + justthedigits + ']' )
if justthedigits.isdigit():
digitsvalid = "true"
else:
if '.' in justthedigits:
logger.fdebug("decimals")
digitsvalid = "true"
else:
logger.fdebug("no decimals")
digitsvalid = "false"
# else:
# if '.' in justthedigits:
# logger.fdebug('DECIMAL ISSUE DETECTED')
# digitsvalid = "true"
# else:
# logger.fdebug('NO DECIMALS DETECTED')
# digitsvalid = "false"
if justthedigits.lower() == 'annual':
logger.fdebug('ANNUAL [' + tmpthedigits.split(' ', 1)[1] + ']')
justthedigits += ' ' + tmpthedigits.split(' ', 1)[1]
digitsvalid = "true"
else:
try:
if tmpthedigits.split(' ', 1)[1] is not None:
poss_alpha = tmpthedigits.split(' ', 1)[1]
if poss_alpha.isdigit():
logger.fdebug("decimal issue detected (filename space seperate most likely '.')")
digitsvalid = "true"
justthedigits += '.' + poss_alpha
for issexcept in issue_exceptions:
if issexcept.lower() in poss_alpha.lower() and len(poss_alpha) <= len(issexcept):
justthedigits += poss_alpha
logger.fdebug('ALPHANUMERIC EXCEPTION. COMBINING : [' + justthedigits + ']')
digitsvalid = "true"
break
except:
pass
# if justthedigits.lower() == 'annual':
# logger.fdebug('ANNUAL [' + tmpthedigits.split(' ', 1)[1] + ']')
# justthedigits += ' ' + tmpthedigits.split(' ', 1)[1]
# digitsvalid = "true"
# else:
# try:
# if tmpthedigits.isdigit(): #.split(' ', 1)[1] is not None:
# poss_alpha = tmpthedigits#.split(' ', 1)[1]
# if poss_alpha.isdigit():
# digitsvalid = "true"
# justthedigits += '.' + poss_alpha
# logger.fdebug('DECIMAL ISSUE DETECTED [' + justthedigits + ']')
# for issexcept in issue_exceptions:
# if issexcept.lower() in poss_alpha.lower() and len(poss_alpha) <= len(issexcept):
# justthedigits += poss_alpha
# logger.fdebug('ALPHANUMERIC EXCEPTION. COMBINING : [' + justthedigits + ']')
# digitsvalid = "true"
# break
# except:
# pass
logger.fdebug('final justthedigits [' + justthedigits + ']')
if digitsvalid == "false":
@ -318,6 +344,10 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None):
if manual is not None:
#this is needed for Manual Run to determine matches
#without this Batman will match on Batman Incorporated, and Batman and Robin, etc..
# in case it matches on an Alternate Search pattern, set modwatchcomic to the cchk value
modwatchcomic = cchk
logger.fdebug('cchk = ' + cchk.lower())
logger.fdebug('modwatchcomic = ' + modwatchcomic.lower())
logger.fdebug('subname = ' + subname.lower())
comyear = manual['SeriesYear']
@ -389,7 +419,7 @@ def listFiles(dir,watchcomic,AlternateSearch=None,manual=None):
logger.fdebug('number of words do not match...aborting.')
else:
while ( x > -1 ):
print str(split_mod[x]) + ' comparing to ' + str(split_mod[x])
print str(split_sub[x]) + ' comparing to ' + str(split_mod[x])
if str(split_sub[x]).lower() == str(split_mod[x]).lower():
scnt+=1
logger.fdebug('word match exact. ' + str(scnt) + '/' + str(len(split_mod)))

View File

@ -646,7 +646,7 @@ def issuedigits(issnum):
issnum = .75
int_issnum = int(issnum) * 1000
elif '.' in issnum or ',' in issnum:
logger.fdebug('decimal detected.')
#logger.fdebug('decimal detected.')
if ',' in issnum: issnum = re.sub(',','.', issnum)
issst = str(issnum).find('.')
issb4dec = str(issnum)[:issst]

View File

@ -437,6 +437,11 @@ def forceRescan(ComicID,archive=None):
fc = filechecker.listFiles(dir=archive, watchcomic=rescan['ComicName'], AlternateSearch=rescan['AlternateSearch'])
iscnt = rescan['Total']
havefiles = 0
if mylar.ANNUALS_ON:
an_cnt = myDB.action("SELECT COUNT(*) FROM annuals WHERE ComicID=?", [ComicID]).fetchall()
anncnt = an_cnt[0][0]
else:
anncnt = 0
fccnt = int(fc['comiccount'])
issnum = 1
fcnew = []
@ -561,8 +566,8 @@ def forceRescan(ComicID,archive=None):
fcdigit = helpers.issuedigits(fcnew[som])
logger.fdebug("fcdigit: " + str(fcdigit))
logger.fdebug("int_iss: " + str(int_iss))
#logger.fdebug("fcdigit: " + str(fcdigit))
#logger.fdebug("int_iss: " + str(int_iss))
if int(fcdigit) == int_iss:
logger.fdebug('issue match - fcdigit: ' + str(fcdigit) + ' ... int_iss: ' + str(int_iss))
@ -605,10 +610,8 @@ def forceRescan(ComicID,archive=None):
# annual inclusion here.
#logger.fdebug("checking " + str(temploc))
reannuals = myDB.action('SELECT * FROM annuals WHERE ComicID=?', [ComicID]).fetchall()
an_cnt = myDB.action("SELECT COUNT(*) FROM issues WHERE ComicID=?", [ComicID]).fetchall()
fcnew = shlex.split(str(temploc))
fcn = len(fcnew)
anncnt = an_cnt[0][0]
n = 0
while (n < anncnt):
som = 0
@ -801,7 +804,9 @@ def forceRescan(ComicID,archive=None):
newValueStat = {"Have": havefiles
}
combined_total = rescan['Total'] + anncnt
myDB.upsert("comics", newValueStat, controlValueStat)
logger.info('I have physically found ' + str(foundcount) + ' issues, ignored ' + str(ignorecount) + ' issues, and accounted for ' + str(totalarc) + ' in an Archived state. Total Issue Count: ' + str(havefiles) + ' / ' + str(rescan['Total']))
logger.info('I have physically found ' + str(foundcount) + ' issues, ignored ' + str(ignorecount) + ' issues, and accounted for ' + str(totalarc) + ' in an Archived state. Total Issue Count: ' + str(havefiles) + ' / ' + str(combined_total))
return