1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 10:42:34 +01:00

[vsco] add 'avatar' extractor (#5341)

This commit is contained in:
Mike Fährmann 2024-05-02 18:12:19 +02:00
parent d0cead105b
commit bd8e4797e5
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
3 changed files with 41 additions and 1 deletions

View File

@ -940,7 +940,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>VSCO</td>
<td>https://vsco.co/</td>
<td>Collections, individual Images, Spaces, User Profiles</td>
<td>Avatars, Collections, individual Images, Spaces, User Profiles</td>
<td></td>
</tr>
<tr>

View File

@ -46,6 +46,8 @@ class VscoExtractor(Extractor):
url = "https://image-{}.vsco.co/{}".format(cdn, path)
elif cdn.isdecimal():
url = "https://image.vsco.co/" + base
elif img["responsive_url"].startswith("http"):
url = img["responsive_url"]
else:
url = "https://" + img["responsive_url"]
@ -238,6 +240,34 @@ class VscoSpacesExtractor(VscoExtractor):
yield Message.Queue, url, space
class VscoAvatarExtractor(VscoExtractor):
"""Extractor for vsco.co user avatars"""
subcategory = "avatar"
pattern = USER_PATTERN + r"/avatar"
example = "https://vsco.co/USER/avatar"
def images(self):
url = "{}/{}/gallery".format(self.root, self.user)
page = self.request(url).text
piid = text.extr(page, '"profileImageId":"', '"')
url = "https://im.vsco.co/" + piid
# needs GET request, since HEAD does not redirect to full URL
response = self.request(url, allow_redirects=False)
return ({
"_id" : piid,
"is_video" : False,
"grid_name" : "",
"upload_date" : 0,
"responsive_url": response.headers["Location"],
"video_url" : "",
"image_meta" : None,
"width" : 0,
"height" : 0,
},)
class VscoImageExtractor(VscoExtractor):
"""Extractor for individual images on vsco.co"""
subcategory = "image"

View File

@ -55,6 +55,16 @@ __tests__ = (
),
},
{
"#url" : "https://vsco.co/vsco/avatar",
"#category": ("", "vsco", "avatar"),
"#class" : vsco.VscoAvatarExtractor,
"#urls" : "https://image-aws-us-west-2.vsco.co/3c69ae/304128/652d9f3b39a6007526dda683/vscoprofile-avatar.jpg",
"#sha1_content" : "57cd648759e34a6daefc5c79542ddb4595b9b677",
"id": "652d9f3b39a6007526dda683",
},
{
"#url" : "https://vsco.co/erenyildiz/media/5d34b93ef632433030707ce2",
"#category": ("", "vsco", "image"),