mirror of
https://github.com/evilhero/mylar
synced 2025-03-09 05:13:35 +00:00
FIX:(#1197) Startup errors on Windows systems after last commit related to stderr/stdout problems, FIX: Selecting copy/move option from GUI configuration wouldn't retain settings, FIX: Removed unnecessary stdout calls from included CT module, FIX: When copy/moving during post-processing and meta-tagging enabled, won't move files to tag if copy is selected
This commit is contained in:
parent
d182321d9b
commit
52d0b29702
9 changed files with 53 additions and 41 deletions
3
Mylar.py
3
Mylar.py
|
@ -32,6 +32,9 @@ try:
|
|||
except ImportError:
|
||||
import lib.argparse as argparse
|
||||
|
||||
if ( sys.platform == 'win32' and sys.executable.split( '\\' )[-1] == 'pythonw.exe'):
|
||||
sys.stdout = open(os.devnull, "w")
|
||||
sys.stderr = open(os.devnull, "w")
|
||||
|
||||
def handler_sigterm(signum, frame):
|
||||
mylar.SIGNAL = 'shutdown'
|
||||
|
|
|
@ -460,7 +460,7 @@
|
|||
%endif
|
||||
|
||||
%if mylar.ENABLE_META:
|
||||
<a href="#" title="Manually meta-tag issue" onclick="doAjaxCall('manual_metatag?dirName=${comic['ComicLocation'] |u}&issueid=${issue['IssueID']}&filename=${linky |u}&comicid=${issue['ComicID']}&comversion=${comic['ComicVersion']}',$(this),'table')" data-success="${issue['Issue_Number']} successfully tagged."><img src="interfaces/default/images/comictagger.png" height="25" width="25" class="highqual" /></a>
|
||||
<a href="#" title="Manually meta-tag issue" onclick="doAjaxCall('manual_metatag?dirName=${comic['ComicLocation'] |u}&issueid=${issue['IssueID']}&filename=${linky |u}&comicid=${issue['ComicID']}&comversion=${comic['ComicVersion']}',$(this),'table')" data-success="${comic['ComicName']} #${issue['Issue_Number']} successfully tagged."><img src="interfaces/default/images/comictagger.png" height="25" width="25" class="highqual" /></a>
|
||||
%endif
|
||||
%endif
|
||||
<a href="#" title="Add to Reading List" onclick="doAjaxCall('addtoreadlist?IssueID=${issue['IssueID']}',$(this),'table')" data-success="${comic['ComicName']} #${issue['Issue_Number']} added to Reading List"><img src="interfaces/default/images/glasses-icon.png" height="25" width="25" class="highqual" /></a>
|
||||
|
@ -603,7 +603,7 @@
|
|||
%endif
|
||||
|
||||
%if mylar.ENABLE_META:
|
||||
<a href="#" title="Manually meta-tag annual" onclick="doAjaxCall('manual_metatag?dirName=${comic['ComicLocation'] |u}&issueid=${issue['IssueID']}&filename=${linky |u}&comicid=${issue['ComicID']}',$(this),'table')" data-success="${issue['Issue_Number']} successfully tagged."><img src="interfaces/default/images/comictagger.png" height="25" width="25" class="highqual" /></a>
|
||||
<a href="#" title="Manually meta-tag annual" onclick="doAjaxCall('manual_metatag?dirName=${comic['ComicLocation'] |u}&issueid=${issue['IssueID']}&filename=${linky |u}&comicid=${issue['ComicID']}',$(this),'table')" data-success="${annual['ComicName']} #${issue['Issue_Number']} successfully tagged."><img src="interfaces/default/images/comictagger.png" height="25" width="25" class="highqual" /></a>
|
||||
%endif
|
||||
%endif
|
||||
<!--
|
||||
|
|
|
@ -734,7 +734,7 @@
|
|||
<div class="config">
|
||||
<div class="row left">
|
||||
<label>When Post-Processing
|
||||
<select name="file_opts clearfix">
|
||||
<select name="file_opts">
|
||||
%for x in ['move', 'copy']:
|
||||
<%
|
||||
if config['file_opts'] == x:
|
||||
|
|
|
@ -68,7 +68,7 @@ def actual_issue_data_fetch( match, settings, opts ):
|
|||
comicVine.wait_for_rate_limit = opts.wait_and_retry_on_rate_limit
|
||||
cv_md = comicVine.fetchIssueData( match['volume_id'], match['issue_number'], settings )
|
||||
except ComicVineTalkerException:
|
||||
print >> sys.stderr, "Network error while getting issue details. Save aborted"
|
||||
print "Network error while getting issue details. Save aborted"
|
||||
return None
|
||||
|
||||
if settings.apply_cbl_transform_on_cv_import:
|
||||
|
@ -81,16 +81,16 @@ def actual_metadata_save( ca, opts, md ):
|
|||
if not opts.dryrun:
|
||||
# write out the new data
|
||||
if not ca.writeMetadata( md, opts.data_style ):
|
||||
print >> sys.stderr,"The tag save seemed to fail!"
|
||||
print "The tag save seemed to fail!"
|
||||
return False
|
||||
else:
|
||||
pass
|
||||
#print >> sys.stderr,"Save complete."
|
||||
else:
|
||||
if opts.terse:
|
||||
print >> sys.stderr,"dry-run option was set, so nothing was written"
|
||||
print "dry-run option was set, so nothing was written"
|
||||
else:
|
||||
print >> sys.stderr,"dry-run option was set, so nothing was written, but here is the final set of tags:"
|
||||
print "dry-run option was set, so nothing was written, but here is the final set of tags:"
|
||||
print u"{0}".format(md)
|
||||
return True
|
||||
|
||||
|
@ -176,7 +176,7 @@ def post_process_matches( match_results, opts, settings ):
|
|||
|
||||
def cli_mode( opts, settings ):
|
||||
if len( opts.file_list ) < 1:
|
||||
print >> sys.stderr,"You must specify at least one filename. Use the -h option for more info"
|
||||
print "You must specify at least one filename. Use the -h option for more info"
|
||||
return
|
||||
|
||||
match_results = OnlineMatchResults()
|
||||
|
@ -185,7 +185,7 @@ def cli_mode( opts, settings ):
|
|||
if type(f) == str:
|
||||
f = f.decode(filename_encoding, 'replace')
|
||||
process_file_cli( f, opts, settings, match_results )
|
||||
sys.stdout.flush()
|
||||
#sys.stdout.flush()
|
||||
|
||||
post_process_matches( match_results, opts, settings )
|
||||
|
||||
|
@ -215,16 +215,16 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
ca = ComicArchive(filename, settings.rar_exe_path)
|
||||
|
||||
if not os.path.lexists( filename ):
|
||||
print >> sys.stderr,"Cannot find "+ filename
|
||||
print "Cannot find "+ filename
|
||||
return
|
||||
|
||||
if not ca.seemsToBeAComicArchive():
|
||||
print >> sys.stderr,"Sorry, but "+ filename + " is not a comic archive!"
|
||||
print "Sorry, but "+ filename + " is not a comic archive!"
|
||||
return
|
||||
|
||||
#if not ca.isWritableForStyle( opts.data_style ) and ( opts.delete_tags or opts.save_tags or opts.rename_file ):
|
||||
if not ca.isWritable( ) and ( opts.delete_tags or opts.copy_tags or opts.save_tags or opts.rename_file ):
|
||||
print >> sys.stderr,"This archive is not writable for that tag type"
|
||||
print "This archive is not writable for that tag type"
|
||||
return
|
||||
|
||||
has = [ False, False, False ]
|
||||
|
@ -353,12 +353,12 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
comicVine.wait_for_rate_limit = opts.wait_and_retry_on_rate_limit
|
||||
cv_md = comicVine.fetchIssueDataByIssueID( opts.issue_id, settings )
|
||||
except ComicVineTalkerException:
|
||||
print >> sys.stderr,"Network error while getting issue details. Save aborted"
|
||||
print "Network error while getting issue details. Save aborted"
|
||||
match_results.fetchDataFailures.append(filename)
|
||||
return
|
||||
|
||||
if cv_md is None:
|
||||
print >> sys.stderr,"No match for ID {0} was found.".format(opts.issue_id)
|
||||
print "No match for ID {0} was found.".format(opts.issue_id)
|
||||
match_results.noMatches.append(filename)
|
||||
return
|
||||
|
||||
|
@ -368,7 +368,7 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
ii = IssueIdentifier( ca, settings )
|
||||
|
||||
if md is None or md.isEmpty:
|
||||
print >> sys.stderr,"No metadata given to search online with!"
|
||||
print "No metadata given to search online with!"
|
||||
match_results.noMatches.append(filename)
|
||||
return
|
||||
|
||||
|
@ -407,19 +407,19 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
|
||||
if choices:
|
||||
if low_confidence:
|
||||
print >> sys.stderr,"Online search: Multiple low confidence matches. Save aborted"
|
||||
print "Online search: Multiple low confidence matches. Save aborted"
|
||||
match_results.lowConfidenceMatches.append(MultipleMatch(filename,matches))
|
||||
return
|
||||
else:
|
||||
print >> sys.stderr,"Online search: Multiple good matches. Save aborted"
|
||||
print "Online search: Multiple good matches. Save aborted"
|
||||
match_results.multipleMatches.append(MultipleMatch(filename,matches))
|
||||
return
|
||||
if low_confidence and opts.abortOnLowConfidence:
|
||||
print >> sys.stderr,"Online search: Low confidence match. Save aborted"
|
||||
print "Online search: Low confidence match. Save aborted"
|
||||
match_results.lowConfidenceMatches.append(MultipleMatch(filename,matches))
|
||||
return
|
||||
if not found_match:
|
||||
print >> sys.stderr,"Online search: No match found. Save aborted"
|
||||
print "Online search: No match found. Save aborted"
|
||||
match_results.noMatches.append(filename)
|
||||
return
|
||||
|
||||
|
@ -454,7 +454,7 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
md = create_local_metadata( opts, ca, use_tags )
|
||||
|
||||
if md.series is None:
|
||||
print >> sys.stderr, msg_hdr + "Can't rename without series name"
|
||||
print msg_hdr + "Can't rename without series name"
|
||||
return
|
||||
|
||||
new_ext = None # default
|
||||
|
@ -472,7 +472,7 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
new_name = renamer.determineName( filename, ext=new_ext )
|
||||
|
||||
if new_name == os.path.basename(filename):
|
||||
print >> sys.stderr, msg_hdr + "Filename is already good!"
|
||||
print msg_hdr + "Filename is already good!"
|
||||
return
|
||||
|
||||
folder = os.path.dirname( os.path.abspath( filename ) )
|
||||
|
@ -493,7 +493,7 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
msg_hdr = u"{0}: ".format(filename)
|
||||
|
||||
if not ca.isRar():
|
||||
print >> sys.stderr, msg_hdr + "Archive is not a RAR."
|
||||
print msg_hdr + "Archive is not a RAR."
|
||||
return
|
||||
|
||||
rar_file = os.path.abspath( os.path.abspath( filename ) )
|
||||
|
@ -514,7 +514,7 @@ def process_file_cli( filename, opts, settings, match_results ):
|
|||
try:
|
||||
os.unlink( rar_file )
|
||||
except:
|
||||
print >> sys.stderr, msg_hdr + "Error deleting original RAR after export"
|
||||
print msg_hdr + "Error deleting original RAR after export"
|
||||
delete_success = False
|
||||
else:
|
||||
delete_success = True
|
||||
|
|
|
@ -60,7 +60,7 @@ def ctmain():
|
|||
|
||||
if not qt_available and not opts.no_gui:
|
||||
opts.no_gui = True
|
||||
print >> sys.stderr, "PyQt4 is not available. ComicTagger is limited to command-line mode."
|
||||
print "PyQt4 is not available. ComicTagger is limited to command-line mode."
|
||||
|
||||
if opts.no_gui:
|
||||
cli.cli_mode( opts, settings )
|
||||
|
|
|
@ -1245,6 +1245,7 @@ class PostProcessor(object):
|
|||
|
||||
else:
|
||||
#need to set the filename source as the new name of the file returned from comictagger.
|
||||
odir = os.path.split(pcheck)[0]
|
||||
ofilename = os.path.split(pcheck)[1]
|
||||
ext = os.path.splitext(ofilename)[1]
|
||||
self._log("Sucessfully wrote metadata to .cbz - Continuing..")
|
||||
|
@ -1322,6 +1323,9 @@ class PostProcessor(object):
|
|||
# else:
|
||||
if pcheck == "fail":
|
||||
odir, ofilename = os.path.split(ml['ComicLocation'])
|
||||
elif pcheck:
|
||||
#odir, ofilename already set. Carry it through.
|
||||
pass
|
||||
else:
|
||||
odir = os.path.split(ml['ComicLocation'])[0]
|
||||
logger.fdebug(module + ' ofilename:' + ofilename)
|
||||
|
|
|
@ -320,6 +320,7 @@ CT_TAG_CR = 1
|
|||
CT_TAG_CBL = 1
|
||||
CT_CBZ_OVERWRITE = 0
|
||||
UNRAR_CMD = None
|
||||
CT_SETTINGSPATH = None
|
||||
|
||||
UPCOMING_SNATCHED = 1
|
||||
|
||||
|
@ -419,7 +420,7 @@ def initialize():
|
|||
NEWZNAB, NEWZNAB_NAME, NEWZNAB_HOST, NEWZNAB_APIKEY, NEWZNAB_UID, NEWZNAB_ENABLED, EXTRA_NEWZNABS, NEWZNAB_EXTRA, \
|
||||
ENABLE_TORZNAB, TORZNAB_NAME, TORZNAB_HOST, TORZNAB_APIKEY, TORZNAB_CATEGORY, \
|
||||
EXPERIMENTAL, ALTEXPERIMENTAL, \
|
||||
ENABLE_META, CMTAGGER_PATH, CT_TAG_CR, CT_TAG_CBL, CT_CBZ_OVERWRITE, UNRAR_CMD, UPDATE_ENDED, INDIE_PUB, BIGGIE_PUB, IGNORE_HAVETOTAL, SNATCHED_HAVETOTAL, PROVIDER_ORDER, \
|
||||
ENABLE_META, CMTAGGER_PATH, CT_TAG_CR, CT_TAG_CBL, CT_CBZ_OVERWRITE, UNRAR_CMD, CT_SETTINGSPATH, UPDATE_ENDED, INDIE_PUB, BIGGIE_PUB, IGNORE_HAVETOTAL, SNATCHED_HAVETOTAL, PROVIDER_ORDER, \
|
||||
dbUpdateScheduler, searchScheduler, RSSScheduler, WeeklyScheduler, VersionScheduler, FolderMonitorScheduler, \
|
||||
ENABLE_TORRENTS, MINSEEDS, TORRENT_LOCAL, LOCAL_WATCHDIR, TORRENT_SEEDBOX, SEEDBOX_HOST, SEEDBOX_PORT, SEEDBOX_USER, SEEDBOX_PASS, SEEDBOX_WATCHDIR, \
|
||||
ENABLE_RSS, RSS_CHECKINTERVAL, RSS_LASTRUN, FAILED_DOWNLOAD_HANDLING, FAILED_AUTO, ENABLE_TORRENT_SEARCH, ENABLE_KAT, KAT_PROXY, ENABLE_32P, MODE_32P, KEYS_32P, RSSFEED_32P, USERNAME_32P, PASSWORD_32P, AUTHKEY_32P, PASSKEY_32P, FEEDINFO_32P, VERIFY_32P, SNATCHEDTORRENT_NOTIFY, \
|
||||
|
@ -1047,15 +1048,15 @@ def initialize():
|
|||
#comictagger - force to use included version if option is enabled.
|
||||
if ENABLE_META:
|
||||
CMTAGGER_PATH = PROG_DIR
|
||||
logger.info('Setting ComicTagger default path to : ' + PROG_DIR)
|
||||
#we need to make sure the default folder setting for the comictagger settings exists so things don't error out
|
||||
CT_SETTINGSPATH = os.path.join(PROG_DIR, 'lib', 'comictaggerlib', 'ct_settings')
|
||||
logger.info('Setting ComicTagger settings default path to : ' + CT_SETTINGSPATH)
|
||||
|
||||
if os.path.exists(os.path.join(PROG_DIR, 'lib', 'comictaggerlib', 'ct_settings')):
|
||||
if os.path.exists(CT_SETTINGSPATH):
|
||||
logger.info('ComicTagger settings location exists.')
|
||||
else:
|
||||
try:
|
||||
os.mkdir(os.path.join(PROG_DIR, 'lib', 'comictaggerlib', 'ct_settings'))
|
||||
os.mkdir(CT_SETTINGSPATH)
|
||||
except OSError,e:
|
||||
if e.errno != errno.EEXIST:
|
||||
logger.error('Unable to create setting directory for ComicTagger. This WILL cause problems when tagging.')
|
||||
|
|
|
@ -18,7 +18,7 @@ import mylar
|
|||
from mylar import logger
|
||||
|
||||
|
||||
def run(dirName, nzbName=None, issueid=None, comversion=None, manual=None, filename=None, module=None):
|
||||
def run(dirName, nzbName=None, issueid=None, comversion=None, manual=None, filename=None, module=None, manualmeta=False):
|
||||
if module is None:
|
||||
module = ''
|
||||
module += '[META-TAGGER]'
|
||||
|
@ -101,7 +101,10 @@ def run(dirName, nzbName=None, issueid=None, comversion=None, manual=None, filen
|
|||
import tempfile
|
||||
new_folder = os.path.join(tempfile.mkdtemp(prefix='mylar_', dir=mylar.CACHE_DIR)) #prefix, suffix, dir
|
||||
new_filepath = os.path.join(new_folder, filename)
|
||||
if mylar.FILE_OPTS == 'copy' and manualmeta == False:
|
||||
shutil.copy(filepath, new_filepath)
|
||||
else:
|
||||
shutil.move(filepath, new_filepath)
|
||||
filepath = new_filepath
|
||||
except:
|
||||
logger.warn(module + ' Unable to create temporary directory to perform meta-tagging. Processing without metatagging.')
|
||||
|
@ -222,15 +225,14 @@ def run(dirName, nzbName=None, issueid=None, comversion=None, manual=None, filen
|
|||
logger.fdebug(module + ' Absolute path to script: ' +script_cmd[0])
|
||||
try:
|
||||
p = subprocess.Popen(script_cmd, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)
|
||||
out, err = p.communicate() # @UnusedVariable
|
||||
#logger.info('out:' + str(out))
|
||||
#logger.info('err:' + str(err))
|
||||
out, err = p.communicate()
|
||||
|
||||
if initial_ctrun and 'exported successfully' in out:
|
||||
logger.fdebug(module + '[COMIC-TAGGER] : ' +str(out))
|
||||
#Archive exported successfully to: X-Men v4 008 (2014) (Digital) (Nahga-Empire).cbz (Original deleted)
|
||||
tmpfilename = re.sub('Archive exported successfully to: ', '', out.rstrip())
|
||||
if mylar.FILE_OPTS == 'move':
|
||||
tmpfilename = re.sub('\(Original deleted\)', '', tmpname).strip()
|
||||
tmpfilename = re.sub('\(Original deleted\)', '', tmpfilename).strip()
|
||||
filepath = os.path.join(comicpath, tmpfilename)
|
||||
logger.fdebug(module + '[COMIC-TAGGER][CBR-TO-CBZ] New filename: ' + filepath)
|
||||
initial_ctrun = False
|
||||
|
@ -245,7 +247,7 @@ def run(dirName, nzbName=None, issueid=None, comversion=None, manual=None, filen
|
|||
file_error = 'file not found||' + filename
|
||||
return file_error
|
||||
else:
|
||||
logger.info(module + '[COMIC-TAGGER] Successfully wrote ' + tagdisp)
|
||||
logger.info(module + '[COMIC-TAGGER] Successfully wrote ' + tagdisp + ' [' + filepath + ']')
|
||||
i+=1
|
||||
except OSError, e:
|
||||
#Cannot find The Walking Dead 150 (2016) (Digital) (Zone-Empire).cbr
|
||||
|
|
|
@ -4136,7 +4136,7 @@ class WebInterface(object):
|
|||
module = '[MANUAL META-TAGGING]'
|
||||
try:
|
||||
import cmtagmylar
|
||||
metaresponse = cmtagmylar.run(dirName, issueid=issueid, filename=filename, comversion=comversion)
|
||||
metaresponse = cmtagmylar.run(dirName, issueid=issueid, filename=filename, comversion=comversion, manualmeta=True)
|
||||
except ImportError:
|
||||
logger.warn(module + ' comictaggerlib not found on system. Ensure the ENTIRE lib directory is located within mylar/lib/comictaggerlib/ directory.')
|
||||
metaresponse = "fail"
|
||||
|
@ -4149,6 +4149,8 @@ class WebInterface(object):
|
|||
return
|
||||
#launch failed download handling here.
|
||||
else:
|
||||
dst = os.path.join(dirName, os.path.split(metaresponse)[1])
|
||||
shutil.move(metaresponse, dst)
|
||||
logger.info(module + ' Sucessfully wrote metadata to .cbz (' + os.path.split(metaresponse)[1] + ') - Continuing..')
|
||||
|
||||
updater.forceRescan(comicid)
|
||||
|
|
Loading…
Add table
Reference in a new issue