From 008a871ccb86fc7859265fd84a02ce48b240f504 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 3 Oct 2025 11:02:01 +0200 Subject: [PATCH] [weibo] download 'm3u8' manifests with ytdl (#8339) --- gallery_dl/extractor/weibo.py | 13 +++++++++---- test/results/weibo.py | 18 +++++++++++++++++- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/gallery_dl/extractor/weibo.py b/gallery_dl/extractor/weibo.py index 823e8e03..7bf52423 100644 --- a/gallery_dl/extractor/weibo.py +++ b/gallery_dl/extractor/weibo.py @@ -87,15 +87,20 @@ class WeiboExtractor(Extractor): yield Message.Directory, status for num, file in enumerate(files, 1): - if file["url"].startswith("http:"): - file["url"] = "https:" + file["url"][5:] + url = file["url"] + if url.startswith("http:"): + url = f"https:{url[5:]}" if "filename" not in file: - text.nameext_from_url(file["url"], file) + text.nameext_from_url(url, file) if file["extension"] == "json": file["extension"] = "mp4" + if file["extension"] == "m3u8": + url = f"ytdl:{url}" + file["_ytdl_manifest"] = "hls" + file["extension"] = "mp4" file["status"] = status file["num"] = num - yield Message.Url, file["url"], file + yield Message.Url, url, file def _extract_status(self, status, files): if "mix_media_info" in status: diff --git a/test/results/weibo.py b/test/results/weibo.py index c31b3fc7..29303c00 100644 --- a/test/results/weibo.py +++ b/test/results/weibo.py @@ -262,7 +262,7 @@ __tests__ = ( "#comment" : "missing 'playback_list' (#2792)", "#category": ("", "weibo", "status"), "#class" : weibo.WeiboStatusExtractor, - "#count" : 10, + "#count" : 9, }, { @@ -308,4 +308,20 @@ __tests__ = ( "#class" : weibo.WeiboStatusExtractor, }, +{ + "#url" : "https://weibo.com/7117031969/5208376084532264", + "#comment" : "'.m3u8' manifest (live replay #8339)", + "#class" : weibo.WeiboStatusExtractor, + "#pattern" : r"ytdl:https://live.video.weibocdn.com/0f9e059c-3438-49ab-a84c-671a04d37b92_index.m3u8\?media_id=5208391172685924&.+&KID=unistore,video", + "#count" : 1, +}, + +{ + "#url" : "https://weibo.com/2683260651/3774796733364550", + "#comment" : "'.m3u8' manifest (from 2014)", + "#class" : weibo.WeiboStatusExtractor, + "#pattern" : r"ytdl:https://us.sinaimg.cn/001xN98Njx06NszB2n15010d0100008H0k01.m3u8\?ori=0&.+&KID=unistore,video", + "#count" : 1, +}, + )