feat(route): tiktok iframe (#13066)

This commit is contained in:
Tony 2023-08-18 04:44:38 +08:00 committed by GitHub
parent 507e836238
commit 25e4d85853
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 13 additions and 4 deletions

View File

@ -1,3 +1,3 @@
module.exports = (router) => {
router.get('/user/:user', require('./user'));
router.get('/user/:user/:iframe?', require('./user'));
};

View File

@ -1,3 +1,7 @@
{{ if useIframe }}
<iframe src="https://www.tiktok.com/embed/{{ id }}" height="757" frameborder="0" referrerpolicy="no-referrer"></iframe>
{{ else }}
<video controls loop poster="{{ poster }}" preload="none">
<source src="{{ source }}">
<source src="{{ source }}">
</video>
{{ /if }}

View File

@ -2,11 +2,13 @@ const config = require('@/config').value;
const { parseDate } = require('@/utils/parse-date');
const { art } = require('@/utils/render');
const path = require('path');
const { queryToBoolean } = require('@/utils/readable-social');
const baseUrl = 'https://www.tiktok.com';
module.exports = async (ctx) => {
const { user } = ctx.params;
const { user, iframe } = ctx.params;
const useIframe = queryToBoolean(iframe);
const data = await ctx.cache.tryGet(
`tiktok:user:${user}`,
@ -38,6 +40,8 @@ module.exports = async (ctx) => {
description: art(path.join(__dirname, 'templates/user.art'), {
poster: item.video.cover,
source: item.video.playAddr,
useIframe,
id: item.id,
}),
author: item.nickname,
pubDate: parseDate(item.createTime, 'X'),

View File

@ -467,13 +467,14 @@ Specify different option values than default values to improve readability. The
```
https://rsshub.app/threads/zuck/showAuthorInTitle=1&showAuthorInDesc=1&showQuotedAuthorAvatarInDesc=1&showAuthorAvatarInDesc=1&showEmojiForQuotesAndReply=1&showQuotedInTitle=1
```
</RouteEn>
## TikTok
### User
<RouteEn author="TonyRL" example="/tiktok/user/@linustech" path="/tiktok/user/:user" paramsDesc={['User ID, including @']} anticrawler="1" puppeteer="1" radar="1" rssbud="1"/>
<RouteEn author="TonyRL" example="/tiktok/user/@linustech/true" path="/tiktok/user/:user/:iframe?" paramsDesc={['User ID, including @', 'Use the official iframe to embed the video, which allows you to view the video if the default option does not work. Default to `false`']} anticrawler="1" puppeteer="1" radar="1" rssbud="1"/>
## Twitter