Skip to content

Commit

Permalink
[vsco] support '/video/' URLs (#4295 #6973)
Browse files Browse the repository at this point in the history
requires yt-dlp/youtube-dl to handle m3u8 manifests
  • Loading branch information
mikf committed Feb 12, 2025
1 parent d1a8142 commit f1f27eb
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 7 deletions.
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -1018,7 +1018,7 @@ Consider all listed sites to potentially be NSFW.
<tr>
<td>VSCO</td>
<td>https://vsco.co/</td>
<td>Avatars, Collections, Galleries, individual Images, Spaces, User Profiles</td>
<td>Avatars, Collections, Galleries, individual Images, Spaces, User Profiles, Videos</td>
<td></td>
</tr>
<tr>
Expand Down
38 changes: 32 additions & 6 deletions gallery_dl/extractor/vsco.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ def items(self):
if img["is_video"]:
if not videos:
continue
url = "https://" + img["video_url"]
url = img["video_url"]
if not url.startswith("ytdl:"):
url = "https://" + url
else:
base = img["responsive_url"].partition("/")[2]
cdn, _, path = base.partition("/")
Expand All @@ -63,6 +65,9 @@ def items(self):
"height": img["height"],
"description": img.get("description") or "",
})
if data["extension"] == "m3u8":
data["_ytdl_manifest"] = "hls"
data["extension"] = "mp4"
yield Message.Url, url, data

def images(self):
Expand Down Expand Up @@ -294,12 +299,33 @@ class VscoImageExtractor(VscoExtractor):
pattern = USER_PATTERN + r"/media/([0-9a-fA-F]+)"
example = "https://vsco.co/USER/media/0123456789abcdef"

def __init__(self, match):
VscoExtractor.__init__(self, match)
self.media_id = match.group(2)

def images(self):
url = "{}/{}/media/{}".format(self.root, self.user, self.media_id)
url = "{}/{}/media/{}".format(self.root, self.user, self.groups[1])
data = self._extract_preload_state(url)
media = data["medias"]["byId"].popitem()[1]["media"]
return (self._transform_media(media),)


class VscoVideoExtractor(VscoExtractor):
"""Extractor for vsco.co videos links"""
subcategory = "video"
pattern = USER_PATTERN + r"/video/([^/?#]+)"
example = "https://vsco.co/USER/video/012345678-9abc-def0"

def images(self):
url = "{}/{}/video/{}".format(self.root, self.user, self.groups[1])
data = self._extract_preload_state(url)
media = data["medias"]["byId"].popitem()[1]["media"]

return ({
"_id" : media["id"],
"is_video" : True,
"grid_name" : "",
"upload_date" : media["createdDate"],
"responsive_url": media["posterUrl"],
"video_url" : "ytdl:" + media.get("playbackUrl"),
"image_meta" : None,
"width" : media["width"],
"height" : media["height"],
"description" : media["description"],
},)
20 changes: 20 additions & 0 deletions test/results/vsco.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,4 +108,24 @@
"video": True,
},

{
"#url" : "https://vsco.co/shavonec/video/c5eb34bb-dd13-4d7a-a09c-2a7cd719c9fa",
"#category": ("", "vsco", "video"),
"#class" : vsco.VscoVideoExtractor,
"#pattern" : r"ytdl:https://stream\.mux\.com/3o01XbjqTI4rkeRwPzR17H9i7VSFdWX1h\.m3u8\?token=ey.+",

"date" : "dt:2020-02-04 15:11:52",
"description": "Big news: 🎥 YOU CAN NOW POST VIDEOS TO VSCO ⚡️⚡️💪🏾. ⁣\n\n🔗BTS from my #FashionIsActivism panel with the California African American Arts museum ✊🏾",
"extension" : "mp4",
"filename" : "3o01XbjqTI4rkeRwPzR17H9i7VSFdWX1h",
"grid" : "",
"id" : "c5eb34bb-dd13-4d7a-a09c-2a7cd719c9fa",
"meta" : {},
"tags" : [],
"user" : "shavonec",
"video" : True,
"width" : 624,
"height" : 1232,
},

)

0 comments on commit f1f27eb

Please sign in to comment.