From 73f673e3caa4a825bcccaff04f11378d4e75defa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Fri, 3 Jun 2022 17:33:14 +0200 Subject: [PATCH] [weibo] handle 'gif' pictures --- gallery_dl/extractor/weibo.py | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/gallery_dl/extractor/weibo.py b/gallery_dl/extractor/weibo.py index e705b575..09825a44 100644 --- a/gallery_dl/extractor/weibo.py +++ b/gallery_dl/extractor/weibo.py @@ -81,14 +81,22 @@ class WeiboExtractor(Extractor): pics = status["pic_infos"] for pic_id in pic_ids: pic = pics[pic_id] - yield pic["largest"].copy() + pic_type = pic.get("type") + + if pic_type == "gif" and self.videos: + yield {"url": pic["video"]} + + elif pic_type == "livephoto" and self.livephoto: + yield pic["largest"].copy() - if pic.get("type") == "livephoto" and self.livephoto: file = {"url": pic["video"]} file["filehame"], _, file["extension"] = \ pic["video"].rpartition("%2F")[2].rpartition(".") yield file + else: + yield pic["largest"].copy() + if "page_info" in status: page_info = status["page_info"] if "media_info" not in page_info or not self.videos: @@ -318,12 +326,17 @@ class WeiboStatusExtractor(WeiboExtractor): "options": (("retweets", "original"),), "keyword": {"status": {"id": 4600167083287033}}, }), - # livephoto (#2146) + # type == livephoto (#2146) ("https://weibo.com/5643044717/KkuDZ4jAA", { "range": "2,4,6", "pattern": r"https://video\.weibo\.com/media/play\?livephoto=" r"https%3A%2F%2Fus.sinaimg.cn%2F\w+\.mov", }), + # type == gif + ("https://weibo.com/1758989602/LvBhm5DiP", { + "pattern": r"http://g\.us\.sinaimg.cn/o0/qNZcaAAglx07Wuf921CM01041" + r"20005tc0E010\.mp4\?label=gif_mp4", + }), ("https://m.weibo.cn/status/4339748116375525"), ("https://m.weibo.cn/5746766133/4339748116375525"), )