From e7aa49b70c70c998f95015247194d9db5fc43e3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pawe=C5=82=20Jastrz=C4=99bski?= Date: Sun, 8 Mar 2015 18:06:27 +0100 Subject: [PATCH] Fixed bookmark drift caused by image splits --- kcc/comic2ebook.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index b654d2a..7b5f725 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -448,10 +448,18 @@ def buildEPUB(path, chapterNames, tomeNumber): # Overwrite chapternames if tree is flat and ComicInfo.xml has bookmarks if not chapterNames and options.chapters: chapterlist = [] + globaldiff = 0 for aChapter in options.chapters: - filename = filelist[aChapter[0]][1] - chapterlist.append((filelist[aChapter[0]][0].replace('Images', 'Text'), filename)) + pageid = aChapter[0] + for x in range(0, pageid + globaldiff + 1): + if '-aaa-kcc' in filelist[x][1]: + pageid += 1 + if '-bbb-kcc' in filelist[pageid][1]: + pageid -= 1 + filename = filelist[pageid][1] + chapterlist.append((filelist[pageid][0].replace('Images', 'Text'), filename)) chapterNames[filename] = aChapter[1] + globaldiff = pageid - (aChapter[0] + globaldiff) buildNCX(path, options.title, chapterlist, chapterNames) buildOPF(path, options.title, filelist, cover)