Skip to content

Commit

Permalink
Change force_img_referer to force_img_self_referer_regexp See #940 #941
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmXinu committed Apr 27, 2023
1 parent 98f95a7 commit f6dafec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 12 deletions.
10 changes: 5 additions & 5 deletions calibre-plugin/plugin-defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1265,11 +1265,11 @@ remove_transparency: true
## kept.)
#dedup_img_files:false

## If set true, FFF will use the img tag's own src URL as the HTTP
## Referer instead of the page URL. This is useful for some image
## hosting sites that watermark or return HTML instead of image data
## without it.
#force_img_self_referer:false
## If set, and the img tag's URL matches the regular expression, FFF
## will use the img tag's own src URL as the HTTP Referer instead of
## the page URL. This is useful for some image hosting sites that
## watermark or return HTML instead of image data without it.
#force_img_self_referer_regexp:gelbooru.com|photobucket.com

## if the <img> tag doesn't have a div or a p around it, nook gets
## confused and displays it on every page after that under the text
Expand Down
2 changes: 1 addition & 1 deletion fanficfare/configurable.py
Original file line number Diff line number Diff line change
Expand Up @@ -375,7 +375,7 @@ def get_valid_keywords():
'dateUpdated_format',
'default_cover_image',
'force_cover_image',
'force_img_referer',
'force_img_self_referer_regexp',
'description_limit',
'do_update_hook',
'use_archived_author',
Expand Down
10 changes: 5 additions & 5 deletions fanficfare/defaults.ini
Original file line number Diff line number Diff line change
Expand Up @@ -1264,11 +1264,11 @@ remove_transparency: true
## kept.)
#dedup_img_files:false

## If set true, FFF will use the img tag's own src URL as the HTTP
## Referer instead of the page URL. This is useful for some image
## hosting sites that watermark or return HTML instead of image data
## without it.
#force_img_self_referer:false
## If set, and the img tag's URL matches the regular expression, FFF
## will use the img tag's own src URL as the HTTP Referer instead of
## the page URL. This is useful for some image hosting sites that
## watermark or return HTML instead of image data without it.
#force_img_self_referer_regexp:gelbooru.com|photobucket.com

## if the <img> tag doesn't have a div or a p around it, nook gets
## confused and displays it on every page after that under the text
Expand Down
4 changes: 3 additions & 1 deletion fanficfare/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1548,7 +1548,9 @@ def addImgUrl(self,parenturl,url,fetch,cover=False,coverexclusion=None):
# and authors who link images that watermark or
# don't work anymore.
refererurl = parenturl
if self.getConfig("force_img_self_referer"):
if( self.getConfig("force_img_self_referer_regexp") and
re.search(self.getConfig("force_img_self_referer_regexp"),
url) ):
refererurl = url
logger.debug("Use Referer:%s"%refererurl)
imgdata = fetch(imgurl,referer=refererurl)
Expand Down

0 comments on commit f6dafec

Please sign in to comment.