[weibo] add 'gifs' option (#5183)
This commit is contained in:
@@ -3868,6 +3868,19 @@ Description
|
||||
Note: This requires 1 additional HTTP request per submission.
|
||||
|
||||
|
||||
extractor.weibo.gifs
|
||||
--------------------
|
||||
Type
|
||||
* ``bool``
|
||||
* ``string``
|
||||
Default
|
||||
``true``
|
||||
Description
|
||||
Download ``gif`` files.
|
||||
|
||||
Set this to ``"video"`` to download GIFs as video files.
|
||||
|
||||
|
||||
extractor.weibo.include
|
||||
-----------------------
|
||||
Type
|
||||
|
||||
@@ -33,6 +33,8 @@ class WeiboExtractor(Extractor):
|
||||
self.retweets = self.config("retweets", True)
|
||||
self.videos = self.config("videos", True)
|
||||
self.livephoto = self.config("livephoto", True)
|
||||
self.gifs = self.config("gifs", True)
|
||||
self.gifs_video = (self.gifs == "video")
|
||||
|
||||
cookies = _cookie_cache()
|
||||
if cookies is not None:
|
||||
@@ -106,8 +108,11 @@ class WeiboExtractor(Extractor):
|
||||
pic = pics[pic_id]
|
||||
pic_type = pic.get("type")
|
||||
|
||||
if pic_type == "gif" and self.videos:
|
||||
append({"url": pic["video"]})
|
||||
if pic_type == "gif" and self.gifs:
|
||||
if self.gifs_video:
|
||||
append({"url": pic["video"]})
|
||||
else:
|
||||
append(pic["largest"].copy())
|
||||
|
||||
elif pic_type == "livephoto" and self.livephoto:
|
||||
append(pic["largest"].copy())
|
||||
|
||||
@@ -218,6 +218,15 @@ __tests__ = (
|
||||
"#comment" : "type == gif",
|
||||
"#category": ("", "weibo", "status"),
|
||||
"#class" : weibo.WeiboStatusExtractor,
|
||||
"#urls" : "https://wx4.sinaimg.cn/large/68d80d22gy1h2ryfa8k0kg208w06o7wh.gif",
|
||||
},
|
||||
|
||||
{
|
||||
"#url" : "https://weibo.com/1758989602/LvBhm5DiP",
|
||||
"#comment" : "type == gif as video (#5183)",
|
||||
"#category": ("", "weibo", "status"),
|
||||
"#class" : weibo.WeiboStatusExtractor,
|
||||
"#options" : {"gifs": "video"},
|
||||
"#pattern" : r"https://g\.us\.sinaimg.cn/o0/qNZcaAAglx07Wuf921CM0104120005tc0E010\.mp4\?label=gif_mp4",
|
||||
},
|
||||
|
||||
|
||||
Reference in New Issue
Block a user