Skip to content

Commit

Permalink
Merge branch 'python3-dev'
Browse files Browse the repository at this point in the history
IMP: Update look4untaggedcbzs.py (@DieselTech)
FIX: Tweaked Issue ID parsing to handle any subsequent numbers in Notes field (@falo2k)
FIX: Rechecking Story-Arc directory fails on missing issue numbers (@qubidt)
FIX:(mylar3#1179) Allow for POST method on pages where large amounts of data is being sent (ie.config/manage)
FIX:(mylar3#1321) Imprints would take json naming convention over CV (ini option added)
  • Loading branch information
evilhero committed Mar 22, 2023
2 parents 5c1b5e2 + cfd98a7 commit 4db40cd
Show file tree
Hide file tree
Showing 12 changed files with 72 additions and 32 deletions.
2 changes: 1 addition & 1 deletion data/interfaces/default/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -1712,7 +1712,7 @@ <h3><img src="images/gotify.png" style="vertical-align: middle; margin: 3px; mar
</tr>
</table>
</div>
<input type="button" value="Save Changes" onclick="doAjaxCall('configUpdate',$(this),'tabs',true);return false;" data-success="Changes saved successfully">
<input type="button" value="Save Changes" onclick="doAjaxCall('configUpdate',$(this),'tabs',true,'post');return false;" data-success="Changes saved successfully">
<div class="message">
<p><span class="ui-icon ui-icon-info" style="float: left; margin-right: .3em;"></span>Web Interface changes require a restart to take effect</p>
</div>
Expand Down
4 changes: 2 additions & 2 deletions data/interfaces/default/history.html
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@
<h1 class="clearfix"><img src="images/icon_history.png" alt="History"/>History</h1>
</div>

<form action="markissues" method="get" id="markissues">
<form action="markissues" method="post" id="markissues">
<div id="markissue">Mark selected issues as
<select name="action" onChange="doAjaxCall('markissues',$(this),'table',true);" data-success="selected issues marked">
<select name="action" onChange="doAjaxCall('markissues',$(this),'table',true,'post');" data-success="selected issues marked">
<option disabled="disabled" selected="selected">Choose...</option>
<option value="Retry">Retry</option>
<option value="Clear">Clear</option>
Expand Down
4 changes: 2 additions & 2 deletions data/interfaces/default/importresults.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,9 @@ <h1 class="clearfix">Ultron Import Results</h1>
</div>
<div class="table_wrapper">

<form action="markImports" method="get" id="markImports">
<form action="markImports" method="post" id="markImports">
<div id="markcomic">
<select name="action" onChange="doAjaxCall('markImports',$(this),'table',true);" data-success="Now running background Import" data-error="You didn't select any comics">
<select name="action" onChange="doAjaxCall('markImports',$(this),'table',true,'post');" data-success="Now running background Import" data-error="You didn't select any comics">
<option disabled="disabled" selected="selected">Choose...</option>
<option value="importselected">Start Import</option>
<option value="removeimport">Remove</option>
Expand Down
4 changes: 2 additions & 2 deletions data/interfaces/default/managecomics.html
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
<div id="manageheader" class="title">
<h1 class="clearfix">Manage comics</h1>
</div>
<form action="markComics" method="get" id="markComics">
<form action="markComics" method="post" id="markComics">
<div id="markcomics" style="top:0;">
<select name="action" onChange="doAjaxCall('markComics',$(this),'table',true);" data-error="You didn't select any comics">
<select name="action" onChange="doAjaxCall('markComics',$(this),'table',true,'post');" data-error="You didn't select any comics">
<option disabled="disabled" selected="selected">Choose...</option>
<option value="delete">Delete Series</option>
<option value="metatag">MetaTag Series</option>
Expand Down
6 changes: 3 additions & 3 deletions data/interfaces/default/manageissues.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
<h1 class="clearfix">Manage Issues</h1>
</div>

<form action="manageIssues" method="get">
<form action="manageIssues" method="post">
<div>
<label>Manage Issues with Status&nbsp&nbsp</label><select name="status">
%for curStatus in ['Wanted', 'Downloaded', 'Snatched', 'Skipped', 'Archived', 'Ignored', 'Failed']:
Expand All @@ -35,9 +35,9 @@ <h1 class="clearfix">Manage Issues</h1>
</div>
</form>
</br></br>
<form action="markissues" method="get" id="markissues">
<form action="markissues" method="post" id="markissues">
<div id="markissues" style="top:0;">
<select name="action" onChange="doAjaxCall('markissues',$(this),'table',true);" data-error="You didn't select any issues">
<select name="action" onChange="doAjaxCall('markissues',$(this),'table',true,'post');" data-error="You didn't select any issues">
<option disabled="disabled" selected="selected">Choose...</option>
<option value="Wanted">Wanted</option>
<option value="Archived">Archived</option>
Expand Down
9 changes: 8 additions & 1 deletion data/js/script.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ function showMsg(msg,loader,timeout,ms) {
}
}

function doAjaxCall(url,elem,reload,form) {
function doAjaxCall(url,elem,reload,form,method) {
// Set Message
feedback = $("#ajaxMsg");
update = $("#updatebar");
Expand All @@ -154,7 +154,13 @@ function doAjaxCall(url,elem,reload,form) {
var formID = "#"+url;
if ( form == true ) {
var dataString = $(formID).serialize();
if ( !method ) {
method = 'get';
}
// jquery > 1.9.0 has 'type' set as an alias for 'method' for backwards compatibility.
//alert('method used:'+method);
}

// Loader Image
var loader = $("<img src='images/loader_black.gif' alt='loading' class='loader'/>");
// Data Success Message
Expand Down Expand Up @@ -194,6 +200,7 @@ function doAjaxCall(url,elem,reload,form) {
// Ajax Call
$.ajax({
url: url,
type: method,
data: dataString,
beforeSend: function(jqXHR, settings) {
// Start loader etc.
Expand Down
7 changes: 7 additions & 0 deletions mylar/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@
SESSION_ID = None
UPDATE_VALUE = {}
REQS = {}
IMPRINT_MAPPING = {
#ComicVine: imprint.json
'Homage': 'Homage Comics',
'Mailbu': 'Malibu Comics',
'Milestone': 'Milestone Comics',
'Skybound': 'Skybound Entertainment',
'Top Cow': 'Top Cow Productions'}
SCHED = BackgroundScheduler({
'apscheduler.executors.default': {
'class': 'apscheduler.executors.pool:ThreadPoolExecutor',
Expand Down
1 change: 1 addition & 0 deletions mylar/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@
'CV_ONETIMER': (bool, 'CV', True),
'CVINFO': (bool, 'CV', False),
'CV_USER_AGENT': (str, 'CV', 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.246'),
'IMPRINT_MAPPING_TYPE': (str, 'CV', 'CV'), # either 'CV' for ComicVine or 'JSON' for imprints.json to choose which naming to use for imprints

'LOG_DIR' : (str, 'Logs', None),
'MAX_LOGSIZE' : (int, 'Logs', 10000000),
Expand Down
21 changes: 17 additions & 4 deletions mylar/cv.py
Original file line number Diff line number Diff line change
Expand Up @@ -1579,10 +1579,23 @@ def get_imprint_volume_and_booktype(series, comicyear, publisher, firstissueid,
found = True
break
elif all([f != 'imprints', f != 'publication_run']) and h is not None and found is not True:
if h.lower() == comic['ComicPublisher'].lower():
logger.info('imprint matched: %s ---> %s' % (d, h))
comicPublisher = d
publisherImprint = h
imprint_match = False
for x, y in mylar.IMPRINT_MAPPING.items():
if all([
y.lower() == h.lower(),
x.lower() == comic['ComicPublisher'].lower()
]):
imprint_match = True
break

if h.lower() == comic['ComicPublisher'].lower() or imprint_match is True:
if mylar.CONFIG.IMPRINT_MAPPING_TYPE == 'CV':
comicPublisher = d
publisherImprint = comic['ComicPublisher']
else:
comicPublisher = d
publisherImprint = h
logger.fdebug('imprint matching: [PRIORITY:%s] %s ---> %s' % (mylar.CONFIG.IMPRINT_MAPPING_TYPE, comicPublisher, publisherImprint))
chkyear = True
found = True

Expand Down
16 changes: 5 additions & 11 deletions mylar/librarysync.py
Original file line number Diff line number Diff line change
Expand Up @@ -363,18 +363,12 @@ def libraryScan(dir=None, append=False, ComicID=None, ComicName=None, cron=None,
# if used by ComicTagger, Notes field will have the IssueID.
issuenotes = issueinfo['metadata']['notes']
logger.fdebug('[IMPORT-CBZ] Notes: ' + issuenotes)
# Attempt to parse the first set of consecutive numbers after either CVDB or Issue ID
if issuenotes is not None and issuenotes != 'None':
if 'Issue ID' in issuenotes:
st_find = issuenotes.find('Issue ID')
tmp_issuenotes_id = re.sub("[^0-9]", " ", issuenotes[st_find:]).strip()
if tmp_issuenotes_id.isdigit():
issuenotes_id = tmp_issuenotes_id
logger.fdebug('[IMPORT-CBZ] Successfully retrieved CV IssueID for ' + comicname + ' #' + issue_number + ' [' + str(issuenotes_id) + ']')
elif 'CVDB' in issuenotes:
st_find = issuenotes.find('CVDB')
tmp_issuenotes_id = re.sub("[^0-9]", " ", issuenotes[st_find:]).strip()
if tmp_issuenotes_id.isdigit():
issuenotes_id = tmp_issuenotes_id
issue_id = re.search("(CVDB|Issue ID)[^0-9]*([0-9]*)", issuenotes)
if issue_id:
if issue_id.groups()[1].isdigit():
issuenotes_id = issue_id.groups()[1]
logger.fdebug('[IMPORT-CBZ] Successfully retrieved CV IssueID for ' + comicname + ' #' + issue_number + ' [' + str(issuenotes_id) + ']')
else:
logger.fdebug('[IMPORT-CBZ] Unable to retrieve IssueID from meta-tagging. If there is other metadata present I will use that.')
Expand Down
6 changes: 5 additions & 1 deletion mylar/webserve.py
Original file line number Diff line number Diff line change
Expand Up @@ -5163,7 +5163,11 @@ def ArcWatchlist(self,StoryArcID=None):
for tmpfc in valids: #filelist:
haveissue = "no"
issuedupe = "no"
temploc = tmpfc['issue_number'].replace('_', ' ')
temploc = tmpfc['issue_number']
if temploc:
temploc = temploc.replace('_', ' ')
else:
logger.debug('could not parse issue number: %r', tmpfc)
fcdigit = helpers.issuedigits(arc['IssueNumber'])
int_iss = helpers.issuedigits(temploc)
if int_iss == fcdigit:
Expand Down
24 changes: 19 additions & 5 deletions utilities/look4untaggedcbzs.py
Original file line number Diff line number Diff line change
@@ -1,27 +1,41 @@
from lib2to3.pgen2.token import NEWLINE
import sys
import zipfile
import os
import subprocess
from zipfile import BadZipFile
from pathlib import Path

results = subprocess.run(['find', '.', '-iname', '*.cbz'], universal_newlines = True, stdout=subprocess.PIPE)
results = Path().cwd().glob('**/*.cbz')
file1 = open("notags.txt", "a")
file2 = open("badzip.txt", "a")

for result in results.stdout.splitlines():

for result in results:
tagged = 0
target_zip = str(result)
# with pathlib your result is always going to be
# a path object
# making this unnecessary
target_zip = result
# print("file: %s" % target_zip)
try:
with zipfile.ZipFile(target_zip) as zip_file:
for member in zip_file.namelist():
if 'ComicInfo.xml' in member:
tagged = 1
if tagged == 0:
print("Filename %s is not metatagged" % target_zip)
print('Filename %s is not metatagged' % target_zip)
stuff= f'Filename {target_zip} is not metatagged' + os.linesep
file1.write(stuff)
elif tagged == 1:
next
# print("filename %s is correctly metatagged" % target_zip)
else:
print("Something's not right! %s" % target_zip)
except BadZipFile:
print("%s is a bad zipfile!" % target_zip)
print("%s is a bad zipfile!" % target_zip)
badstuff= f'{target_zip} is a bad zipfile' + os.linesep
file2.write(badstuff)

file1.close()
file2.close()

0 comments on commit 4db40cd

Please sign in to comment.