diff --git a/README.md b/README.md index c3bd0a7..581c2d7 100644 --- a/README.md +++ b/README.md @@ -53,18 +53,18 @@ Don't want all that statistic clutter on your embed and only want the video or i We check all the boxes for being one of the best TikTok embedding services with many features that others don't have. Here's a table comparing our service, tnktok.com, with the other TikTok embedding services as well as TikTok's default embeds. -| | [tnktok.com](https://www.tnktok.com) | Default TikTok | [tiktxk.com](https://tiktxk.com) | [vxtiktok.com](https://vxtiktok.com) | [tfxktok.com](https://tfxktok.com) | -| -------------------------------------- | -------------------------------------------------- | -------------- | -------------------------------- | ----------------------------------------------------------------------------- | ---------------------------------- | -| Embed playable videos | ☑️ | ❌ | ❔ | ☑️ | ☑️ | -| Embed multi-image slideshows | ☑️ | ❌ | ❔ | [❌](https://github.com/dylanpdx/vxtiktok/issues/142#issuecomment-2128030983) | ☑️ | -| Embed lives | ☑️ | ➖ | ❌ | ❌ | ☑️ | -| Open source | ☑️ | ❌ | ☑️ | ☑️ | ❌ | -| Supports direct embeds | [➖](https://github.com/okdargy/fxTikTok/issues/9) | ❌ | ❌ | ❌ | ❌ | -| Shows like, shares, comments | ☑️ | ➖ | ➖ | ☑️ | ☑️ | -| Removes tracking for redirects | ☑️ | ❌ | ☑️ | ☑️ | ☑️ | -| Support for multi-continent short URLs | [☑️](https://github.com/okdargy/fxTikTok/issues/5) | ☑️ | ☑️ | ☑️ | ❌ | -| Support for h265/high quality | ☑️ | ❌ | ❔ | ❌ | ❌ | -| Last commit | [![][tnk]][tnkc] | N/A | [![][txk]][txkc] | [![][vxt]][vxtc] | N/A | +| | [tnktok.com](https://www.tnktok.com) | Default TikTok | [tiktxk.com](https://tiktxk.com) | [vxtiktok.com](https://vxtiktok.com) | [tfxktok.com](https://tfxktok.com) | +| -------------------------------------- | ------------------------------------ | -------------- | -------------------------------- | ------------------------------------ | ---------------------------------- | +| Embed playable videos | ☑️ | ❌ | ❔ | ☑️ | ☑️ | +| Embed multi-image slideshows | ☑️ | ❌ | ❔ | ❌ | ☑️ | +| Embed lives | ☑️ | ➖ | ❌ | ❌ | ☑️ | +| Open source | ☑️ | ❌ | ☑️ | ☑️ | ❌ | +| Supports direct embeds | ☑️ | ❌ | ❌ | ❌ | ❌ | +| Shows like, shares, comments | ☑️ | ➖ | ➖ | ☑️ | ☑️ | +| Removes tracking for redirects | ☑️ | ❌ | ☑️ | ☑️ | ☑️ | +| Support for multi-continent short URLs | ☑️ | ☑️ | ☑️ | ☑️ | ❌ | +| Support for h265/high quality | ☑️ | ❌ | ❔ | ❌ | ❌ | +| Last commit | [![][tnk]][tnkc] | N/A | [![][txk]][txkc] | [![][vxt]][vxtc] | N/A | [tnk]: https://img.shields.io/github/last-commit/okdargy/fxTikTok?label [tnkc]: https://github.com/okdargy/fxTikTok/commits diff --git a/src/index.ts b/src/index.ts index 79ae897..8998160 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import { cache } from 'hono/cache' import { scrapeLiveData, scrapeVideoData } from './services/tiktok' import { grabAwemeId } from './services/tiktok' -import { VideoResponse, ErrorResponse, LiveResponse } from './templates' +import { VideoResponse, ErrorResponse, LiveResponse, WarningResponse } from './templates' import generateAlternate from './util/generateAlternate' import { returnHTMLResponse } from './util/responseHelper' @@ -141,6 +141,11 @@ async function handleVideo(c: any): Promise { }) } } else { + if (videoInfo.isContentClassified === true) { + const responseContent = await WarningResponse('Sensitive Content', 'the video being age-restricted') + return returnHTMLResponse(responseContent, 200) + } + const responseContent = await VideoResponse(videoInfo) return returnHTMLResponse(responseContent) } diff --git a/src/templates/index.ts b/src/templates/index.ts index ffc9327..99509a2 100644 --- a/src/templates/index.ts +++ b/src/templates/index.ts @@ -1,3 +1,4 @@ export * from './pages/VideoResponse' export * from './pages/Error' export * from './pages/LiveResponse' +export * from './pages/WarningResponse' diff --git a/src/templates/pages/Error.tsx b/src/templates/pages/Error.tsx index a80a627..80cc152 100644 --- a/src/templates/pages/Error.tsx +++ b/src/templates/pages/Error.tsx @@ -1,4 +1,3 @@ -import { AwemeList } from '../../types/API' import MetaHelper from '../../util/metaHelper' export function ErrorResponse(error: string): JSX.Element { diff --git a/src/templates/pages/WarningResponse.tsx b/src/templates/pages/WarningResponse.tsx new file mode 100644 index 0000000..1aa26bd --- /dev/null +++ b/src/templates/pages/WarningResponse.tsx @@ -0,0 +1,22 @@ +import MetaHelper from '../../util/metaHelper' + +export function WarningResponse(title: string, reason: string): JSX.Element { + return ( + <> + {MetaHelper([ + { + name: 'og:title', + content: `⚠️ ${title}` + }, + { + name: 'theme-color', + content: '#f7c500' + }, + { + name: 'og:description', + content: `Sorry, we were unable to show this video due to ${reason}. If you would like to view the video, please visit TikTok directly.` + } + ])} + + ) +} diff --git a/src/tests/video.test.ts b/src/tests/video.test.ts index 2e34605..3bc3752 100644 --- a/src/tests/video.test.ts +++ b/src/tests/video.test.ts @@ -34,6 +34,22 @@ describe('GET /@i/video/:videoId', () => { }) }) +// age restricted video +describe('GET /@i/video/:videoId (age restricted)', () => { + // /t/ZP81NmQk9/ + it('should return 200', async () => { + const res = await app.request('/t/ZP81NmQk9', { + method: 'GET', + headers: { + 'User-Agent': 'Mozilla/5.0 (compatible; Discordbot/2.0; +https://discordapp.com)' + } + }) + + expect(res.status).toBe(200) + expect(await res.text()).toContain('⚠️') + }) +}) + describe('GET /t/:videoId', () => { it('should return 200', async () => { const res = await app.request('/t/ZPRKrbUB1', { diff --git a/src/types/Web.ts b/src/types/Web.ts index 132ad48..bb0171c 100644 --- a/src/types/Web.ts +++ b/src/types/Web.ts @@ -2899,6 +2899,7 @@ export interface ItemStruct { collected: boolean channelTags: any[] item_control: ItemControl + isContentClassified: boolean IsAigc: boolean AIGCDescription: string }