From 5e2974d69977459f172f5adb854c5cfbff8662c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Wed, 29 Apr 2020 23:27:29 +0200 Subject: [PATCH] [weibo] add 'videos' option --- docs/configuration.rst | 18 ++++++++++++++++++ docs/gallery-dl.conf | 5 +++++ gallery_dl/extractor/weibo.py | 4 +++- 3 files changed, 26 insertions(+), 1 deletion(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index 51be9d30..04a6d439 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -1232,6 +1232,24 @@ Description Your `API Key `__ to use =========== ===== +extractor.weibo.retweets +------------------------ +=========== ===== +Type ``bool`` +Default ``true`` +Description Extract media from retweeted posts. +=========== ===== + + +extractor.weibo.videos +---------------------- +=========== ===== +Type ``bool`` +Default ``true`` +Description Download video files. +=========== ===== + + extractor.[booru].tags ---------------------- =========== ===== diff --git a/docs/gallery-dl.conf b/docs/gallery-dl.conf index c6d8b03f..acfae8ac 100644 --- a/docs/gallery-dl.conf +++ b/docs/gallery-dl.conf @@ -167,6 +167,11 @@ { "api-key": null }, + "weibo": + { + "retweets": true, + "videos": true + }, "booru": { "tags": false diff --git a/gallery_dl/extractor/weibo.py b/gallery_dl/extractor/weibo.py index 9539c2f9..aa9bdaeb 100644 --- a/gallery_dl/extractor/weibo.py +++ b/gallery_dl/extractor/weibo.py @@ -23,6 +23,7 @@ class WeiboExtractor(Extractor): def __init__(self, match): Extractor.__init__(self, match) self.retweets = self.config("retweets", True) + self.videos = self.config("videos", True) def items(self): yield Message.Version, 1 @@ -52,7 +53,7 @@ class WeiboExtractor(Extractor): yield Message.Url, image["url"], data num += 1 - if "page_info" in obj and "media_info" in obj["page_info"]: + if self.videos and "media_info" in obj.get("page_info", ()): info = obj["page_info"]["media_info"] url = info.get("stream_url_hd") or info.get("stream_url") @@ -70,6 +71,7 @@ class WeiboExtractor(Extractor): data["extension"] = "mp4" data["_ytdl_extra"] = {"protocol": "m3u8_native"} yield Message.Url, url, data + num += 1 if self.retweets and "retweeted_status" in obj: obj = obj["retweeted_status"]