fix tiktok bot media urls#91
Conversation
|
Deploying with
|
| Status | Name | Latest Commit | Preview URL | Updated (UTC) |
|---|---|---|---|---|
| ✅ Deployment successful! View logs |
embedly-docs | b268d04 | Commit Preview URL Branch Preview URL |
Jun 23 2026, 03:23 AM |
| continue; | ||
| } | ||
|
|
||
| const response = await fetch(item.url, { |
There was a problem hiding this comment.
[🟠 High] [🔵 Bug]
resolveMedia performs a network fetch for each TikTok candidate inside buildEmbed but does not catch fetch/cancel exceptions, so transient network failures (DNS/TLS/socket reset) throw out of embed construction and fail the request instead of degrading gracefully. This turns a best-effort media URL refinement step into a hard failure path; wrap the probe in try/catch and continue with the original item (or skip it) on error.
// apps/bot/src/lib/builder.ts
const response = await fetch(item.url, {
method: "GET",
redirect: "follow",
headers: {| raw.video.downloadAddr, | ||
| ...(raw.video.PlayAddrStruct?.UrlList ?? []), | ||
| ].filter((url) => typeof url === "string" && url.length > 0); | ||
| return [...new Set(urls)].map((url) => ({ url, type: "video" })); |
There was a problem hiding this comment.
[🟡 Medium] [🔵 Bug]
The transform now maps every candidate video URL into a distinct media item, but downstream rendering treats NormalizedPost.media as gallery items, not fallback URLs for a single asset. When multiple candidates return playable video, one TikTok post can render duplicate/alternate copies instead of a single resolved video URL; keep candidates as fallback metadata and collapse to one selected URL before emitting gallery media.
// packages/platforms/src/platforms/tiktok.ts
const urls = [
raw.video.playAddr,
raw.video.downloadAddr,
...(raw.video.PlayAddrStruct?.UrlList ?? []),
];
return [...new Set(urls)].map((url) => ({ url, type: "video" }));|
so tiktok seems to be working without this and unless i need it, its kinda pointless. |
Summary
Root cause
The API worker can be blocked by TikTok when checking media URLs, but the bot can resolve the playable TikTok URL immediately before sending the Discord message. Returning all candidates keeps the API response complete while letting the bot choose the URL Discord can actually use.
Validation
Fixes #86