diff --git a/docs/configuration.rst b/docs/configuration.rst index b9070f3a..df049c8b 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -4039,7 +4039,7 @@ extractor.weibo.retweets Type ``bool`` Default - ``true`` + ``false`` Description Fetch media from retweeted posts. diff --git a/gallery_dl/extractor/weibo.py b/gallery_dl/extractor/weibo.py index ab90c0ba..1049ba7b 100644 --- a/gallery_dl/extractor/weibo.py +++ b/gallery_dl/extractor/weibo.py @@ -30,9 +30,9 @@ class WeiboExtractor(Extractor): self._prefix, self.user = match.groups() def _init(self): - self.retweets = self.config("retweets", True) - self.videos = self.config("videos", True) self.livephoto = self.config("livephoto", True) + self.retweets = self.config("retweets", False) + self.videos = self.config("videos", True) self.gifs = self.config("gifs", True) self.gifs_video = (self.gifs == "video") @@ -59,15 +59,25 @@ class WeiboExtractor(Extractor): for status in self.statuses(): - files = [] - if self.retweets and "retweeted_status" in status: + if "ori_mid" in status and not self.retweets: + self.log.debug("Skipping %s (快转 retweet)", status["id"]) + continue + + if "retweeted_status" in status: + if not self.retweets: + self.log.debug("Skipping %s (retweet)", status["id"]) + continue + + # videos of the original post are in status + # images of the original post are in status["retweeted_status"] + files = [] + self._extract_status(status, files) + self._extract_status(status["retweeted_status"], files) + if original_retweets: status = status["retweeted_status"] - self._extract_status(status, files) - else: - self._extract_status(status, files) - self._extract_status(status["retweeted_status"], files) else: + files = [] self._extract_status(status, files) status["date"] = text.parse_datetime( diff --git a/test/results/weibo.py b/test/results/weibo.py index 992d2c93..8f46da3f 100644 --- a/test/results/weibo.py +++ b/test/results/weibo.py @@ -80,11 +80,11 @@ __tests__ = ( "#category": ("", "weibo", "home"), "#class" : weibo.WeiboHomeExtractor, "#range" : "1-30", - "#count" : 30, + "#count" : 0, }, { - "#url" : "https://weibo.com/1758989602?tabtype=feed", + "#url" : "https://weibo.com/2553930725?tabtype=feed", "#category": ("", "weibo", "feed"), "#class" : weibo.WeiboFeedExtractor, "#range" : "1-30", @@ -194,6 +194,28 @@ __tests__ = ( "#class" : weibo.WeiboStatusExtractor, }, +{ + "#url" : "https://weibo.cn/detail/4600272267522211", + "#comment" : "retweet", + "#category": ("", "weibo", "status"), + "#class" : weibo.WeiboStatusExtractor, + "#count" : 0, +}, + +{ + "#url" : "https://weibo.cn/detail/4600272267522211", + "#comment" : "retweet", + "#category": ("", "weibo", "status"), + "#class" : weibo.WeiboStatusExtractor, + "#options" : {"retweets": True}, + "#count" : 2, + + "status": { + "id" : 4600272267522211, + "retweeted_status": {"id": 4600167083287033}, + }, +}, + { "#url" : "https://m.weibo.cn/detail/4600272267522211", "#comment" : "original retweets (#1542)",