diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index d49a1c6..2104e94 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -1471,6 +1471,8 @@ extra_titlepage_entries:readings,awards awards_label:Awards readings_label:Readings +## some sites include images that we don't ever want becoming the +## cover image. This lets you exclude them. cover_exclusion_regexp:art/.*Awards.jpg [voracity2.e-fic.com] @@ -1667,6 +1669,10 @@ dateUpdated_format:%%Y-%%m-%%d %%H:%%M:%%S ## to on, but can be switched off if it is found to cause problems. fix_fimf_blockquotes:true +## some sites include images that we don't ever want becoming the +## cover image. This lets you exclude them. +cover_exclusion_regexp:/images/emoticons/ + ## Site dedicated to these categories/characters/ships extracategories:My Little Pony: Friendship is Magic diff --git a/fanficfare/adapters/adapter_fimfictionnet.py b/fanficfare/adapters/adapter_fimfictionnet.py index fd55ceb..cd42ebc 100644 --- a/fanficfare/adapters/adapter_fimfictionnet.py +++ b/fanficfare/adapters/adapter_fimfictionnet.py @@ -176,7 +176,10 @@ class FimFictionNetSiteAdapter(BaseSiteAdapter): if coverurl.startswith('//'): # fix for img urls missing 'http:' coverurl = "http:"+coverurl if get_cover: - self.setCoverImage(self.url,coverurl) + # try setting from href, if fails, try using the img src + if self.setCoverImage(self.url,coverurl)[0] == "failedtoload": + coverurl = storyImage.find('img')['src'] + self.setCoverImage(self.url,coverurl) coverSource = storyImage.find('a', {'class':'source'}) if coverSource: diff --git a/fanficfare/adapters/base_adapter.py b/fanficfare/adapters/base_adapter.py index e7ae20b..1dbb3df 100644 --- a/fanficfare/adapters/base_adapter.py +++ b/fanficfare/adapters/base_adapter.py @@ -479,8 +479,8 @@ class BaseSiteAdapter(Configurable): def setCoverImage(self,storyurl,imgurl): if self.getConfig('include_images'): - self.story.addImgUrl(storyurl,imgurl,self._fetchUrlRaw,cover=True, - coverexclusion=self.getConfig('cover_exclusion_regexp')) + return self.story.addImgUrl(storyurl,imgurl,self._fetchUrlRaw,cover=True, + coverexclusion=self.getConfig('cover_exclusion_regexp')) # bs3 & bs4 are different here. # will move to a bs3 vs bs4 block if there's lots of changes. diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index dbd26a7..b6294dc 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -1656,6 +1656,10 @@ dateUpdated_format:%%Y-%%m-%%d %%H:%%M:%%S ## to on, but can be switched off if it is found to cause problems. fix_fimf_blockquotes:true +## some sites include images that we don't ever want becoming the +## cover image. This lets you exclude them. +cover_exclusion_regexp:/images/emoticons/ + ## Site dedicated to these categories/characters/ships extracategories:My Little Pony: Friendship is Magic diff --git a/fanficfare/story.py b/fanficfare/story.py index 9d78fd8..a0674d4 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -51,7 +51,7 @@ try: export = False img = Image() img.load(data) - + owidth, oheight = img.size nwidth, nheight = sizes scaled, nwidth, nheight = fit_image(owidth, oheight, nwidth, nheight)