Skip to content

Commit

Permalink
feat(bot): add emded-proxy v2 support with v1 as fallback
Browse files Browse the repository at this point in the history
  • Loading branch information
lastarc committed Mar 31, 2024
1 parent 62133dd commit e03d632
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion bot/commands/media/tiktok.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,26 @@ module.exports = {
}

console.log(vurl, vwidth, vheight);
const embeddableUrl = `${EMBED_PROXY_URL}/?src=${encodeURIComponent(vurl)}&width=${vwidth}&height=${vheight}`;
let embeddableUrl = '';

const v2Check = await fetch(`${EMBED_PROXY_URL}/v2/healthz`);
if (v2Check.ok) {
const v2Res = await fetch(`${EMBED_PROXY_URL}/v2/add`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
src: vurl,
width: vwidth,
height: vheight,
}),
});
const v2Json = await v2Res.json();
embeddableUrl = `${EMBED_PROXY_URL}/v2/~/${v2Json.slug}`;
} else {
embeddableUrl = `${EMBED_PROXY_URL}/?src=${encodeURIComponent(vurl)}&width=${vwidth}&height=${vheight}`;
}
await replyMsg.edit(`Done ${embeddableUrl}`);
},
};

0 comments on commit e03d632

Please sign in to comment.