Add option to checking ffnet auth img vs cover img, fix new ini params.

master
Jim Miller 2015-04-12 23:17:07 -05:00
parent 853295bcf9
commit 3ecfdd568e
5 changed files with 58 additions and 5 deletions

1
.gitignore vendored
View File

@ -25,3 +25,4 @@ output
build
dist
FanFicFare.egg-info
personal.ini

View File

@ -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.

View File

@ -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' } )

View File

@ -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',

View File

@ -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.