Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Override book's title if Title is set in XML #532

Merged
merged 3 commits into from
Jun 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion kindlecomicconverter/comic2ebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -695,7 +695,9 @@ def getComicInfo(path, originalpath):
os.remove(xmlPath)
return
options.authors = []
if defaultTitle:
if xml.data['Title']:
options.title = hescape(xml.data['Title'])
elif defaultTitle:
if xml.data['Series']:
options.title = hescape(xml.data['Series'])
if xml.data['Volume']:
Expand Down
11 changes: 8 additions & 3 deletions kindlecomicconverter/metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ def __init__(self, source):
'Inkers': [],
'Colorists': [],
'Summary': '',
'Bookmarks': []}
'Bookmarks': [],
'Title': ''}
self.rawdata = None
self.format = None
if self.source.endswith('.xml') and os.path.exists(self.source):
Expand All @@ -58,6 +59,8 @@ def parseXML(self):
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
if len(self.rawdata.getElementsByTagName('Title')) != 0:
self.data['Title'] = 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(', '):
Expand All @@ -76,7 +79,8 @@ def saveXML(self):
for row in (['Series', self.data['Series']], ['Volume', self.data['Volume']],
['Number', self.data['Number']], ['Writer', ', '.join(self.data['Writers'])],
['Penciller', ', '.join(self.data['Pencillers'])], ['Inker', ', '.join(self.data['Inkers'])],
['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']]):
['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']],
['Title', self.data['Title']]):
if self.rawdata.getElementsByTagName(row[0]):
node = self.rawdata.getElementsByTagName(row[0])[0]
if row[1]:
Expand All @@ -97,7 +101,8 @@ def saveXML(self):
for row in (['Series', self.data['Series']], ['Volume', self.data['Volume']],
['Number', self.data['Number']], ['Writer', ', '.join(self.data['Writers'])],
['Penciller', ', '.join(self.data['Pencillers'])], ['Inker', ', '.join(self.data['Inkers'])],
['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']]):
['Colorist', ', '.join(self.data['Colorists'])], ['Summary', self.data['Summary']],
['Title', self.data['Title']]):
if row[1]:
main = doc.createElement(row[0])
root.appendChild(main)
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@ python-slugify>=1.2.1
raven>=6.0.0
# PyQt5-tools
mozjpeg-lossless-optimization>=1.1.2
distro
distro