FIX: numerous fixes - trying to get everything back in sync with my box. Expect some things to be broken after this one until the bugs are found :( (#210)(#204)

This commit is contained in:
evilhero 2013-02-12 20:27:24 -05:00
parent 7601fdaa9a
commit 3501a71da9
11 changed files with 281 additions and 87 deletions

View File

@ -48,10 +48,16 @@
</div> </div>
<ul id="nav"> <ul id="nav">
<li><a href="upcoming">wanted</a></li> <li><a href="upcoming">wanted</a></li>
<li><a href="pullist">This Week</a></li> <li><a href="pullist">
<li><a href="manage">manage</a></li> %if mylar.PULLNEW == 'no':
<li><a href="history">history</a></li> <img src="interfaces/default/images/grey-circle.png" height="10" width="10" />
<li><a href="logs" class="log">logs</a></li> %else:
<img src="interfaces/default/images/green-circle.png" height="10" width="10" />
%endif
&nbspThis Week</a></li>
<li><a href="manage">Manage</a></li>
<li><a href="history">History</a></li>
<li><a href="logs" class="log">Logs</a></li>
<li><a href="config" class="config"><img src="interfaces/default/images/icon_gear.png" alt="settings"/></a></li> <li><a href="config" class="config"><img src="interfaces/default/images/icon_gear.png" alt="settings"/></a></li>
</ul> </ul>
<div id="searchbar"> <div id="searchbar">

View File

@ -361,7 +361,7 @@
<fieldset> <fieldset>
<legend>Post-Processing</legend> <legend>Post-Processing</legend>
<div class="row checkbox left clearfix"> <div class="row checkbox left clearfix">
<input type="checkbox" name="post_processing" value="1" ${config['post_processing']} /><label>Enable Post-Processing<small> (not checked = NO post-processing/post-management)</small></label> <input type="checkbox" name="post_processing" value="1" ${config['post_processing']} /><label>Enable Post-Processing<small>not checked means NO post-processing or post-management</small></label>
</div> </div>
<div class="row checkbox left clearfix"> <div class="row checkbox left clearfix">
<input type="checkbox" name="enable_pre_scripts" value="1" ${config['enable_pre_scripts']} /><label>Use Extra Script BEFORE Post-Processing</label> <input type="checkbox" name="enable_pre_scripts" value="1" ${config['enable_pre_scripts']} /><label>Use Extra Script BEFORE Post-Processing</label>
@ -379,7 +379,6 @@
<input type="text" name="extra_scripts" value="${config['extra_scripts']}" size="30"> <input type="text" name="extra_scripts" value="${config['extra_scripts']}" size="30">
<small>enter in the absolute path to the script</small> <small>enter in the absolute path to the script</small>
</div> </div>
</div>
</fieldset> </fieldset>
</td> </td>
</tr> </tr>

View File

@ -13,6 +13,7 @@
</%def> </%def>
<%def name="body()"> <%def name="body()">
<div id="paddingheader"> <div id="paddingheader">
<h1 class="clearfix">Borg Importing Results</h1> <h1 class="clearfix">Borg Importing Results</h1>
</div> </div>
@ -54,6 +55,9 @@
<input type="hidden" value="Go"> <input type="hidden" value="Go">
</div> </div>
<table class="display" id="impresults_table"> <table class="display" id="impresults_table">
<tr />
<tr><center><h3>To be Imported</h3></center></tr>
<tr><center><small>(green indicates confirmed on watchlist)</tr>
<thead> <thead>
<tr> <tr>
<th id="select"></th> <th id="select"></th>
@ -67,16 +71,20 @@
<tbody> <tbody>
%if results: %if results:
%for result in results: %for result in results:
<tr> <tr>
<td id="select"><input type="checkbox" style="vertical-align: middle; margin: 3px; margin-top: -1px;" name="${result['ComicName']}" class="checkbox" /></td> <td id="select"><input type="checkbox" style="vertical-align: middle; margin: 3px; margin-top: -1px;" name="${result['ComicName']}" class="checkbox" /></td>
<td id="comicname"><a href="${result['ComicName']}" title="${result['ComicName']}" target="_blank">${result['ComicName']}</td> <td id="comicname"><a href="${result['ComicName']}" title="${result['ComicName']}" target="_blank">${result['ComicName']}</td>
<td id="comicissues"><title="${result['ComicYear']}">${result['ComicYear']}</td> <td id="comicissues"><title="${result['ComicYear']}">${result['ComicYear']}</td>
<td id="status">${result['Status']}</td> <td id="status">${result['Status']}
<td id="importdate">${result['ImportDate']}</td> %if result['WatchMatch'] is not None:
<td id="addcomic">[<a href="preSearchit?ComicName=${result['ComicName']}&imp_rename=$imp_rename&imp_move=$imp_move">Import</a>] <img src="interfaces/default/images/green-circle.png" height="10" width="10"/>
[<a href="deleteimport?ComicName=${result['ComicName']}">Remove</a>] %endif
</td> </td>
</tr> <td id="importdate">${result['ImportDate']}</td>
<td id="addcomic">[<a href="preSearchit?ComicName=${result['ComicName']}">Import</a>]
[<a href="deleteimport?ComicName=${result['ComicName']}">Remove</a>]
</td>
</tr>
<% <%
myDB = db.DBConnection() myDB = db.DBConnection()
files = myDB.action("SELECT * FROM importresults WHERE ComicName=?", [result['ComicName']]) files = myDB.action("SELECT * FROM importresults WHERE ComicName=?", [result['ComicName']])
@ -85,24 +93,76 @@
%endfor %endfor
%else: %else:
<tr> <tr>
<td colspan="5"><center><legend>There are no results to display</legend></center></td></tr> <td colspan="6"><center><legend>There are no results to display</legend></center></td></tr>
%endif %endif
</tbody> </tbody>
</table> </table>
<table class="display" id="impresults_table">
<tr><br /></tr>
<tr><center><h3>Already on Watchlist</h3></center></tr>
<tr><center>(you need to CONFIRM the match before doing an import!)
<thead>
<tr>
<th id="select"></th>
<th id="comicname">Comic Name</th>
<th id="comicyear">Year</th>
<th id="status">Status</th>
<th id="importdate">Import Date</th>
<th id="confirmed">Confirmed</th>
<th id="addcomic">Options</th>
</tr>
</thead>
<tbody>
%if watchresults:
%for wresult in watchresults:
<tr>
<td id="select"><input type="checkbox" style="vertical-align: middle; margin: 3px; margin-top: -1px;" name="${wresult['ComicName']}" class="checkbox" /></td>
<td id="comicname"><a href="http://www.comicvine.com/volume/49-${wresult['WatchMatch']} title="${wresult['ComicName']}" target="_blank">${wresult['ComicName']}</td>
<td id="comicissues"><title="${wresult['ComicYear']}">${wresult['ComicYear']}</td>
<td id="status">${wresult['Status']}</td>
<td id="importdate">${wresult['ImportDate']}</td>
<td id="confirmed">
<input type="text" name="confirmed" id="confirmed" size="5">
%if wresult['WatchMatch']:
<a href="confirmResult?comicname=${wresult['ComicName']}&comicid=${wresult['WatchMatch']}">Confirm</a>
%else:
No
%endif
</td>
<td id="addcomic">[<a href="preSearchit?ComicName=${wresult['ComicName']}">Import</a>]
[<a href="deleteimport?ComicName=${wresult['ComicName']}">Remove</a>]
</td>
</tr>
<%
myDB = db.DBConnection()
files = myDB.action("SELECT * FROM importresults WHERE ComicName=?", [wresult['ComicName']])
%>
%endfor
%else:
<tr>
<td colspan="100%"><center><legend>There are no results to display</legend></center></td></tr>
%endif
</tbody>
</table>
</div> </div>
</form> </form>
</div> </div>
</%def> </%def>
<%def name="javascriptIncludes()"> <%def name="javascriptIncludes()">
<script>
function initThisPage() { <script>
jQuery( "#tabs" ).tabs(); function initThisPage() {
initActions(); jQuery( "#tabs" ).tabs();
}; initActions();
$(document).ready(function() { };
initThisPage(); $(document).ready(function() {
}); initThisPage();
</script> });
</script>
</%def> </%def>

View File

@ -63,6 +63,8 @@ LOG_LIST = []
CACHE_DIR = None CACHE_DIR = None
PULLNEW = None
HTTP_PORT = None HTTP_PORT = None
HTTP_HOST = None HTTP_HOST = None
HTTP_USERNAME = None HTTP_USERNAME = None
@ -123,6 +125,7 @@ ADD_TO_CSV = True
SKIPPED2WANTED = False SKIPPED2WANTED = False
CVINFO = False CVINFO = False
LOG_LEVEL = None LOG_LEVEL = None
POST_PROCESSING = True
SAB_HOST = None SAB_HOST = None
SAB_USERNAME = None SAB_USERNAME = None
@ -224,8 +227,8 @@ def initialize():
NZBSU, NZBSU_APIKEY, DOGNZB, DOGNZB_APIKEY, NZBX,\ NZBSU, NZBSU_APIKEY, DOGNZB, DOGNZB_APIKEY, NZBX,\
NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\ NEWZNAB, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_ENABLED, EXTRA_NEWZNABS,\
RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, \ RAW, RAW_PROVIDER, RAW_USERNAME, RAW_PASSWORD, RAW_GROUPS, EXPERIMENTAL, \
PREFERRED_QUALITY, MOVE_FILES, RENAME_FILES, LOWERCASE_FILENAMES, USE_MINSIZE, MINSIZE, USE_MAXSIZE, MAXSIZE, CORRECT_METADATA, FOLDER_FORMAT, FILE_FORMAT, REPLACE_CHAR, REPLACE_SPACES, ADD_TO_CSV, CVINFO, LOG_LEVEL, \ PREFERRED_QUALITY, MOVE_FILES, RENAME_FILES, LOWERCASE_FILENAMES, USE_MINSIZE, MINSIZE, USE_MAXSIZE, MAXSIZE, CORRECT_METADATA, FOLDER_FORMAT, FILE_FORMAT, REPLACE_CHAR, REPLACE_SPACES, ADD_TO_CSV, CVINFO, LOG_LEVEL, POST_PROCESSING, \
COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS COMIC_LOCATION, QUAL_ALTVERS, QUAL_SCANNER, QUAL_TYPE, QUAL_QUALITY, ENABLE_EXTRA_SCRIPTS, EXTRA_SCRIPTS, ENABLE_PRE_SCRIPTS, PRE_SCRIPTS, PULLNEW
if __INITIALIZED__: if __INITIALIZED__:
return False return False
@ -305,6 +308,7 @@ def initialize():
ENABLE_PRE_SCRIPTS = bool(check_setting_int(CFG, 'General', 'enable_pre_scripts', 0)) ENABLE_PRE_SCRIPTS = bool(check_setting_int(CFG, 'General', 'enable_pre_scripts', 0))
PRE_SCRIPTS = check_setting_str(CFG, 'General', 'pre_scripts', '') PRE_SCRIPTS = check_setting_str(CFG, 'General', 'pre_scripts', '')
POST_PROCESSING = bool(check_setting_int(CFG, 'General', 'post_processing', 1))
SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '') SAB_HOST = check_setting_str(CFG, 'SABnzbd', 'sab_host', '')
SAB_USERNAME = check_setting_str(CFG, 'SABnzbd', 'sab_username', '') SAB_USERNAME = check_setting_str(CFG, 'SABnzbd', 'sab_username', '')
@ -559,6 +563,7 @@ def config_write():
new_config['General']['extra_scripts'] = EXTRA_SCRIPTS new_config['General']['extra_scripts'] = EXTRA_SCRIPTS
new_config['General']['enable_pre_scripts'] = int(ENABLE_PRE_SCRIPTS) new_config['General']['enable_pre_scripts'] = int(ENABLE_PRE_SCRIPTS)
new_config['General']['pre_scripts'] = PRE_SCRIPTS new_config['General']['pre_scripts'] = PRE_SCRIPTS
new_config['General']['post_processing'] = POST_PROCESSING
new_config['SABnzbd'] = {} new_config['SABnzbd'] = {}
new_config['SABnzbd']['sab_host'] = SAB_HOST new_config['SABnzbd']['sab_host'] = SAB_HOST
@ -622,6 +627,7 @@ def start():
#weekly pull list gets messed up if it's not populated first, so let's populate it then set the scheduler. #weekly pull list gets messed up if it's not populated first, so let's populate it then set the scheduler.
logger.info("Checking for existance of Weekly Comic listing...") logger.info("Checking for existance of Weekly Comic listing...")
PULLNEW = 'no' #reset the indicator here.
threading.Thread(target=weeklypull.pullit).start() threading.Thread(target=weeklypull.pullit).start()
#now the scheduler (check every 24 hours) #now the scheduler (check every 24 hours)
SCHED.add_interval_job(weeklypull.pullit, hours=24) SCHED.add_interval_job(weeklypull.pullit, hours=24)
@ -651,7 +657,7 @@ def dbcheck():
c.execute('CREATE TABLE IF NOT EXISTS nzblog (IssueID TEXT, NZBName TEXT)') c.execute('CREATE TABLE IF NOT EXISTS nzblog (IssueID TEXT, NZBName TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE text, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)') c.execute('CREATE TABLE IF NOT EXISTS weekly (SHIPDATE text, PUBLISHER text, ISSUE text, COMIC VARCHAR(150), EXTRA text, STATUS text)')
# c.execute('CREATE TABLE IF NOT EXISTS sablog (nzo_id TEXT, ComicName TEXT, ComicYEAR TEXT, ComicIssue TEXT, name TEXT, nzo_complete TEXT)') # c.execute('CREATE TABLE IF NOT EXISTS sablog (nzo_id TEXT, ComicName TEXT, ComicYEAR TEXT, ComicIssue TEXT, name TEXT, nzo_complete TEXT)')
c.execute('CREATE TABLE IF NOT EXISTS importresults (impID TEXT, ComicName TEXT, ComicYear TEXT, Status TEXT, ImportDate TEXT, ComicFilename TEXT, ComicLocation TEXT)') c.execute('CREATE TABLE IF NOT EXISTS importresults (impID TEXT, ComicName TEXT, ComicYear TEXT, Status TEXT, ImportDate TEXT, ComicFilename TEXT, ComicLocation TEXT, WatchMatch TEXT)')
conn.commit conn.commit
c.close c.close
#new #new
@ -696,6 +702,11 @@ def dbcheck():
c.execute('SELECT UseFuzzy from comics') c.execute('SELECT UseFuzzy from comics')
except sqlite3.OperationalError: except sqlite3.OperationalError:
c.execute('ALTER TABLE comics ADD COLUMN UseFuzzy TEXT') c.execute('ALTER TABLE comics ADD COLUMN UseFuzzy TEXT')
try:
c.execute('SELECT WatchMatch from importresults')
except sqlite3.OperationalError:
c.execute('ALTER TABLE importresults ADD COLUMN WatchMatch TEXT')
# -- not implemented just yet ;) # -- not implemented just yet ;)
# for metadata... # for metadata...

View File

@ -18,6 +18,7 @@ from operator import itemgetter
import datetime import datetime
import re import re
import itertools import itertools
import os
import mylar import mylar
def multikeysort(items, columns): def multikeysort(items, columns):
@ -184,8 +185,29 @@ def decimal_issue(iss):
deciss = (int(iss_b4dec) * 1000) + issdec deciss = (int(iss_b4dec) * 1000) + issdec
return deciss return deciss
def rename_param(comicid, comicname, comicyear, issue, issueid=None): def rename_param(comicid, comicname, issue, ofilename, comicyear=None, issueid=None):
from mylar import db, logger
myDB = db.DBConnection() myDB = db.DBConnection()
print ("comicid: " + str(comicid))
print ("issue#: " + str(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:
# no decimal in issue number
iss = str(int(issue)) + ".00"
else:
iss_b4dec = issue[:iss_find]
iss_decval = issue[iss_find+1:]
if len(iss_decval) == 1:
iss = str(int(iss_b4dec)) + "." + iss_decval
else:
if issue.endswith(".00"):
iss = issue
else:
iss = str(int(iss_b4dec)) + "." + iss_decval.rstrip('0')
issue = iss
print ("converted issue#: " + str(issue))
if issueid is None: if issueid is None:
chkissue = myDB.action("SELECT * from issues WHERE ComicID=? AND Issue_Number=?", [comicid, issue]).fetchone() chkissue = myDB.action("SELECT * from issues WHERE ComicID=? AND Issue_Number=?", [comicid, issue]).fetchone()
if chkissue is None: if chkissue is None:
@ -283,8 +305,10 @@ def rename_param(comicid, comicname, comicyear, issue, issueid=None):
extensions = ('.cbr', '.cbz') extensions = ('.cbr', '.cbz')
if ofilename.lower().endswith(extensions):
path, ext = os.path.splitext(ofilename)
if mylar.FILE_FORMAT == '': if mylar.FILE_FORMAT == '':
self._log("Rename Files isn't enabled...keeping original filename.", logger.DEBUG)
logger.fdebug("Rename Files isn't enabled - keeping original filename.") logger.fdebug("Rename Files isn't enabled - keeping original filename.")
#check if extension is in nzb_name - will screw up otherwise #check if extension is in nzb_name - will screw up otherwise
if ofilename.lower().endswith(extensions): if ofilename.lower().endswith(extensions):
@ -292,18 +316,18 @@ def rename_param(comicid, comicname, comicyear, issue, issueid=None):
else: else:
nfilename = ofilename nfilename = ofilename
else: else:
nfilename = helpers.replace_all(mylar.FILE_FORMAT, file_values) nfilename = replace_all(mylar.FILE_FORMAT, file_values)
if mylar.REPLACE_SPACES: if mylar.REPLACE_SPACES:
#mylar.REPLACE_CHAR ...determines what to replace spaces with underscore or dot #mylar.REPLACE_CHAR ...determines what to replace spaces with underscore or dot
nfilename = nfilename.replace(' ', mylar.REPLACE_CHAR) nfilename = nfilename.replace(' ', mylar.REPLACE_CHAR)
nfilename = re.sub('[\,\:]', '', nfilename) nfilename = re.sub('[\,\:]', '', nfilename) + ext.lower()
logger.fdebug("New Filename: " + str(nfilename)) logger.fdebug("New Filename: " + str(nfilename))
if mylar.LOWERCASE_FILENAMES: if mylar.LOWERCASE_FILENAMES:
dst = (comlocation + "/" + nfilename + ext).lower() dst = (comlocation + "/" + nfilename).lower()
else: else:
dst = comlocation + "/" + nfilename + ext.lower() dst = comlocation + "/" + nfilename
logger.fdebug("Source: " + str(src)) logger.fdebug("Source: " + str(ofilename))
logger.fdebug("Destination: " + str(dst)) logger.fdebug("Destination: " + str(dst))
rename_this = { "destination_dir" : dst, rename_this = { "destination_dir" : dst,

View File

@ -379,7 +379,7 @@ def addComictoDB(comicid,mismatch=None,pullupd=None,imported=None,ogcname=None):
print ("imported is :" + str(imported)) print ("imported is :" + str(imported))
if mylar.IMP_MOVE: if mylar.IMP_MOVE:
logger.info("Mass import - Move files") logger.info("Mass import - Move files")
moveit.movefiles(comlocation,ogcname) moveit.movefiles(comicid,comlocation,ogcname)
#check for existing files... #check for existing files...
updater.forceRescan(comicid) updater.forceRescan(comicid)

78
mylar/librarysync.py Normal file → Executable file
View File

@ -46,7 +46,6 @@ def libraryScan(dir=None, append=False, ComicID=None, ComicName=None, cron=None)
basedir = dir basedir = dir
watchmatch = {}
comic_list = [] comic_list = []
comiccnt = 0 comiccnt = 0
extensions = ('cbr','cbz') extensions = ('cbr','cbz')
@ -365,18 +364,17 @@ def libraryScan(dir=None, append=False, ComicID=None, ComicName=None, cron=None)
#issue comparison now as well #issue comparison now as well
logger.info(u"Found " + str(comname) + " (" + str(comyear) + ") issue: " + str(comic_iss)) logger.info(u"Found " + str(comname) + " (" + str(comyear) + ") issue: " + str(comic_iss))
watchfound+=1 # watchfound+=1
# updater.forceRescan(ComicID=comicid) watchmatch = str(comicid)
# if not any(d.get('ComicID', None) == str(comicid) for d in watch_kchoice): # watch_kchoice.append({
watch_kchoice.append({ # "ComicID": str(comicid),
"ComicID": str(comicid), # "ComicName": str(comname),
"ComicName": str(comname), # "ComicYear": str(comyear),
"ComicYear": str(comyear), # "ComicIssue": str(int(comic_iss)),
"ComicIssue": str(int(comic_iss)), # "ComicLocation": str(watch_location),
"ComicLocation": str(watch_location), # "OriginalLocation" : str(comlocation),
"OriginalLocation" : str(comlocation), # "OriginalFilename" : str(comfilename)
"OriginalFilename" : str(comfilename) # })
})
foundonwatch = "True" foundonwatch = "True"
break break
elif int(spercent) < 80: elif int(spercent) < 80:
@ -384,33 +382,35 @@ def libraryScan(dir=None, append=False, ComicID=None, ComicName=None, cron=None)
cm_cn+=1 cm_cn+=1
if foundonwatch == "False": if foundonwatch == "False":
watchmatch = None
#---if it's not a match - send it to the importer. #---if it's not a match - send it to the importer.
n = 0 n = 0
csplit = comic_andiss.split(None) csplit = comic_andiss.split(None)
while ( n <= (len(csplit)-1) ): while ( n <= (len(csplit)-1) ):
if csplit[n].isdigit(): if csplit[n].isdigit():
logger.fdebug("issue detected") logger.fdebug("issue detected")
comiss = splitit[n] comiss = splitit[n]
logger.fdebug("issue # : " + str(comiss)) logger.fdebug("issue # : " + str(comiss))
comicNAMER = n - 1 comicNAMER = n - 1
com_NAME = csplit[0] com_NAME = csplit[0]
cmnam = 1 cmnam = 1
while (cmnam <= comicNAMER): while (cmnam <= comicNAMER):
com_NAME = str(com_NAME) + " " + str(csplit[cmnam]) com_NAME = str(com_NAME) + " " + str(csplit[cmnam])
cmnam+=1 cmnam+=1
logger.fdebug("comic: " + str(com_NAME)) logger.fdebug("comic: " + str(com_NAME))
n+=1 n+=1
if result_comyear is None: result_comyear = '0000' #no year in filename basically. if result_comyear is None: result_comyear = '0000' #no year in filename basically.
print ("adding " + str(com_NAME) + " to the import-queue!") print ("adding " + str(com_NAME) + " to the import-queue!")
impid = str(com_NAME) + "-" + str(result_comyear) + "-" + str(comiss) impid = str(com_NAME) + "-" + str(result_comyear) + "-" + str(comiss)
print ("impid: " + str(impid)) print ("impid: " + str(impid))
import_by_comicids.append({ import_by_comicids.append({
"impid": impid, "impid": impid,
"comicname" : com_NAME, "watchmatch": watchmatch,
"comicyear" : result_comyear, "comicname" : com_NAME,
"comfilename" : comfilename, "comicyear" : result_comyear,
"comlocation" : comlocation.decode(mylar.SYS_ENCODING) "comfilename" : comfilename,
}) "comlocation" : comlocation.decode(mylar.SYS_ENCODING)
})
if len(watch_kchoice) > 0: if len(watch_kchoice) > 0:
watchchoice['watchlist'] = watch_kchoice watchchoice['watchlist'] = watch_kchoice

19
mylar/moveit.py Normal file → Executable file
View File

@ -1,10 +1,10 @@
import mylar import mylar
from mylar import db, logger from mylar import db, logger, helpers
import os import os
import shutil import shutil
def movefiles(comlocation,ogcname,imported=None): def movefiles(comicid,comlocation,ogcname,imported=None):
myDB = db.DBConnection() myDB = db.DBConnection()
print ("comlocation is : " + str(comlocation)) print ("comlocation is : " + str(comlocation))
print ("original comicname is : " + str(ogcname)) print ("original comicname is : " + str(ogcname))
@ -14,7 +14,20 @@ def movefiles(comlocation,ogcname,imported=None):
#print ("preparing to move " + str(len(impres)) + " files into the right directory now.") #print ("preparing to move " + str(len(impres)) + " files into the right directory now.")
for impr in impres: for impr in impres:
srcimp = impr['ComicLocation'] srcimp = impr['ComicLocation']
dstimp = os.path.join(comlocation, impr['ComicFilename']) orig_filename = impr['ComicFilename']
orig_iss = impr['impID'].rfind('-')
orig_iss = impr['impID'][orig_iss+1:]
print ("Issue :" + str(orig_iss))
#before moving check to see if Rename to Mylar structure is enabled.
if mylar.IMP_RENAME:
print("Renaming files according to configuration details : " + str(mylar.FILE_FORMAT))
renameit = helpers.rename_param(comicid, impr['ComicName'], orig_iss, orig_filename)
nfilename = renameit['nfilename']
dstimp = os.path.join(comlocation,nfilename)
else:
print("Renaming files not enabled, keeping original filename(s)")
dstimp = os.path.join(comlocation,orig_filename)
logger.info("moving " + str(srcimp) + " ... to " + str(dstimp)) logger.info("moving " + str(srcimp) + " ... to " + str(dstimp))
try: try:
shutil.move(srcimp, dstimp) shutil.move(srcimp, dstimp)

View File

@ -704,7 +704,7 @@ def NZB_SEARCH(ComicName, IssueNumber, ComicYear, SeriesYear, nzbprov, nzbpr, Is
if mylar.SAB_CATEGORY: if mylar.SAB_CATEGORY:
tmpapi = tmpapi + "&cat=" + str(mylar.SAB_CATEGORY) tmpapi = tmpapi + "&cat=" + str(mylar.SAB_CATEGORY)
logger.fdebug("...attaching category: " + str(tmpapi)) logger.fdebug("...attaching category: " + str(tmpapi))
if mylar.RENAME_FILES == 1: if mylar.RENAME_FILES or mylar.POST_PROCESSING:
tmpapi = tmpapi + "&script=ComicRN.py" tmpapi = tmpapi + "&script=ComicRN.py"
logger.fdebug("...attaching rename script: " + str(tmpapi)) logger.fdebug("...attaching rename script: " + str(tmpapi))
#final build of send-to-SAB #final build of send-to-SAB

View File

@ -305,7 +305,7 @@ def forceRescan(ComicID):
while (som < fcn): while (som < fcn):
#counts get buggered up when the issue is the last field in the filename - ie. '50.cbr' #counts get buggered up when the issue is the last field in the filename - ie. '50.cbr'
logger.fdebug("checking word - " + str(fcnew[som])) #logger.fdebug("checking word - " + str(fcnew[som]))
if ".cbr" in fcnew[som].lower(): if ".cbr" in fcnew[som].lower():
fcnew[som] = fcnew[som].replace(".cbr", "") fcnew[som] = fcnew[som].replace(".cbr", "")
elif ".cbz" in fcnew[som].lower(): elif ".cbz" in fcnew[som].lower():
@ -316,7 +316,7 @@ def forceRescan(ComicID):
if fcnew[som] != " ": if fcnew[som] != " ":
fcnew[som] = get_issue[0] fcnew[som] = get_issue[0]
if '.' in fcnew[som]: if '.' in fcnew[som]:
logger.fdebug("decimal detected...adjusting.") #logger.fdebug("decimal detected...adjusting.")
try: try:
i = float(fcnew[som]) i = float(fcnew[som])
except ValueError, TypeError: except ValueError, TypeError:

View File

@ -108,6 +108,26 @@ class WebInterface(object):
def addComic(self, comicid, comicname=None, comicyear=None, comicimage=None, comicissues=None, comicpublisher=None, imported=None, ogcname=None): def addComic(self, comicid, comicname=None, comicyear=None, comicimage=None, comicissues=None, comicpublisher=None, imported=None, ogcname=None):
myDB = db.DBConnection() myDB = db.DBConnection()
print ("I'm here.")
if imported == "confirm":
# if it's coming from the importer and it's just for confirmation, record the right selection and break.
# if it's 'confirmed' coming in as the value for imported
# the ogcname will be the original comicid that is either correct/incorrect (doesn't matter which)
#confirmedid is the selected series (comicid) with the letter C at the beginning to denote Confirmed.
# then sql the original comicid which will hit on all the results for the given series.
# iterate through, and overwrite the existing watchmatch with the new chosen 'C' + comicid value
confirmedid = "C" + str(comicid)
confirms = myDB.action("SELECT * FROM importresults WHERE WatchMatch=?", [ogcname])
if confirms is None:
print ("There are no results that match...this is an ERROR.")
else:
for confirm in confirms:
controlValue = {"impID": confirm['impID']}
newValue = {"WatchMatch": str(confirmedid)}
myDB.upsert("importresults", newValue, controlValue)
self.importResults()
return
sresults = [] sresults = []
cresults = [] cresults = []
mismatch = "no" mismatch = "no"
@ -499,9 +519,40 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % [comicid]) raise cherrypy.HTTPRedirect("artistPage?ComicID=%s" % [comicid])
skipped2wanted.exposed = True skipped2wanted.exposed = True
def ManualRename(self): def manualRename(self, comicid):
print ("entering.")
if mylar.FILE_FORMAT == '':
print ("You haven't specified a File Format in Configuration/Advanced")
print ("Cannot rename files.")
return
myDB = db.DBConnection()
comic = myDB.action("SELECT * FROM comics WHERE ComicID=?", [comicid]).fetchone()
comicdir = comic['ComicLocation']
comicname = comic['ComicName']
extensions = ('.cbr', '.cbz')
issues = myDB.action("SELECT * FROM issues WHERE ComicID=?", [comicid])
comfiles = []
for root, dirnames, filenames in os.walk(comicdir):
for filename in filenames:
if filename.lower().endswith(extensions):
print ("filename being checked is : " + str(filename))
for issue in issues:
if issue['Location'] == filename:
print ("matched " + str(filename) + " to DB file " + str(issue['Location']))
renameiss = helpers.rename_param(comicid, comicname, issue['Issue_Number'], filename, comicyear=None, issueid=None)
nfilename = renameiss['nfilename']
srciss = os.path.join(comicdir,filename)
dstiss = os.path.join(comicdir,nfilename)
logger.info("Renaming " + str(filename) + " ... to " + str(nfilename))
try:
shutil.move(srciss, dstiss)
except (OSError, IOError):
logger.error("Failed to move files - check directories and manually re-run.")
continue
print ("hello") print ("hello")
ManualRename.exposed = True manualRename.exposed = True
def searchScan(self, name): def searchScan(self, name):
return serve_template(templatename="searchfix.html", title="Manage", name=name) return serve_template(templatename="searchfix.html", title="Manage", name=name)
@ -638,6 +689,15 @@ class WebInterface(object):
return serve_template(templatename="idirectory.html", title="Import a Directory") return serve_template(templatename="idirectory.html", title="Import a Directory")
idirectory.exposed = True idirectory.exposed = True
def confirmResult(self,comicname,comicid):
#print ("here.")
mode='series'
sresults = mb.findComic(comicname, mode, None)
#print sresults
type='comic'
return serve_template(templatename="searchresults.html", title='Import Results for: "' + comicname + '"',searchresults=sresults, type=type, imported='confirm', ogcname=comicid)
confirmResult.exposed = True
def comicScan(self, path, scan=0, redirect=None, autoadd=0, libraryscan=0, imp_move=0, imp_rename=0, imp_metadata=0): def comicScan(self, path, scan=0, redirect=None, autoadd=0, libraryscan=0, imp_move=0, imp_rename=0, imp_metadata=0):
mylar.LIBRARYSCAN = libraryscan mylar.LIBRARYSCAN = libraryscan
mylar.ADD_COMICS = autoadd mylar.ADD_COMICS = autoadd
@ -679,7 +739,8 @@ class WebInterface(object):
"ComicName": soma_sl['comicname'], "ComicName": soma_sl['comicname'],
"ComicFilename": soma_sl['comfilename'], "ComicFilename": soma_sl['comfilename'],
"ComicLocation": soma_sl['comlocation'].encode('utf-8'), "ComicLocation": soma_sl['comlocation'].encode('utf-8'),
"ImportDate": helpers.today()} "ImportDate": helpers.today(),
"WatchMatch": soma_sl['watchmatch']}
myDB.upsert("importresults", newValue, controlValue) myDB.upsert("importresults", newValue, controlValue)
sl+=1 sl+=1
# because we could be adding volumes/series that span years, we need to account for this # because we could be adding volumes/series that span years, we need to account for this
@ -702,8 +763,9 @@ class WebInterface(object):
def importResults(self): def importResults(self):
myDB = db.DBConnection() myDB = db.DBConnection()
results = myDB.select("SELECT * FROM importresults group by ComicName COLLATE NOCASE") results = myDB.select("SELECT * FROM importresults WHERE WatchMatch is Null OR WatchMatch LIKE 'C%' group by ComicName COLLATE NOCASE")
return serve_template(templatename="importresults.html", title="Import Results", results=results) watchresults = myDB.select("SELECT * FROM importresults WHERE WatchMatch is not Null AND WatchMatch NOT LIKE 'C%' group by ComicName COLLATE NOCASE")
return serve_template(templatename="importresults.html", title="Import Results", results=results, watchresults=watchresults)
importResults.exposed = True importResults.exposed = True
def deleteimport(self, ComicName): def deleteimport(self, ComicName):
@ -713,7 +775,7 @@ class WebInterface(object):
raise cherrypy.HTTPRedirect("importResults") raise cherrypy.HTTPRedirect("importResults")
deleteimport.exposed = True deleteimport.exposed = True
def preSearchit(self, ComicName, imp_rename, imp_move): def preSearchit(self, ComicName):
#print ("imp_rename:" + str(imp_rename)) #print ("imp_rename:" + str(imp_rename))
#print ("imp_move:" + str(imp_move)) #print ("imp_move:" + str(imp_move))
myDB = db.DBConnection() myDB = db.DBConnection()
@ -729,6 +791,23 @@ class WebInterface(object):
for result in results: for result in results:
if result is None: if result is None:
break break
elif result['WatchMatch'].startswith('C'):
print ("Confirmed. ComicID already provided - initiating auto-magik mode for import.")
comicid = result['WatchMatch'][1:]
print (result['WatchMatch'] + " .to. " + str(comicid))
#since it's already in the watchlist, we just need to move the files and re-run the filechecker.
#self.refreshArtist(comicid=comicid,imported='yes')
if mylar.IMP_MOVE:
logger.info("Mass import - Move files")
comloc = myDB.action("SELECT * FROM comics WHERE ComicID=?", [comicid]).fetchone()
mylar.moveit.movefiles(comicid,comloc['ComicLocation'],ComicName)
#check for existing files...
updater.forceRescan(comicid)
else:
print ("nothing to do if I'm not moving.")
raise cherrypy.HTTPRedirect("importResults")
else: else:
comicstoIMP.append(result['ComicLocation'].decode(mylar.SYS_ENCODING, 'replace')) comicstoIMP.append(result['ComicLocation'].decode(mylar.SYS_ENCODING, 'replace'))
getiss = result['impID'].rfind('-') getiss = result['impID'].rfind('-')
@ -796,9 +875,9 @@ class WebInterface(object):
resultset = 0 resultset = 0
if resultset == 1: if resultset == 1:
self.addComic(comicid=sr['comicid'],comicname=sr['name'],comicyear=sr['comicyear'],comicpublisher=sr['publisher'],comicimage=sr['comicimage'],comicissues=sr['issues'],imported=comicstoIMP,ogcname=ogcname) self.addComic(comicid=sr['comicid'],comicname=sr['name'],comicyear=sr['comicyear'],comicpublisher=sr['publisher'],comicimage=sr['comicimage'],comicissues=sr['issues'],imported='yes',ogcname=ogcname) #imported=comicstoIMP,ogcname=ogcname)
else: else:
return serve_template(templatename="searchresults.html", title='Search Results for: "' + ComicName + '"',searchresults=sresults, type=type, imported=comicstoIMP, ogcname=ogcname) return serve_template(templatename="searchresults.html", title='Import Results for: "' + ComicName + '"',searchresults=sresults, type=type, imported='yes', ogcname=ogcname) #imported=comicstoIMP, ogcname=ogcname)
preSearchit.exposed = True preSearchit.exposed = True
#--- #---
@ -868,6 +947,7 @@ class WebInterface(object):
"lowercase_filenames" : helpers.checked(mylar.LOWERCASE_FILENAMES), "lowercase_filenames" : helpers.checked(mylar.LOWERCASE_FILENAMES),
"enable_extra_scripts" : helpers.checked(mylar.ENABLE_EXTRA_SCRIPTS), "enable_extra_scripts" : helpers.checked(mylar.ENABLE_EXTRA_SCRIPTS),
"extra_scripts" : mylar.EXTRA_SCRIPTS, "extra_scripts" : mylar.EXTRA_SCRIPTS,
"post_processing" : helpers.checked(mylar.POST_PROCESSING),
"branch" : version.MYLAR_VERSION, "branch" : version.MYLAR_VERSION,
"br_type" : mylar.INSTALL_TYPE, "br_type" : mylar.INSTALL_TYPE,
"br_version" : mylar.versioncheck.getVersion(), "br_version" : mylar.versioncheck.getVersion(),
@ -971,7 +1051,7 @@ class WebInterface(object):
sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, sab_priority=None, sab_directory=None, log_dir=None, log_level=0, blackhole=0, blackhole_dir=None, sab_host=None, sab_username=None, sab_apikey=None, sab_password=None, sab_category=None, sab_priority=None, sab_directory=None, log_dir=None, log_level=0, blackhole=0, blackhole_dir=None,
usenet_retention=None, nzbsu=0, nzbsu_apikey=None, dognzb=0, dognzb_apikey=None, nzbx=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0, usenet_retention=None, nzbsu=0, nzbsu_apikey=None, dognzb=0, dognzb_apikey=None, nzbx=0, newznab=0, newznab_host=None, newznab_apikey=None, newznab_enabled=0,
raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0, raw=0, raw_provider=None, raw_username=None, raw_password=None, raw_groups=None, experimental=0,
preferred_quality=0, move_files=0, rename_files=0, add_to_csv=1, cvinfo=0, lowercase_filenames=0, folder_format=None, file_format=None, enable_extra_scripts=0, extra_scripts=None, enable_pre_scripts=0, pre_scripts=None, preferred_quality=0, move_files=0, rename_files=0, add_to_csv=1, cvinfo=0, lowercase_filenames=0, folder_format=None, file_format=None, enable_extra_scripts=0, extra_scripts=None, enable_pre_scripts=0, pre_scripts=None, post_processing=0,
destination_dir=None, replace_spaces=0, replace_char=None, use_minsize=0, minsize=None, use_maxsize=0, maxsize=None, autowant_all=0, autowant_upcoming=0, comic_cover_local=0, zero_level=0, zero_level_n=None, interface=None, **kwargs): destination_dir=None, replace_spaces=0, replace_char=None, use_minsize=0, minsize=None, use_maxsize=0, maxsize=None, autowant_all=0, autowant_upcoming=0, comic_cover_local=0, zero_level=0, zero_level_n=None, interface=None, **kwargs):
mylar.HTTP_HOST = http_host mylar.HTTP_HOST = http_host
mylar.HTTP_PORT = http_port mylar.HTTP_PORT = http_port
@ -1032,6 +1112,7 @@ class WebInterface(object):
mylar.ENABLE_EXTRA_SCRIPTS = enable_extra_scripts mylar.ENABLE_EXTRA_SCRIPTS = enable_extra_scripts
mylar.EXTRA_SCRIPTS = extra_scripts mylar.EXTRA_SCRIPTS = extra_scripts
mylar.ENABLE_PRE_SCRIPTS = enable_pre_scripts mylar.ENABLE_PRE_SCRIPTS = enable_pre_scripts
mylar.POST_PROCESSING = post_processing
mylar.PRE_SCRIPTS = pre_scripts mylar.PRE_SCRIPTS = pre_scripts
mylar.LOG_DIR = log_dir mylar.LOG_DIR = log_dir
mylar.LOG_LEVEL = log_level mylar.LOG_LEVEL = log_level