1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

unescape ampersand (&) (#923)

This commit is contained in:
Alex Xu
2025-05-22 18:04:40 -07:00
committed by GitHub
parent 581ecd0ec2
commit dc711e671d
2 changed files with 10 additions and 9 deletions

View File

@@ -285,9 +285,9 @@ def buildOPF(dstdir, title, filelist, cover=None):
"<dc:identifier id=\"BookID\">urn:uuid:", options.uuid, "</dc:identifier>\n",
"<dc:contributor id=\"contributor\">KindleComicConverter-" + __version__ + "</dc:contributor>\n"])
if len(options.summary) > 0:
f.writelines(["<dc:description>", options.summary, "</dc:description>\n"])
f.writelines(["<dc:description>", hescape(options.summary), "</dc:description>\n"])
for author in options.authors:
f.writelines(["<dc:creator>", author, "</dc:creator>\n"])
f.writelines(["<dc:creator>", hescape(author), "</dc:creator>\n"])
f.writelines(["<meta property=\"dcterms:modified\">" + strftime("%Y-%m-%dT%H:%M:%SZ", gmtime()) + "</meta>\n",
"<meta name=\"cover\" content=\"cover\"/>\n"])
if options.iskindle and options.profile != 'Custom':
@@ -743,7 +743,7 @@ def getComicInfo(path, originalpath):
return
if defaultTitle:
if xml.data['Series']:
options.title = hescape(xml.data['Series'])
options.title = xml.data['Series']
if xml.data['Volume']:
titleSuffix += ' V' + xml.data['Volume'].zfill(2)
if xml.data['Number']:
@@ -753,7 +753,7 @@ def getComicInfo(path, originalpath):
options.authors = []
for field in ['Writers', 'Pencillers', 'Inkers', 'Colorists']:
for person in xml.data[field]:
options.authors.append(hescape(person))
options.authors.append(person)
if len(options.authors) > 0:
options.authors = list(set(options.authors))
options.authors.sort()
@@ -762,7 +762,7 @@ def getComicInfo(path, originalpath):
if xml.data['Bookmarks']:
options.comicinfo_chapters = xml.data['Bookmarks']
if xml.data['Summary']:
options.summary = hescape(xml.data['Summary'])
options.summary = xml.data['Summary']
os.remove(xmlPath)

View File

@@ -20,6 +20,7 @@ import os
from xml.dom.minidom import parse, Document
from tempfile import mkdtemp
from shutil import rmtree
from xml.sax.saxutils import unescape
from . import comicarchive
@@ -52,19 +53,19 @@ class MetadataParser:
def parseXML(self):
if len(self.rawdata.getElementsByTagName('Series')) != 0:
self.data['Series'] = self.rawdata.getElementsByTagName('Series')[0].firstChild.nodeValue
self.data['Series'] = unescape(self.rawdata.getElementsByTagName('Series')[0].firstChild.nodeValue)
if len(self.rawdata.getElementsByTagName('Volume')) != 0:
self.data['Volume'] = self.rawdata.getElementsByTagName('Volume')[0].firstChild.nodeValue
if len(self.rawdata.getElementsByTagName('Number')) != 0:
self.data['Number'] = self.rawdata.getElementsByTagName('Number')[0].firstChild.nodeValue
if len(self.rawdata.getElementsByTagName('Summary')) != 0:
self.data['Summary'] = self.rawdata.getElementsByTagName('Summary')[0].firstChild.nodeValue
self.data['Summary'] = unescape(self.rawdata.getElementsByTagName('Summary')[0].firstChild.nodeValue)
if len(self.rawdata.getElementsByTagName('Title')) != 0:
self.data['Title'] = self.rawdata.getElementsByTagName('Title')[0].firstChild.nodeValue
self.data['Title'] = unescape(self.rawdata.getElementsByTagName('Title')[0].firstChild.nodeValue)
for field in ['Writer', 'Penciller', 'Inker', 'Colorist']:
if len(self.rawdata.getElementsByTagName(field)) != 0:
for person in self.rawdata.getElementsByTagName(field)[0].firstChild.nodeValue.split(', '):
self.data[field + 's'].append(person)
self.data[field + 's'].append(unescape(person))
self.data[field + 's'] = list(set(self.data[field + 's']))
self.data[field + 's'].sort()
if len(self.rawdata.getElementsByTagName('Page')) != 0: