Skip to content

Commit 10fb7e0

Browse files
committed
fix(platforms): restore tiktok video urls
1 parent 7d1246b commit 10fb7e0

1 file changed

Lines changed: 13 additions & 6 deletions

File tree

packages/platforms/src/platforms/tiktok.ts

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,19 @@ const FOLLOWUP_RE =
99

1010
async function parseMedia(raw: Record<string, any>): Promise<NormalizedPost["media"]> {
1111
if (raw.video) {
12-
const videoURL = raw.video.PlayAddrStruct.UrlList[2];
13-
const video = await fetch(videoURL, {
14-
method: "GET",
15-
redirect: "follow",
16-
});
17-
return [{ url: video.url, type: "video" }];
12+
const urls = raw.video.PlayAddrStruct?.UrlList ?? [];
13+
for (const url of urls) {
14+
const video = await fetch(url, {
15+
method: "GET",
16+
redirect: "follow",
17+
headers: {
18+
Range: "bytes=0-0",
19+
},
20+
});
21+
await video.body?.cancel();
22+
if (!video.ok || !video.headers.get("Content-Type")?.startsWith("video/")) continue;
23+
return [{ url, type: "video" }];
24+
}
1825
}
1926
return [];
2027
}

0 commit comments

Comments
 (0)