From 766b5f73e94f73a13467a7c19bd25731f7b80903 Mon Sep 17 00:00:00 2001 From: dargy Date: Sun, 9 Jun 2024 13:48:59 -0500 Subject: [PATCH] minor: change /image redirects to rely on web instead of tikwm --- src/index.ts | 9 +++++++-- src/templates/pages/LiveResponse.tsx | 1 - 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 229ba74..ae96030 100644 --- a/src/index.ts +++ b/src/index.ts @@ -50,7 +50,7 @@ async function handleShort(c: any): Promise { let id = videoId.split('.')[0] // for .mp4, .webp, etc. // First, we need to find where the vm link goes to - const res = await fetch('https://vm.tiktok.com/' + videoId) + const res = await fetch('https://vm.tiktok.com/' + id) const link = new URL(res.url) // Clean any tracking parameters @@ -214,6 +214,7 @@ app.get('/generate/video/:videoId', async (c) => { try { const data = await scrapeVideoData(videoId) + /* if (!(data instanceof Error)) { if(data.video.playAddr) { @@ -248,7 +249,11 @@ app.get('/generate/image/:videoId', async (c) => { try { const data = await scrapeVideoData(videoId) - return c.redirect(`https://tikwm.com/video/cover/${videoId}.webp`) + if ('imagePost' in data && data.imagePost.images.length > 0) { + return c.redirect(data.imagePost.images[0].imageURL.urlList[0]); + } else { + throw new Error('Image not found'); + } } catch (e) { return new Response((e as Error).message, { status: 500, diff --git a/src/templates/pages/LiveResponse.tsx b/src/templates/pages/LiveResponse.tsx index 2c9a96a..5fb566a 100644 --- a/src/templates/pages/LiveResponse.tsx +++ b/src/templates/pages/LiveResponse.tsx @@ -7,7 +7,6 @@ export function LiveResponse(data: LiveRoom): JSX.Element { title += `👀 ${formatNumber(String(data.liveRoomUserInfo.liveRoom.liveRoomStats.userCount))} ` - console.log(data.liveRoomUserInfo.liveRoom.status) if(data.liveRoomUserInfo.liveRoom.status !== 4) { // live has NOT ended title += `🔴 LIVE ` title += `🕒 ${formatTime(data.liveRoomUserInfo.liveRoom.startTime)} `