api/tikok: catch an age restriction error

This commit is contained in:
wukko 2024-11-24 19:26:44 +06:00
parent 1559ed13af
commit a1fa79f2f5
No known key found for this signature in database
GPG key ID: 3E30B3F26C7B4AA2

View file

@ -51,13 +51,22 @@ export default async function(obj) {
return { error: "fetch.fail" }; return { error: "fetch.fail" };
} }
if (detail.isContentClassified) {
return { error: "content.post.age" };
}
if (!detail.author) {
return { error: "fetch.empty" };
}
let video, videoFilename, audioFilename, audio, images, let video, videoFilename, audioFilename, audio, images,
filenameBase = `tiktok_${detail.author.uniqueId}_${postId}`, filenameBase = `tiktok_${detail.author?.uniqueId}_${postId}`,
bestAudio; // will get defaulted to m4a later on in match-action bestAudio; // will get defaulted to m4a later on in match-action
images = detail.imagePost?.images; images = detail.imagePost?.images;
let playAddr = detail.video.playAddr; let playAddr = detail.video?.playAddr;
if (obj.h265) { if (obj.h265) {
const h265PlayAddr = detail?.video?.bitrateInfo?.find(b => b.CodecType.includes("h265"))?.PlayAddr.UrlList[0] const h265PlayAddr = detail?.video?.bitrateInfo?.find(b => b.CodecType.includes("h265"))?.PlayAddr.UrlList[0]
playAddr = h265PlayAddr || playAddr playAddr = h265PlayAddr || playAddr