Allow using image_url_processor to skip img downloads

This commit is contained in:
Kovid Goyal 2022-08-02 19:17:29 +05:30
parent c60d61a777
commit b3828dcec7
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 4 additions and 1 deletions

View File

@ -491,7 +491,8 @@ class BasicNewsRecipe(Recipe):
def image_url_processor(cls, baseurl, url):
'''
Perform some processing on image urls (perhaps removing size restrictions for
dynamically generated images, etc.) and return the precessed URL.
dynamically generated images, etc.) and return the precessed URL. Return None
or an empty string to skip fetching the image.
'''
return url

View File

@ -407,6 +407,8 @@ class RecursiveFetcher:
else:
if callable(self.image_url_processor):
iurl = self.image_url_processor(baseurl, iurl)
if not iurl:
continue
if not urlsplit(iurl).scheme:
iurl = urljoin(baseurl, iurl, False)
found_in_cache = False