Skip to content

best way to save what you love

api/tikok: catch an age restriction error

wukkoa1fa79f2f56d
diff --git a/api/src/processing/services/tiktok.js b/api/src/processing/services/tiktok.js
index d5e5c6e4..976350b0 100644
--- a/api/src/processing/services/tiktok.js
+++ b/api/src/processing/services/tiktok.js
@@ -51,13 +51,22 @@ export default async function(obj) {
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,
- filenameBase = `tiktok_${detail.author.uniqueId}_${postId}`,
+ filenameBase = `tiktok_${detail.author?.uniqueId}_${postId}`,
bestAudio; // will get defaulted to m4a later on in match-action
images = detail.imagePost?.images;
- let playAddr = detail.video.playAddr;
+ let playAddr = detail.video?.playAddr;
+
if (obj.h265) {
const h265PlayAddr = detail?.video?.bitrateInfo?.find(b => b.CodecType.includes("h265"))?.PlayAddr.UrlList[0]
playAddr = h265PlayAddr || playAddr