From 6db77d46565848a8c88c7bec5c7f3640708aa4e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 12 Jun 2022 17:55:23 +0200 Subject: [PATCH] [weibo] support '?tabtype=video' listings (#2601) --- docs/configuration.rst | 2 +- gallery_dl/extractor/weibo.py | 38 +++++++++++++++++++++++++++-------- scripts/supportedsites.py | 1 + 3 files changed, 32 insertions(+), 9 deletions(-) diff --git a/docs/configuration.rst b/docs/configuration.rst index ead9323329..e420771abe 100644 --- a/docs/configuration.rst +++ b/docs/configuration.rst @@ -2489,7 +2489,7 @@ Description when processing a user profile. Possible values are - ``"home"``, ``"feed"``, ``"videos"``, ``"article"``, ``"album"``. + ``"home"``, ``"feed"``, ``"videos"``, ``"newvideo"``, ``"article"``, ``"album"``. It is possible to use ``"all"`` instead of listing all values separately. diff --git a/gallery_dl/extractor/weibo.py b/gallery_dl/extractor/weibo.py index 081209016a..68871c8bf5 100644 --- a/gallery_dl/extractor/weibo.py +++ b/gallery_dl/extractor/weibo.py @@ -191,7 +191,9 @@ class WeiboUserExtractor(WeiboExtractor): subcategory = "user" pattern = USER_PATTERN + r"(?:$|#)" test = ( - ("https://weibo.com/1758989602"), + ("https://weibo.com/1758989602", { + "pattern": r"^https://weibo\.com/u/1758989602\?tabtype=feed$", + }), ("https://weibo.com/u/1758989602"), ("https://weibo.com/p/1758989602"), ("https://m.weibo.cn/profile/2314621010"), @@ -202,10 +204,11 @@ class WeiboUserExtractor(WeiboExtractor): def items(self): base = "{}/u/{}?tabtype=".format(self.root, self._user_id()) return self._dispatch_extractors(( - (WeiboHomeExtractor , base + "home"), - (WeiboFeedExtractor , base + "feed"), - (WeiboVideosExtractor, base + "newVideo"), - (WeiboAlbumExtractor , base + "album"), + (WeiboHomeExtractor , base + "home"), + (WeiboFeedExtractor , base + "feed"), + (WeiboVideosExtractor , base + "video"), + (WeiboNewvideoExtractor, base + "newVideo"), + (WeiboAlbumExtractor , base + "album"), ), ("feed",)) @@ -254,8 +257,27 @@ def statuses(self): class WeiboVideosExtractor(WeiboExtractor): - """Extractor for weibo 'newVideo' listings""" + """Extractor for weibo 'video' listings""" subcategory = "videos" + pattern = USER_PATTERN + r"\?tabtype=video" + test = ("https://weibo.com/1758989602?tabtype=video", { + "pattern": r"https://f\.(video\.weibocdn\.com|us\.sinaimg\.cn)" + r"/(../)?\w+\.mp4\?label=mp", + "range": "1-30", + "count": 30, + }) + + def statuses(self): + endpoint = "/profile/getprofilevideolist" + params = {"uid": self._user_id()} + + for status in self._pagination(endpoint, params): + yield status["video_detail_vo"] + + +class WeiboNewvideoExtractor(WeiboExtractor): + """Extractor for weibo 'newVideo' listings""" + subcategory = "newvideo" pattern = USER_PATTERN + r"\?tabtype=newVideo" test = ("https://weibo.com/1758989602?tabtype=newVideo", { "pattern": r"https://f\.video\.weibocdn\.com/(../)?\w+\.mp4\?label=mp", @@ -336,8 +358,8 @@ class WeiboStatusExtractor(WeiboExtractor): }), # type == gif ("https://weibo.com/1758989602/LvBhm5DiP", { - "pattern": r"http://g\.us\.sinaimg.cn/o0/qNZcaAAglx07Wuf921CM01041" - r"20005tc0E010\.mp4\?label=gif_mp4", + "pattern": r"https://g\.us\.sinaimg.cn/o0/qNZcaAAglx07Wuf921CM0104" + r"120005tc0E010\.mp4\?label=gif_mp4", }), ("https://m.weibo.cn/status/4339748116375525"), ("https://m.weibo.cn/5746766133/4339748116375525"), diff --git a/scripts/supportedsites.py b/scripts/supportedsites.py index 04f96a2b57..76ffc92c9a 100755 --- a/scripts/supportedsites.py +++ b/scripts/supportedsites.py @@ -230,6 +230,7 @@ }, "weibo": { "home": "", + "newvideo": "", }, "wikiart": { "artists": "Artist Listings",