From f7b5feede61fb3bdcc32a68824099375dbc233a4 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 12 Jan 2012 21:39:32 -0600 Subject: [PATCH] Plugin 1.1.4, fix Category title, keep calibre_bookmarks.txt on epub update. --- calibre-plugin/__init__.py | 2 +- epubmerge.py | 13 ++++++++++++- plugin-defaults.ini | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index 7c35407..e8751de 100644 --- a/calibre-plugin/__init__.py +++ b/calibre-plugin/__init__.py @@ -27,7 +27,7 @@ class FanFictionDownLoaderBase(InterfaceActionBase): description = 'UI plugin to download FanFiction stories from various sites.' supported_platforms = ['windows', 'osx', 'linux'] author = 'Jim Miller' - version = (1, 1, 3) + version = (1, 1, 4) minimum_calibre_version = (0, 8, 30) #: This field defines the GUI plugin class that contains all the code diff --git a/epubmerge.py b/epubmerge.py index 99e2523..7c83fdc 100644 --- a/epubmerge.py +++ b/epubmerge.py @@ -224,10 +224,21 @@ def doMerge(outputio,files,authoropts=[],titleopt=None,descopt=None, pass # Skip missing files. for itemref in metadom.getElementsByTagName("itemref"): + if not striptitletoc or not re.match(r'(title|toc)_page', itemref.getAttribute("idref")): itemrefs.append(bookid+itemref.getAttribute("idref")) booknum=booknum+1; + if not forceunique: + # If not forceunique, it's an epub update. + # If there's a "calibre_bookmarks.txt", it's from reading + # in Calibre and should be preserved. + try: + fn = "META-INF/calibre_bookmarks.txt" + outputepub.writestr(fn,epub.read(fn)) + except: + pass + ## create content.opf file. uniqueid="epubmerge-uid-%d" % time() # real sophisticated uid scheme. @@ -355,7 +366,7 @@ def doMerge(outputio,files,authoropts=[],titleopt=None,descopt=None, ## during TOC generation to save loops. outputepub.writestr("content.opf",contentdom.toxml('utf-8')) outputepub.writestr("toc.ncx",tocncxdom.toxml('utf-8')) - + # declares all the files created by Windows. otherwise, when # it runs in appengine, windows unzips the files as 000 perms. for zf in outputepub.filelist: diff --git a/plugin-defaults.ini b/plugin-defaults.ini index 8b22d85..55ca62d 100644 --- a/plugin-defaults.ini +++ b/plugin-defaults.ini @@ -34,7 +34,7 @@ formatext_label:File Extension ## Sometimes Harry Potter is a category and Fantasy a genre. (fanfiction.net) ## Sometimes Fantasy is category *and* a genre (fictionpress.com) ## Sometimes there are multiple categories and/or genres. -category_label:Categoryq +category_label:Category genre_label:Genre characters_label:Characters ## Completed/In-Progress