From 33e2a4766e8a9ee6046bc48aa15a198c8430ac92 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 14 Jun 2012 19:07:49 -0500 Subject: [PATCH] Add cover image to fanfiction.net, but default 'never_make_cover: true' for ffnet. --- calibre-plugin/__init__.py | 2 +- defaults.ini | 3 +++ fanficdownloader/adapters/adapter_fanfictionnet.py | 5 +++++ plugin-defaults.ini | 3 +++ 4 files changed, 12 insertions(+), 1 deletion(-) diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index adb1f031..f5f2de8e 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, 32) + version = (1, 5, 33) minimum_calibre_version = (0, 8, 30) #: This field defines the GUI plugin class that contains all the code diff --git a/defaults.ini b/defaults.ini index cd30ac9e..cb3ee5ec 100644 --- a/defaults.ini +++ b/defaults.ini @@ -464,6 +464,9 @@ cover_exclusion_regexp:/images/.*?ribbon.gif [www.dokuga.com] [www.fanfiction.net] +## fanfiction.net's 'cover' images are really just tiny thumbnails. +## Comment this out or change it to false to use them anyway. +never_make_cover: true [www.ficbook.net] diff --git a/fanficdownloader/adapters/adapter_fanfictionnet.py b/fanficdownloader/adapters/adapter_fanfictionnet.py index 47996c7d..7e57f0c3 100644 --- a/fanficdownloader/adapters/adapter_fanfictionnet.py +++ b/fanficdownloader/adapters/adapter_fanfictionnet.py @@ -242,6 +242,11 @@ class FanFictionNetSiteAdapter(BaseSiteAdapter): self.story.setMetadata('status', 'Completed') else: self.story.setMetadata('status', 'In-Progress') + + img = soup.find('img',{'class':'cimage'}) + if img: + self.story.addImgUrl(self,url,img['src'],self._fetchUrlRaw,cover=True) + return def getChapterText(self, url): diff --git a/plugin-defaults.ini b/plugin-defaults.ini index a8422568..557583ad 100644 --- a/plugin-defaults.ini +++ b/plugin-defaults.ini @@ -449,6 +449,9 @@ cover_exclusion_regexp:/images/.*?ribbon.gif [www.dokuga.com] [www.fanfiction.net] +## fanfiction.net's 'cover' images are really just tiny thumbnails. +## Comment this out or change it to false to use them anyway. +never_make_cover: true [www.ficbook.net]