1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 18:53:21 +01:00

[weibo] prevent exception for missing 'playback_list' (#2792)

This commit is contained in:
Mike Fährmann 2022-07-30 16:49:08 +02:00
parent 7d1a95ada6
commit 0f5826e884
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

View File

@ -99,13 +99,14 @@ class WeiboExtractor(Extractor):
else:
yield pic["largest"].copy()
if "page_info" in status:
page_info = status["page_info"]
if "media_info" not in page_info or not self.videos:
return
media = max(page_info["media_info"]["playback_list"],
key=lambda m: m["meta"]["quality_index"])
yield media["play_info"].copy()
if "page_info" in status and self.videos:
try:
media = max(status["page_info"]["media_info"]["playback_list"],
key=lambda m: m["meta"]["quality_index"])
except KeyError:
pass
else:
yield media["play_info"].copy()
def _status_by_id(self, status_id):
url = "{}/ajax/statuses/show?id={}".format(self.root, status_id)
@ -366,6 +367,10 @@ class WeiboStatusExtractor(WeiboExtractor):
"pattern": r"https://g\.us\.sinaimg.cn/o0/qNZcaAAglx07Wuf921CM0104"
r"120005tc0E010\.mp4\?label=gif_mp4",
}),
# missing 'playback_list' (#2792)
("https://weibo.com/2909128931/4409545658754086", {
"count": 9,
}),
("https://m.weibo.cn/status/4339748116375525"),
("https://m.weibo.cn/5746766133/4339748116375525"),
)