Skip to content

Commit e03d632

Browse files
committed
feat(bot): add emded-proxy v2 support with v1 as fallback
1 parent 62133dd commit e03d632

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

bot/commands/media/tiktok.js

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,26 @@ module.exports = {
107107
}
108108

109109
console.log(vurl, vwidth, vheight);
110-
const embeddableUrl = `${EMBED_PROXY_URL}/?src=${encodeURIComponent(vurl)}&width=${vwidth}&height=${vheight}`;
110+
let embeddableUrl = '';
111+
112+
const v2Check = await fetch(`${EMBED_PROXY_URL}/v2/healthz`);
113+
if (v2Check.ok) {
114+
const v2Res = await fetch(`${EMBED_PROXY_URL}/v2/add`, {
115+
method: 'POST',
116+
headers: {
117+
'Content-Type': 'application/json',
118+
},
119+
body: JSON.stringify({
120+
src: vurl,
121+
width: vwidth,
122+
height: vheight,
123+
}),
124+
});
125+
const v2Json = await v2Res.json();
126+
embeddableUrl = `${EMBED_PROXY_URL}/v2/~/${v2Json.slug}`;
127+
} else {
128+
embeddableUrl = `${EMBED_PROXY_URL}/?src=${encodeURIComponent(vurl)}&width=${vwidth}&height=${vheight}`;
129+
}
111130
await replyMsg.edit(`Done ${embeddableUrl}`);
112131
},
113132
};

0 commit comments

Comments
 (0)