diff --git a/.gitignore b/.gitignore index 3743024..1dee98b 100644 --- a/.gitignore +++ b/.gitignore @@ -25,3 +25,4 @@ output build dist FanFicFare.egg-info +personal.ini diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 7a42a3a..7adc253 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -1505,9 +1505,15 @@ user_agent: ## Set this to true to never use them. #never_make_cover: false -## fanfiction.net shows the user's +## exclude fanfiction.net imageu (old user vs story detect) and +## default user (d_60_90) cover_exclusion_regexp:(/imageu/|d_60_90\.jpg) +## April 2015, ffnet changed their story and user pictures urls to be +## the same. Now the only way to know if the story image is really +## the author image is to go get the author image and check. +skip_author_cover:true + ## fanfiction.net is blocking people more aggressively. If you ## download fewer stories less often you can likely get by with ## reducing this sleep. diff --git a/fanficfare/adapters/adapter_fanfictionnet.py b/fanficfare/adapters/adapter_fanfictionnet.py index 63f3a39..4a33dd6 100644 --- a/fanficfare/adapters/adapter_fanfictionnet.py +++ b/fanficfare/adapters/adapter_fanfictionnet.py @@ -268,14 +268,49 @@ class FanFictionNetSiteAdapter(BaseSiteAdapter): if get_cover: # Try the larger image first. + cover_url = "" try: img = soup.select('img.lazy.cimage') - self.setCoverImage(url,img[0]['data-original']) + cover_url=img[0]['data-original'] except: img = soup.select('img.cimage') if img: - self.setCoverImage(url,img[0]['src']) + cover_url=img[0]['src'] + logger.debug("cover_url:%s"%cover_url) + + authimg_url = "" + if cover_url and self.getConfig('skip_author_cover'): + authsoup = self.make_soup(self._fetchUrl(self.story.getMetadata('authorUrl'))) + try: + img = authsoup.select('img.lazy.cimage') + authimg_url=img[0]['data-original'] + except: + img = authsoup.select('img.cimage') + if img: + authimg_url=img[0]['src'] + + logger.debug("authimg_url:%s"%authimg_url) + ## ffnet uses different sizes on auth & story pages, but same id. + ## //ffcdn2012t-fictionpressllc.netdna-ssl.com/image/1936929/150/ + ## //ffcdn2012t-fictionpressllc.netdna-ssl.com/image/1936929/180/ + try: + cover_id = cover_url.split('/')[4] + except: + cover_id = None + try: + authimg_id = authimg_url.split('/')[4] + except: + authimg_id = None + + ## don't use cover if it matches the auth image. + if cover_id and authimg_id and cover_id == authimg_id: + cover_url = None + + if cover_url: + self.setCoverImage(url,cover_url) + + # Find the chapter selector select = soup.find('select', { 'name' : 'chapter' } ) diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index 85fac94..2716839 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -107,6 +107,7 @@ def get_valid_set_options(): 'check_next_chapter':(['fanfiction.net'],None,boollist), 'tweak_fg_sleep':(['fanfiction.net'],None,boollist), + 'skip_author_cover':(['fanfiction.net'],None,boollist), 'fix_fimf_blockquotes':(['fimfiction.net'],None,boollist), 'fail_on_password':(['fimfiction.net'],None,boollist), @@ -122,7 +123,10 @@ def get_valid_set_options(): 'fhsarchive.com', 'lotrfanfiction.com', 'themaplebookshelf.com', - 'devianthearts.com'],None,boollist), + 'devianthearts.com', + 'thehookupzone.net', + 'libraryofmoria.com', + ],None,boollist), 'include_logpage':(None,['epub'],boollist+['smart']), @@ -180,6 +184,7 @@ def get_valid_keywords(): 'chapter_title_add_pattern', 'chapter_title_strip_pattern', 'check_next_chapter', + 'skip_author_cover', 'collect_series', 'connect_timeout', 'convert_images_to', diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index 22378e7..1c82934 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -1511,9 +1511,15 @@ user_agent: ## Set this to true to never use them. #never_make_cover: false -## fanfiction.net shows the user's +## exclude fanfiction.net imageu (old user vs story detect) and +## default user (d_60_90) cover_exclusion_regexp:(/imageu/|d_60_90\.jpg) +## April 2015, ffnet changed their story and user pictures urls to be +## the same. Now the only way to know if the story image is really +## the author image is to go get the author image and check. +skip_author_cover:true + ## fanfiction.net is blocking people more aggressively. If you ## download fewer stories less often you can likely get by with ## reducing this sleep.