FIX: Added unicode option for issue number retention in config.ini as UNICODE_ISSUENUMBERS (enabling will retain unicode issue numbers in filename, not enabling will convert to normal numbering if possible), FIX: Fixed some problems with the weekly pull not properly refreshing series that were on the pullist in order to be correctly marked as Wanted.

This commit is contained in:
evilhero 2017-09-20 17:21:33 -04:00
parent c6a7f4dbdf
commit 6294bb7476
4 changed files with 61 additions and 39 deletions

View File

@ -261,6 +261,7 @@ LOG_LEVEL = None
POST_PROCESSING = 1
POST_PROCESSING_SCRIPT = None
FILE_OPTS = None
UNICODE_ISSUENUMBER = False
NZB_DOWNLOADER = None #0 = sabnzbd, #1 = nzbget, #2 = blackhole
@ -548,7 +549,7 @@ def initialize():
PUSHBULLET_ENABLED, PUSHBULLET_APIKEY, PUSHBULLET_DEVICEID, PUSHBULLET_CHANNEL_TAG, PUSHBULLET_ONSNATCH, LOCMOVE, NEWCOM_DIR, FFTONEWCOM_DIR, \
PREFERRED_QUALITY, MOVE_FILES, RENAME_FILES, LOWERCASE_FILENAMES, USE_MINSIZE, MINSIZE, USE_MAXSIZE, MAXSIZE, CORRECT_METADATA, \
FOLDER_FORMAT, SETDEFAULTVOLUME, FILE_FORMAT, REPLACE_CHAR, REPLACE_SPACES, ADD_TO_CSV, CVINFO, LOG_LEVEL, POST_PROCESSING, POST_PROCESSING_SCRIPT, \
FILE_OPTS, SEARCH_DELAY, GRABBAG_DIR, READ2FILENAME, SEND2READ, MAINTAINSERIESFOLDER, TAB_ENABLE, TAB_HOST, TAB_USER, TAB_PASS, TAB_DIRECTORY, \
FILE_OPTS, UNICODE_ISSUENUMBER, SEARCH_DELAY, GRABBAG_DIR, READ2FILENAME, SEND2READ, MAINTAINSERIESFOLDER, TAB_ENABLE, TAB_HOST, TAB_USER, TAB_PASS, TAB_DIRECTORY, \
STORYARCDIR, COPY2ARCDIR, ARC_FOLDERFORMAT, ARC_FILEOPS, CVURL, CV_VERIFY, CHECK_FOLDER, ENABLE_CHECK_FOLDER, \
COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_SNATCH_SCRIPT, SNATCH_SCRIPT, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS, PULLNEW, ALT_PULL, PULLBYFILE, COUNT_ISSUES, COUNT_HAVES, COUNT_COMICS, \
SYNO_FIX, ENFORCE_PERMS, CHMOD_FILE, CHMOD_DIR, CHOWNER, CHGROUP, ANNUALS_ON, CV_ONLY, CV_ONETIMER, CURRENT_WEEKNUMBER, CURRENT_YEAR, PULL_REFRESH, WEEKFOLDER, WEEKFOLDER_LOC, WEEKFOLDER_FORMAT, UMASK, \
@ -770,6 +771,7 @@ def initialize():
ENABLE_META = 0
else:
ENABLE_META = bool(check_setting_int(CFG, 'General', 'enable_meta', 0))
UNICODE_ISSUENUMBER = bool(check_setting_int(CFG, 'General', 'unicode_issuenumber', 0))
CBR2CBZ_ONLY = bool(check_setting_int(CFG, 'General', 'cbr2cbz_only', 0))
CT_TAG_CR = bool(check_setting_int(CFG, 'General', 'ct_tag_cr', 1))
CT_TAG_CBL = bool(check_setting_int(CFG, 'General', 'ct_tag_cbl', 1))
@ -1563,6 +1565,7 @@ def config_write():
new_config['General']['post_processing'] = int(POST_PROCESSING)
new_config['General']['post_processing_script'] = POST_PROCESSING_SCRIPT
new_config['General']['file_opts'] = FILE_OPTS
new_config['General']['unicode_issuenumber'] = int(UNICODE_ISSUENUMBER)
new_config['General']['weekfolder'] = int(WEEKFOLDER)
new_config['General']['weekfolder_loc'] = WEEKFOLDER_LOC
new_config['General']['weekfolder_format'] = int(WEEKFOLDER_FORMAT)

View File

@ -261,9 +261,8 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
logger.fdebug(type(comicid))
logger.fdebug(type(issueid))
logger.fdebug(type(issue))
logger.fdebug('comicid: ' + comicid)
logger.fdebug('issue#: ' + issue)
logger.fdebug('comicid: %s' % comicid)
logger.fdebug('issue# as per cv: %s' % issue)
# the issue here is a non-decimalized version, we need to see if it's got a decimal and if not, add '.00'
# iss_find = issue.find('.')
# if iss_find < 0:
@ -368,6 +367,17 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
comlocation = comicnzb['ComicLocation']
comversion = comicnzb['ComicVersion']
unicodeissue = issuenum
if type(issuenum) == unicode:
vals = {u'\xbd':'.5',u'\xbc':'.25',u'\xbe':'.75',u'\u221e':'9999999999',u'\xe2':'9999999999'}
else:
vals = {'\xbd':'.5','\xbc':'.25','\xbe':'.75','\u221e':'9999999999','\xe2':'9999999999'}
x = [vals[key] for key in vals if key in issuenum]
if x:
issuenum = x[0]
logger.fdebug('issue number formatted: %s' % issuenum)
#comicid = issuenzb['ComicID']
#issueno = str(issuenum).split('.')[0]
issue_except = 'None'
@ -415,18 +425,18 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
# if '!' in issuenum: issuenum = re.sub('\!', '', issuenum)
# issuenum = re.sub("[^0-9]", "", issuenum)
# issue_except = '.NOW'
if '.' in issuenum:
iss_find = issuenum.find('.')
iss_b4dec = issuenum[:iss_find]
if iss_find == 0:
iss_b4dec = '0'
iss_decval = issuenum[iss_find +1:]
if iss_decval.endswith('.'):
iss_decval = iss_decval[:-1]
if int(iss_decval) == 0:
iss = iss_b4dec
issdec = int(iss_decval)
issueno = str(iss)
logger.fdebug('Issue Number: ' + str(issueno))
issueno = iss
else:
if len(iss_decval) == 1:
iss = iss_b4dec + "." + iss_decval
@ -435,12 +445,9 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
iss = iss_b4dec + "." + iss_decval.rstrip('0')
issdec = int(iss_decval.rstrip('0')) * 10
issueno = iss_b4dec
logger.fdebug('Issue Number: ' + str(iss))
else:
iss = issuenum
issueno = str(iss)
logger.fdebug('iss:' + iss)
logger.fdebug('issueno:' + str(issueno))
issueno = iss
# issue zero-suppression here
if mylar.ZERO_LEVEL == "0":
zeroadd = ""
@ -457,17 +464,20 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
prettycomiss = str(issueno)
else:
try:
x = float(issueno)
x = float(issuenum)
#validity check
if x < 0:
logger.info('I\'ve encountered a negative issue #: ' + str(issueno) + '. Trying to accomodate.')
logger.info('I\'ve encountered a negative issue #: %s. Trying to accomodate.' % issuenumeric)
prettycomiss = '-' + str(zeroadd) + str(issueno[1:])
elif x == 9999999999:
logger.fdebug('Infinity issue found.')
issuenum = 'infinity'
elif x >= 0:
pass
else:
raise ValueError
except ValueError, e:
logger.warn('Unable to properly determine issue number [' + str(issueno) + '] - you should probably log this on github for help.')
logger.warn('Unable to properly determine issue number [ %s] - you should probably log this on github for help.' % issueno)
return
if prettycomiss is None and len(str(issueno)) > 0:
@ -506,10 +516,13 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
logger.fdebug('Zero level supplement set to ' + str(mylar.ZERO_LEVEL_N) + '.Issue will be set as : ' + str(prettycomiss))
else:
logger.fdebug('issue detected greater than 100')
if '.' in iss:
if int(iss_decval) > 0:
issueno = str(iss)
prettycomiss = str(issueno)
if issuenum == 'infinity':
prettycomiss = 'infinity'
else:
if '.' in iss:
if int(iss_decval) > 0:
issueno = str(iss)
prettycomiss = str(issueno)
if issue_except != 'None':
prettycomiss = str(prettycomiss) + issue_except
logger.fdebug('Zero level supplement set to ' + str(mylar.ZERO_LEVEL_N) + '. Issue will be set as : ' + str(prettycomiss))
@ -518,6 +531,10 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
logger.fdebug('issue length error - cannot determine length. Defaulting to None: ' + str(prettycomiss))
logger.fdebug('Pretty Comic Issue is : ' + str(prettycomiss))
if mylar.UNICODE_ISSUENUMBER:
logger.fdebug('Setting this to Unicode format as requested: %s' % prettycomiss)
prettycomiss = unicodeissue
issueyear = issuedate[:4]
month = issuedate[5:7].replace('-', '').strip()
month_name = fullmonth(month)
@ -555,21 +572,21 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
#if it's an annual, but $annual isn't specified in file_format, we need to
#force it in there, by default in the format of $Annual $Issue
#prettycomiss = "Annual " + str(prettycomiss)
logger.fdebug('[' + series + '][ANNUALS-ON][ANNUAL IN SERIES][NOT $ANNUAL] prettycomiss: ' + str(prettycomiss))
logger.fdebug('[%s][ANNUALS-ON][ANNUAL IN SERIES][NOT $ANNUAL] prettycomiss: %s' % (series, prettycomiss))
else:
#because it exists within title, strip it then use formatting tag for placement of wording.
chunk_f_f = re.sub('\$Annual', '', chunk_file_format)
chunk_f = re.compile(r'\s+')
chunk_file_format = chunk_f.sub(' ', chunk_f_f)
logger.fdebug('[' + series + '][ANNUALS-ON][ANNUAL IN SERIES][$ANNUAL] prettycomiss: ' + str(prettycomiss))
logger.fdebug('[%s][ANNUALS-ON][ANNUAL IN SERIES][$ANNUAL] prettycomiss: %s' % (series, prettycomiss))
else:
if '$Annual' not in chunk_file_format: # and 'annual' not in ofilename.lower():
#if it's an annual, but $annual isn't specified in file_format, we need to
#force it in there, by default in the format of $Annual $Issue
prettycomiss = "Annual " + str(prettycomiss)
logger.fdebug('[' + series + '][ANNUALS-ON][ANNUAL NOT IN SERIES][NOT $ANNUAL] prettycomiss: ' + str(prettycomiss))
prettycomiss = "Annual %s" % prettycomiss
logger.fdebug('[%s][ANNUALS-ON][ANNUAL NOT IN SERIES][NOT $ANNUAL] prettycomiss: %s' % (series, prettycomiss))
else:
logger.fdebug('[' + series + '][ANNUALS-ON][ANNUAL NOT IN SERIES][$ANNUAL] prettycomiss: ' + str(prettycomiss))
logger.fdebug('[%s][ANNUALS-ON][ANNUAL NOT IN SERIES][$ANNUAL] prettycomiss: %s' % (series, prettycomiss))
else:
#if annuals aren't enabled, then annuals are being tracked as independent series.
@ -579,21 +596,21 @@ def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=N
#if it's an annual, but $annual isn't specified in file_format, we need to
#force it in there, by default in the format of $Annual $Issue
#prettycomiss = "Annual " + str(prettycomiss)
logger.fdebug('[' + series + '][ANNUALS-OFF][ANNUAL IN SERIES][NOT $ANNUAL] prettycomiss: ' + str(prettycomiss))
logger.fdebug('[%s][ANNUALS-OFF][ANNUAL IN SERIES][NOT $ANNUAL] prettycomiss: %s' (series, prettycomiss))
else:
#because it exists within title, strip it then use formatting tag for placement of wording.
chunk_f_f = re.sub('\$Annual', '', chunk_file_format)
chunk_f = re.compile(r'\s+')
chunk_file_format = chunk_f.sub(' ', chunk_f_f)
logger.fdebug('[' + series + '][ANNUALS-OFF][ANNUAL IN SERIES][$ANNUAL] prettycomiss: ' + str(prettycomiss))
logger.fdebug('[%s][ANNUALS-OFF][ANNUAL IN SERIES][$ANNUAL] prettycomiss: %s' % (series, prettycomiss))
else:
if '$Annual' not in chunk_file_format: # and 'annual' not in ofilename.lower():
#if it's an annual, but $annual isn't specified in file_format, we need to
#force it in there, by default in the format of $Annual $Issue
prettycomiss = "Annual " + str(prettycomiss)
logger.fdebug('[' + series + '][ANNUALS-OFF][ANNUAL NOT IN SERIES][NOT $ANNUAL] prettycomiss: ' + str(prettycomiss))
prettycomiss = "Annual %s" % prettycomiss
logger.fdebug('[%s][ANNUALS-OFF][ANNUAL NOT IN SERIES][NOT $ANNUAL] prettycomiss: %s' % (series, prettycomiss))
else:
logger.fdebug('[' + series + '][ANNUALS-OFF][ANNUAL NOT IN SERIES][$ANNUAL] prettycomiss: ' + str(prettycomiss))
logger.fdebug('[%s][ANNUALS-OFF][ANNUAL NOT IN SERIES][$ANNUAL] prettycomiss: %s' % (series, prettycomiss))
logger.fdebug('Annual detected within series title of ' + series + '. Not auto-correcting issue #')

View File

@ -1062,7 +1062,8 @@ def manualAnnual(manual_comicid=None, comicname=None, comicyear=None, comicid=No
#"M_ComicName": sr['ComicName'],
#"M_ComicID": manual_comicid}
myDB.upsert("annuals", newVals, newCtrl)
logger.info('Successfully integrated ' + str(len(annchk)) + ' annuals into the series: ' + annchk[0]['ComicName'])
if len(annchk) > 0:
logger.info('Successfully integrated ' + str(len(annchk)) + ' annuals into the series: ' + annchk[0]['ComicName'])
return
@ -1100,7 +1101,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
annualchk = annual_check(comicname, SeriesYear, comicid, issuetype, issuechk, annualchk)
if annualchk is None:
annualchk = []
logger.fdebug('Finshed Annual checking.')
logger.fdebug('Finished Annual checking.')
n = 0
iscnt = int(comicIssues)
@ -1264,7 +1265,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
firstdate = str(firstval['Issue_Date'])
if issuechk is not None and issuetype == 'series':
#logger.fdebug('comparing ' + str(issuechk) + ' .. to .. ' + str(int_issnum))
logger.fdebug('comparing ' + str(issuechk) + ' .. to .. ' + str(int_issnum))
if issuechk == int_issnum:
weeklyissue_check.append({"Int_IssueNumber": int_issnum,
"Issue_Number": issnum,
@ -1293,12 +1294,13 @@ 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 calledfrom == 'weeklycheck':
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)
@ -1368,7 +1370,7 @@ def updateissuedata(comicid, comicname=None, issued=None, comicIssues=None, call
importantdates['LastPubDate'] = lastpubdate
importantdates['SeriesStatus'] = 'Active'
if calledfrom == 'weekly':
if calledfrom == 'weeklycheck':
return weeklyissue_check
elif len(issuedata) >= 1 and not calledfrom == 'dbupdate':

View File

@ -1838,7 +1838,7 @@ def searchIssueIDList(issuelist):
issue = myDB.selectone('SELECT * from annuals WHERE IssueID=?', [issueid]).fetchone()
mode = 'want_ann'
if issue is None:
logger.warn('unable to determine IssueID - perhaps you need to delete/refresh series? Skipping this entry: ' + issue['IssueID'])
logger.warn('unable to determine IssueID - perhaps you need to delete/refresh series? Skipping this entry: ' + issueid)
continue
if any([issue['Status'] == 'Downloaded', issue['Status'] == 'Snatched']):