about summary refs log tree commit diff
diff options
context:
space:
mode:
authorPaweł Jastrzębski <pawelj@iosphe.re>2015-03-08 18:06:27 +0100
committerPaweł Jastrzębski <pawelj@iosphe.re>2015-03-08 18:06:27 +0100
commite7aa49b70c70c998f95015247194d9db5fc43e3c (patch)
tree072b2c7379e749d578205e1b4c0221d0dc2f3e34
parentGUI tweak (diff)
downloadkcc-e7aa49b70c70c998f95015247194d9db5fc43e3c.tar.gz
kcc-e7aa49b70c70c998f95015247194d9db5fc43e3c.tar.bz2
kcc-e7aa49b70c70c998f95015247194d9db5fc43e3c.zip
Fixed bookmark drift caused by image splits
-rwxr-xr-xkcc/comic2ebook.py12
1 files 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)