[weibo] raise NotFoundError for unavailable/deleted statuses
This commit is contained in:
@@ -9,7 +9,7 @@
|
|||||||
"""Extractors for https://www.weibo.com/"""
|
"""Extractors for https://www.weibo.com/"""
|
||||||
|
|
||||||
from .common import Extractor, Message
|
from .common import Extractor, Message
|
||||||
from .. import text
|
from .. import text, exception
|
||||||
import json
|
import json
|
||||||
|
|
||||||
|
|
||||||
@@ -124,7 +124,7 @@ class WeiboStatusExtractor(WeiboExtractor):
|
|||||||
}),
|
}),
|
||||||
# unavailable video (#427)
|
# unavailable video (#427)
|
||||||
("https://m.weibo.cn/status/4268682979207023", {
|
("https://m.weibo.cn/status/4268682979207023", {
|
||||||
"count": 0,
|
"exception": exception.NotFoundError,
|
||||||
}),
|
}),
|
||||||
("https://m.weibo.cn/status/4339748116375525"),
|
("https://m.weibo.cn/status/4339748116375525"),
|
||||||
("https://m.weibo.cn/5746766133/4339748116375525"),
|
("https://m.weibo.cn/5746766133/4339748116375525"),
|
||||||
@@ -136,7 +136,8 @@ class WeiboStatusExtractor(WeiboExtractor):
|
|||||||
|
|
||||||
def statuses(self):
|
def statuses(self):
|
||||||
url = "{}/detail/{}".format(self.root, self.status_id)
|
url = "{}/detail/{}".format(self.root, self.status_id)
|
||||||
page = self.request(url).text
|
page = self.request(url, notfound="status").text
|
||||||
data = json.loads(text.extract(
|
data = text.extract(page, "var $render_data = [", "][0] || {};")[0]
|
||||||
page, " var $render_data = [", "][0] || {};")[0])
|
if not data:
|
||||||
return (data["status"],)
|
raise exception.NotFoundError("status")
|
||||||
|
return (json.loads(data)["status"],)
|
||||||
|
|||||||
Reference in New Issue
Block a user