[patreon] add explicit 'image_large' file type (#2257)
to allow more control over when and if to download 'large_url' images
4fee3a0e52 forced them to be downloaded
instead of regular images, even though 'large_url' images are most likely
an upscaled version of the original.
This commit is contained in:
@@ -1661,12 +1661,12 @@ extractor.patreon.files
|
|||||||
Type
|
Type
|
||||||
``list`` of ``strings``
|
``list`` of ``strings``
|
||||||
Default
|
Default
|
||||||
``["images", "attachments", "postfile", "content"]``
|
``["images", "image_large", "attachments", "postfile", "content"]``
|
||||||
Description
|
Description
|
||||||
Determines the type and order of files to be downloaded.
|
Determines the type and order of files to be downloaded.
|
||||||
|
|
||||||
Available types are
|
Available types are
|
||||||
``postfile``, ``images``, ``attachments``, and ``content``.
|
``postfile``, ``images``, ``image_large``, ``attachments``, and ``content``.
|
||||||
|
|
||||||
|
|
||||||
extractor.photobucket.subalbums
|
extractor.photobucket.subalbums
|
||||||
|
|||||||
@@ -65,18 +65,21 @@ class PatreonExtractor(Extractor):
|
|||||||
return ()
|
return ()
|
||||||
|
|
||||||
def _images(self, post):
|
def _images(self, post):
|
||||||
image = post.get("image")
|
|
||||||
if image:
|
|
||||||
url = image.get("large_url") or image["url"]
|
|
||||||
name = image.get("file_name") or self._filename(url) or url
|
|
||||||
yield "image", url, name
|
|
||||||
|
|
||||||
for image in post["images"]:
|
for image in post["images"]:
|
||||||
url = image.get("download_url")
|
url = image.get("download_url")
|
||||||
if url:
|
if url:
|
||||||
name = image.get("file_name") or self._filename(url) or url
|
name = image.get("file_name") or self._filename(url) or url
|
||||||
yield "image", url, name
|
yield "image", url, name
|
||||||
|
|
||||||
|
def _image_large(self, post):
|
||||||
|
image = post.get("image")
|
||||||
|
if image:
|
||||||
|
url = image.get("large_url")
|
||||||
|
if url:
|
||||||
|
name = image.get("file_name") or self._filename(url) or url
|
||||||
|
return (("image_large", url, name),)
|
||||||
|
return ()
|
||||||
|
|
||||||
def _attachments(self, post):
|
def _attachments(self, post):
|
||||||
for attachment in post["attachments"]:
|
for attachment in post["attachments"]:
|
||||||
url = self.request(
|
url = self.request(
|
||||||
@@ -218,10 +221,11 @@ class PatreonExtractor(Extractor):
|
|||||||
|
|
||||||
def _build_file_generators(self, filetypes):
|
def _build_file_generators(self, filetypes):
|
||||||
if filetypes is None:
|
if filetypes is None:
|
||||||
return (self._images, self._attachments,
|
return (self._images, self._image_large,
|
||||||
self._postfile, self._content)
|
self._attachments, self._postfile, self._content)
|
||||||
genmap = {
|
genmap = {
|
||||||
"images" : self._images,
|
"images" : self._images,
|
||||||
|
"image_large": self._image_large,
|
||||||
"attachments": self._attachments,
|
"attachments": self._attachments,
|
||||||
"postfile" : self._postfile,
|
"postfile" : self._postfile,
|
||||||
"content" : self._content,
|
"content" : self._content,
|
||||||
|
|||||||
Reference in New Issue
Block a user