fix(route): douyin uid verification

This commit is contained in:
Tony 2022-06-01 12:02:42 +00:00 committed by GitHub
parent 34a2e5b9c7
commit 2085c2c7b9
2 changed files with 4 additions and 1 deletions

View File

@ -852,7 +852,7 @@ YouTube 官方亦有提供频道 RSS形如 <https://www.youtube.com/feeds/vid
### 博主
<Route author="Max-Tortoise Rongronggg9" example="/douyin/user/MS4wLjABAAAARcAHmmF9mAG3JEixq_CdP72APhBlGlLVbN-1eBcPqao" path="/douyin/user/:uid/:routeParams?" :paramsDesc="['uid可在 URL 中找到', '额外参数query string 格式,请参阅下面的表格']" anticrawler="1" radar="1" rssbud="1" puppeteer="1">
<Route author="Max-Tortoise Rongronggg9" example="/douyin/user/MS4wLjABAAAARcAHmmF9mAG3JEixq_CdP72APhBlGlLVbN-1eBcPqao" path="/douyin/user/:uid/:routeParams?" :paramsDesc="['uid可在用户页面 URL 中找到', '额外参数query string 格式,请参阅下面的表格']" anticrawler="1" radar="1" rssbud="1" puppeteer="1">
| 键 | 含义 | 值 | 默认值 |
| -------- | ----------------------------------- | ---------------------- | ------- |

View File

@ -49,6 +49,9 @@ const getOriginAvatar = (url) =>
module.exports = async (ctx) => {
const uid = ctx.params.uid;
if (!uid.startsWith('MS4wLjABAAAA')) {
throw Error('Invalid UID. UID should start with <b>MS4wLjABAAAA</b>.');
}
const routeParams = Object.fromEntries(new URLSearchParams(ctx.params.routeParams));
const embed = fallback(undefined, queryToBoolean(routeParams.embed), false); // embed video
const iframe = fallback(undefined, queryToBoolean(routeParams.iframe), false); // embed video in iframe