mirror of
https://github.com/wukko/cobalt.git
synced 2025-06-13 13:47:38 +02:00
api/tiktok: catch unavailable post error
This commit is contained in:
@ -44,9 +44,19 @@ export default async function(obj) {
|
|||||||
try {
|
try {
|
||||||
const json = html
|
const json = html
|
||||||
.split('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">')[1]
|
.split('<script id="__UNIVERSAL_DATA_FOR_REHYDRATION__" type="application/json">')[1]
|
||||||
.split('</script>')[0]
|
.split('</script>')[0];
|
||||||
const data = JSON.parse(json)
|
|
||||||
detail = data["__DEFAULT_SCOPE__"]["webapp.video-detail"]["itemInfo"]["itemStruct"]
|
const data = JSON.parse(json);
|
||||||
|
const videoDetail = data["__DEFAULT_SCOPE__"]["webapp.video-detail"];
|
||||||
|
|
||||||
|
if (!videoDetail) throw "no video detail found";
|
||||||
|
|
||||||
|
// status_deleted or etc
|
||||||
|
if (videoDetail.statusMsg) {
|
||||||
|
return { error: "content.post.unavailable"};
|
||||||
|
}
|
||||||
|
|
||||||
|
detail = videoDetail?.itemInfo?.itemStruct;
|
||||||
} catch {
|
} catch {
|
||||||
return { error: "fetch.fail" };
|
return { error: "fetch.fail" };
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user