Skip to content

Commit

Permalink
minor: change /image redirects to rely on web instead of tikwm
Browse files Browse the repository at this point in the history
  • Loading branch information
okdargy committed Jun 9, 2024
1 parent a89a548 commit 766b5f7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
9 changes: 7 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ async function handleShort(c: any): Promise<Response> {
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
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion src/templates/pages/LiveResponse.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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)} `
Expand Down

0 comments on commit 766b5f7

Please sign in to comment.