[weibo] extend 'retweets' option (closes #1542)

Setting 'retweets' to "original" will use metadata from the
original posts, and not from the retweeted ones.
pull/1633/head
Mike Fährmann 3 years ago
parent c0fa5058da
commit c80b18a477
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -1844,7 +1844,10 @@ Type
Default
``true``
Description
Extract media from retweeted posts.
Fetch media from retweeted posts.
If this value is ``"original"``, metadata for these files
will be taken from the original posts, not the retweeted posts.
extractor.weibo.videos

@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
# Copyright 2019-2020 Mike Fährmann
# Copyright 2019-2021 Mike Fährmann
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
@ -27,16 +27,21 @@ class WeiboExtractor(Extractor):
self.videos = self.config("videos", True)
def items(self):
yield Message.Version, 1
original_retweets = (self.retweets == "original")
for status in self.statuses():
files = self._files_from_status(status)
if self.retweets and "retweeted_status" in status:
files = itertools.chain(
files,
self._files_from_status(status["retweeted_status"]),
)
if original_retweets:
status = status["retweeted_status"]
files = self._files_from_status(status)
else:
files = itertools.chain(
self._files_from_status(status),
self._files_from_status(status["retweeted_status"]),
)
else:
files = self._files_from_status(status)
for num, file in enumerate(files, 1):
if num == 1:
@ -143,6 +148,11 @@ class WeiboStatusExtractor(WeiboExtractor):
}),
# non-numeric status ID (#664)
("https://weibo.com/3314883543/Iy7fj4qVg"),
# original retweets (#1542)
("https://m.weibo.cn/detail/4600272267522211", {
"options": (("retweets", "original"),),
"keyword": {"status": {"id": "4600167083287033"}},
}),
("https://m.weibo.cn/status/4339748116375525"),
("https://m.weibo.cn/5746766133/4339748116375525"),
)

Loading…
Cancel
Save