Skip to content

Commit

Permalink
revert: tiktok is back! 67ba564 #24
Browse files Browse the repository at this point in the history
  • Loading branch information
okdargy committed Jan 19, 2025
1 parent 67ba564 commit 53f30c2
Showing 1 changed file with 6 additions and 29 deletions.
35 changes: 6 additions & 29 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Hono } from 'hono'
import { scrapeLiveData, scrapeVideoData } from './services/tiktok'
import { grabAwemeId } from './services/tiktok'
import { VideoResponse, ErrorResponse, LiveResponse, WarningResponse, MessageResponse } from './templates'
import { VideoResponse, ErrorResponse, LiveResponse, WarningResponse } from './templates'
import generateAlternate from './util/generateAlternate'
import { returnHTMLResponse } from './util/responseHelper'

Expand Down Expand Up @@ -327,49 +327,26 @@ app.get('/generate/livePic/:author', async (c) => {
}
})

async function handleDown(c: any): Promise<Response> {
if (!BOT_REGEX.test(c.req.header('User-Agent') || '')) {
const url = new URL(c.req.url)

// Remove tracking parameters
url.search = ''

return new Response('', {
status: 302,
headers: {
Location: 'https://www.tiktok.com' + url.pathname
}
})
}

const responseContent = await MessageResponse(
'TikTok has been banned in the United States',
'As many of you may know, the U.S. Supreme Court has upheld a law that effectively bans TikTok in the United States.\n\n' +
'Because we utilize Cloudflare Workers, which primarily operates through U.S.-based servers, we are unable to access TikTok\'s services.\n\nWe apologize for the inconvenience.'
)
return returnHTMLResponse(responseContent, 200, true);
}

const routes = [
{
path: '/:videoId',
handler: handleDown
handler: handleShort
},
{
path: '/t/:videoId',
handler: handleDown
handler: handleShort
},
{
path: '/*/video/:videoId',
handler: handleDown
handler: handleVideo
},
{
path: '/*/photo/:videoId',
handler: handleDown
handler: handleVideo
},
{
path: '/:author/live',
handler: handleDown
handler: handleLive
}
]

Expand Down

0 comments on commit 53f30c2

Please sign in to comment.