[bbc] provide fallback URLs (#1706)
This commit is contained in:
@@ -54,10 +54,18 @@ class BbcGalleryExtractor(GalleryExtractor):
|
||||
dimensions = "/{}xn/".format(width)
|
||||
|
||||
return [
|
||||
(src.replace("/320x180_b/", dimensions), None)
|
||||
(src.replace("/320x180_b/", dimensions),
|
||||
{"_fallback": self._fallback_urls(src, width)})
|
||||
for src in text.extract_iter(page, 'data-image-src="', '"')
|
||||
]
|
||||
|
||||
@staticmethod
|
||||
def _fallback_urls(src, max_width):
|
||||
front, _, back = src.partition("/320x180_b/")
|
||||
for width in (1920, 1600, 1280, 976):
|
||||
if width < max_width:
|
||||
yield "{}/{}xn/{}".format(front, width, back)
|
||||
|
||||
|
||||
class BbcProgrammeExtractor(Extractor):
|
||||
"""Extractor for all galleries of a bbc programme"""
|
||||
|
||||
Reference in New Issue
Block a user