diff --git a/docs/supportedsites.md b/docs/supportedsites.md index a90ce159..034c8c6e 100644 --- a/docs/supportedsites.md +++ b/docs/supportedsites.md @@ -940,7 +940,7 @@ Consider all listed sites to potentially be NSFW. VSCO https://vsco.co/ - Collections, individual Images, Spaces, User Profiles + Avatars, Collections, individual Images, Spaces, User Profiles diff --git a/gallery_dl/extractor/vsco.py b/gallery_dl/extractor/vsco.py index 41141c6f..c112f4ae 100644 --- a/gallery_dl/extractor/vsco.py +++ b/gallery_dl/extractor/vsco.py @@ -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" diff --git a/test/results/vsco.py b/test/results/vsco.py index 6fa9eb69..0553b4c3 100644 --- a/test/results/vsco.py +++ b/test/results/vsco.py @@ -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"),