mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 17:56:30 +00:00
Add ComicInfo bookmarks -> EPUB chapter support
Bookmarks from ComicRack's ComicInfo.xml are now converted to EPUB chapters. `Bookmark` is an attribute to the `Page` element in ComicInfo.xml. * Works with flat directory structure (no sub-folders support)
This commit is contained in:
committed by
Paweł Jastrzębski
parent
57b571b6c2
commit
ecbf60fb28
@@ -220,10 +220,14 @@ def buildNCX(dstdir, title, chapters, chapterNames):
|
|||||||
])
|
])
|
||||||
for chapter in chapters:
|
for chapter in chapters:
|
||||||
folder = chapter[0].replace(os.path.join(dstdir, 'OEBPS'), '').lstrip('/').lstrip('\\\\')
|
folder = chapter[0].replace(os.path.join(dstdir, 'OEBPS'), '').lstrip('/').lstrip('\\\\')
|
||||||
if os.path.basename(folder) != "Text":
|
|
||||||
title = chapterNames[os.path.basename(folder)]
|
|
||||||
filename = getImageFileName(os.path.join(folder, chapter[1]))
|
filename = getImageFileName(os.path.join(folder, chapter[1]))
|
||||||
f.write("<navPoint id=\"" + folder.replace('/', '_').replace('\\', '_') + "\"><navLabel><text>"
|
navID = folder.replace('/', '_').replace('\\', '_')
|
||||||
|
if options.chapters:
|
||||||
|
title = chapterNames[chapter[1]]
|
||||||
|
navID = filename[0].replace('/', '_').replace('\\', '_')
|
||||||
|
elif os.path.basename(folder) != "Text":
|
||||||
|
title = chapterNames[os.path.basename(folder)]
|
||||||
|
f.write("<navPoint id=\"" + navID + "\"><navLabel><text>"
|
||||||
+ title + "</text></navLabel><content src=\"" + filename[0].replace("\\", "/")
|
+ title + "</text></navLabel><content src=\"" + filename[0].replace("\\", "/")
|
||||||
+ ".html\"/></navPoint>\n")
|
+ ".html\"/></navPoint>\n")
|
||||||
f.write("</navMap>\n</ncx>")
|
f.write("</navMap>\n</ncx>")
|
||||||
@@ -441,6 +445,13 @@ def buildEPUB(path, chapterNames, tomeNumber):
|
|||||||
if lastfile and not options.panelviewused and 'Ko' not in options.profile \
|
if lastfile and not options.panelviewused and 'Ko' not in options.profile \
|
||||||
and options.profile not in ['K1', 'K2', 'KDX', 'OTHER']:
|
and options.profile not in ['K1', 'K2', 'KDX', 'OTHER']:
|
||||||
filelist[-1] = buildHTML(lastfile[0], lastfile[1], lastfile[2], True)
|
filelist[-1] = buildHTML(lastfile[0], lastfile[1], lastfile[2], True)
|
||||||
|
# Overwrite chapternames if tree is flat and ComicInfo.xml has bookmarks
|
||||||
|
if not chapterNames and options.chapters:
|
||||||
|
chapterlist = []
|
||||||
|
for aChapter in options.chapters:
|
||||||
|
filename = filelist[aChapter[0]][1]
|
||||||
|
chapterlist.append((filelist[aChapter[0]][0].replace('Images', 'Text'), filename))
|
||||||
|
chapterNames[filename] = aChapter[1]
|
||||||
buildNCX(path, options.title, chapterlist, chapterNames)
|
buildNCX(path, options.title, chapterlist, chapterNames)
|
||||||
buildOPF(path, options.title, filelist, cover)
|
buildOPF(path, options.title, filelist, cover)
|
||||||
|
|
||||||
@@ -624,6 +635,7 @@ def getComicInfo(path, originalPath):
|
|||||||
xmlPath = os.path.join(path, 'ComicInfo.xml')
|
xmlPath = os.path.join(path, 'ComicInfo.xml')
|
||||||
options.authors = ['KCC']
|
options.authors = ['KCC']
|
||||||
options.remoteCovers = {}
|
options.remoteCovers = {}
|
||||||
|
options.chapters = []
|
||||||
titleSuffix = ''
|
titleSuffix = ''
|
||||||
if options.title == 'defaulttitle':
|
if options.title == 'defaulttitle':
|
||||||
defaultTitle = True
|
defaultTitle = True
|
||||||
@@ -658,6 +670,8 @@ def getComicInfo(path, originalPath):
|
|||||||
options.authors = ['KCC']
|
options.authors = ['KCC']
|
||||||
if xml.data['MUid']:
|
if xml.data['MUid']:
|
||||||
options.remoteCovers = getCoversFromMCB(xml.data['MUid'])
|
options.remoteCovers = getCoversFromMCB(xml.data['MUid'])
|
||||||
|
if xml.data['Bookmarks']:
|
||||||
|
options.chapters = xml.data['Bookmarks']
|
||||||
os.remove(xmlPath)
|
os.remove(xmlPath)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -38,7 +38,8 @@ class MetadataParser:
|
|||||||
'Pencillers': [],
|
'Pencillers': [],
|
||||||
'Inkers': [],
|
'Inkers': [],
|
||||||
'Colorists': [],
|
'Colorists': [],
|
||||||
'MUid': ''}
|
'MUid': '',
|
||||||
|
'Bookmarks': []}
|
||||||
self.rawdata = None
|
self.rawdata = None
|
||||||
self.compressor = None
|
self.compressor = None
|
||||||
if self.source.endswith('.xml'):
|
if self.source.endswith('.xml'):
|
||||||
@@ -100,6 +101,11 @@ class MetadataParser:
|
|||||||
.search(self.rawdata.getElementsByTagName('ScanInformation')[0].firstChild.nodeValue)
|
.search(self.rawdata.getElementsByTagName('ScanInformation')[0].firstChild.nodeValue)
|
||||||
if coverId:
|
if coverId:
|
||||||
self.data['MUid'] = coverId.group(2)
|
self.data['MUid'] = coverId.group(2)
|
||||||
|
if len(self.rawdata.getElementsByTagName('Page')) != 0:
|
||||||
|
for page in self.rawdata.getElementsByTagName('Page'):
|
||||||
|
if 'Bookmark' in page.attributes and 'Image' in page.attributes:
|
||||||
|
self.data['Bookmarks'].append((int(page.attributes['Image'].value),
|
||||||
|
page.attributes['Bookmark'].value))
|
||||||
|
|
||||||
def saveXML(self):
|
def saveXML(self):
|
||||||
if self.rawdata:
|
if self.rawdata:
|
||||||
|
|||||||
Reference in New Issue
Block a user