[vsco] support '/video/' URLs (#4295 #6973)

requires yt-dlp/youtube-dl to handle m3u8 manifests
This commit is contained in:
Mike Fährmann
2025-02-12 18:49:02 +01:00
parent d1a8142dcf
commit f1f27eb2ab
3 changed files with 53 additions and 7 deletions

View File

@@ -38,7 +38,9 @@ class VscoExtractor(Extractor):
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("/")
@@ -63,6 +65,9 @@ class VscoExtractor(Extractor):
"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):
@@ -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"],
},)