diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index a65dec7..00457da 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, 5, 10) + version = (1, 5, 11) minimum_calibre_version = (0, 8, 30) #: This field defines the GUI plugin class that contains all the code diff --git a/fanficdownloader/adapters/base_adapter.py b/fanficdownloader/adapters/base_adapter.py index 35d6d03..5875ec0 100644 --- a/fanficdownloader/adapters/base_adapter.py +++ b/fanficdownloader/adapters/base_adapter.py @@ -331,10 +331,6 @@ class BaseSiteAdapter(Configurable): # This is primarily for epub updates. return re.sub(r"\r?\n?","",retval) -fullmon = {"January":"01", "February":"02", "March":"03", "April":"04", "May":"05", - "June":"06","July":"07", "August":"08", "September":"09", "October":"10", - "November":"11", "December":"12" } - def cachedfetch(realfetch,cache,url): if url in cache: print("cache hit") @@ -342,6 +338,9 @@ def cachedfetch(realfetch,cache,url): else: return realfetch(url) +fullmon = {"January":"01", "February":"02", "March":"03", "April":"04", "May":"05", + "June":"06","July":"07", "August":"08", "September":"09", "October":"10", + "November":"11", "December":"12" } def makeDate(string,format): # Surprise! Abstracting this turned out to be more useful than diff --git a/fanficdownloader/htmlcleanup.py b/fanficdownloader/htmlcleanup.py index d9e2d84..2e223e7 100644 --- a/fanficdownloader/htmlcleanup.py +++ b/fanficdownloader/htmlcleanup.py @@ -23,11 +23,16 @@ def _unirepl(match): radix=16 else: radix=10 - value = int(match.group(2), radix ) - return unichr(value) + value = int(match.group(2), radix) + return "%s%s"%(unichr(value),match.group(3)) def _replaceNumberEntities(data): - p = re.compile(r'&#(x?)([0-9a-fA-F]+);') + # The same brokenish entity parsing in SGMLParser that inserts ';' + # after non-entities will also insert ';' incorrectly after number + # entities, including part of the next word if it's a-z. + # "Don't—ever—do—that—again," becomes + # "Don't—e;ver—d;o—that—a;gain," + p = re.compile(r'&#(x?)([0-9a-fA-F]{,4})([0-9a-fA-F]*);') return p.sub(_unirepl, data) def _replaceNotEntities(data): @@ -50,9 +55,6 @@ def removeAllEntities(text): return removeEntities(text).replace('<', '<').replace('>', '>').replace('&', '&') def removeEntities(text): - - # replace numeric versions of [&<>] with named versions, - # then replace named versions with actual characters, if text is None: return "" @@ -67,6 +69,8 @@ def removeEntities(text): except UnicodeEncodeError, e: t = text text = t + # replace numeric versions of [&<>] with named versions, + # then replace named versions with actual characters, text = re.sub(r'�*38;','&',text) text = re.sub(r'�*60;','<',text) text = re.sub(r'�*62;','>',text) diff --git a/fanficdownloader/story.py b/fanficdownloader/story.py index 555cde3..c8f06a0 100644 --- a/fanficdownloader/story.py +++ b/fanficdownloader/story.py @@ -216,7 +216,7 @@ class Story: for (p,v) in self.replacements: if (isinstance(value,str) or isinstance(value,unicode)) and re.match(p,value): value = re.sub(p,v,value) - return value; + return value def getMetadata(self, key, removeallentities=False): value = None