diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 0a9a069..d677ea1 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -109,6 +109,11 @@ class FanFictionDownLoaderPlugin(InterfaceAction): self.menus_lock = threading.RLock() + def initialization_complete(self): + # otherwise configured hot keys won't work until the menu's + # been displayed once. + self.rebuild_menus() + def about_to_show_menu(self): self.rebuild_menus() diff --git a/fanficdownloader/adapters/adapter_adastrafanficcom.py b/fanficdownloader/adapters/adapter_adastrafanficcom.py index bc908a2..14fe48e 100644 --- a/fanficdownloader/adapters/adapter_adastrafanficcom.py +++ b/fanficdownloader/adapters/adapter_adastrafanficcom.py @@ -79,6 +79,11 @@ class AdAstraFanficComSiteAdapter(BaseSiteAdapter): if "Content is only suitable for mature adults. May contain explicit language and adult themes. Equivalent of NC-17." in data: raise exceptions.AdultCheckRequired(self.url) + # problems with some stories, but only in calibre. I suspect + # issues with different SGML parsers in python. This is a + # nasty hack, but it works. + data = data[data.index(" ??? wtf? + data = ""+data[data.index(""):] + # use BeautifulSoup HTML parser to make everything easier to find. soup = bs.BeautifulSoup(data) @@ -170,6 +176,12 @@ class TwilightedNetSiteAdapter(BaseSiteAdapter): for cat in catstext: self.story.addToList('category',cat.string) + if 'Characters' in label: + chars = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=characters')) + charstext = [char.string for char in chars] + for char in charstext: + self.story.addToList('characters',char.string) + ## twilighted.net doesn't use genre. # if 'Genre' in label: # genres = labelspan.parent.findAll('a',href=re.compile(r'browse.php\?type=class')) @@ -197,7 +209,14 @@ class TwilightedNetSiteAdapter(BaseSiteAdapter): logging.debug('Getting chapter text from: %s' % url) - soup = bs.BeautifulStoneSoup(self._fetchUrl(url), + data = self._fetchUrl(url) + # problems with some stories, but only in calibre. I suspect + # issues with different SGML parsers in python. This is a + # nasty hack, but it works. + # twilighted isn't writing ??? wtf? + data = ""+data[data.index(""):] + + soup = bs.BeautifulStoneSoup(data, selfClosingTags=('br','hr')) # otherwise soup eats the br/hr tags. span = soup.find('div', {'id' : 'story'}) diff --git a/fanficdownloader/adapters/adapter_twiwritenet.py b/fanficdownloader/adapters/adapter_twiwritenet.py index 9473d99..871ad9a 100644 --- a/fanficdownloader/adapters/adapter_twiwritenet.py +++ b/fanficdownloader/adapters/adapter_twiwritenet.py @@ -117,10 +117,13 @@ class TwiwriteNetSiteAdapter(BaseSiteAdapter): if "Access denied. This story has not been validated by the adminstrators of this site." in data: raise exceptions.FailedToDownload(self.getSiteDomain() +" says: Access denied. This story has not been validated by the adminstrators of this site.") - + + # problems with some stories, but only in calibre. I suspect + # issues with different SGML parsers in python. This is a + # nasty hack, but it works. + data = data[data.index("]+>','',moremeta) # strip tags.