* chore(deps-dev): bump eslint-plugin-unicorn from 64.0.0 to 65.0.0 Bumps [eslint-plugin-unicorn](https://github.com/sindresorhus/eslint-plugin-unicorn) from 64.0.0 to 65.0.0. - [Release notes](https://github.com/sindresorhus/eslint-plugin-unicorn/releases) - [Commits](https://github.com/sindresorhus/eslint-plugin-unicorn/compare/v64.0.0...v65.0.0) --- updated-dependencies: - dependency-name: eslint-plugin-unicorn dependency-version: 65.0.0 dependency-type: direct:development update-type: version-update:semver-major ... Signed-off-by: dependabot[bot] <support@github.com> * fix: no-array-from-fill * fix: unicorn-js/no-duplicate-set-values * fix: no-this-outside-of-class * fix: no-unnecessary-nested-ternary * fix: prefer-array-last-methods * fix: prefer-queue-microtask * fix: prefer-split-limit * fix: no-array-from-fill * fix: no-unused-array-method-return * fix: prefer-single-call * fix: prefer-includes-over-repeated-comparisons * fix: consistent-compound-words * fix: prefer-includes-over-repeated-comparisons * chore: add eslint-plugin-unicorn v65 recommended preset * fix: correct duration parsing logic in parseDuration function * fix: update oxlint-disable --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Tony <TonyRL@users.noreply.github.com>
74 lines
2.5 KiB
TypeScript
74 lines
2.5 KiB
TypeScript
import type { Route } from '@/types';
|
|
import { ViewType } from '@/types';
|
|
|
|
import { getDataByUsername as getDataByUsernameGoogle } from './api/google';
|
|
import { getDataByUsername as getDataByUsernameYoutubei } from './api/youtubei';
|
|
import { callApi } from './utils';
|
|
|
|
export const route: Route = {
|
|
path: '/user/:username/:routeParams?',
|
|
categories: ['social-media'],
|
|
view: ViewType.Videos,
|
|
example: '/youtube/user/@JFlaMusic',
|
|
parameters: {
|
|
username: 'YouTuber handle with @',
|
|
routeParams: 'Extra parameters, see the table below',
|
|
},
|
|
description: `::: tip Parameter
|
|
|
|
| Name | Description | Default |
|
|
| ------------ | ---------------------------------------------------------------------------------- | ------- |
|
|
| embed | Whether to embed the video, fill in any value to disable embedding | embed |
|
|
| filterShorts | Whether to filter out shorts from the feed, fill in any falsy value to show shorts | true |
|
|
|
|
:::`,
|
|
features: {
|
|
requireConfig: [
|
|
{
|
|
name: 'YOUTUBE_KEY',
|
|
description: ' YouTube API Key, support multiple keys, split them with `,`, [API Key application](https://console.developers.google.com/)',
|
|
optional: true,
|
|
},
|
|
],
|
|
requirePuppeteer: false,
|
|
antiCrawler: false,
|
|
supportBT: false,
|
|
supportPodcast: false,
|
|
supportScihub: false,
|
|
},
|
|
radar: [
|
|
{
|
|
source: ['www.youtube.com/user/:username', 'www.youtube.com/:username', 'www.youtube.com/:username/videos'],
|
|
target: '/user/:username',
|
|
},
|
|
],
|
|
name: 'Channel with user handle',
|
|
maintainers: ['DIYgod', 'pseudoyu'],
|
|
handler,
|
|
};
|
|
|
|
async function handler(ctx) {
|
|
const username = ctx.req.param('username');
|
|
|
|
// Parse route parameters
|
|
const routeParams = ctx.req.param('routeParams');
|
|
const params = new URLSearchParams(routeParams);
|
|
|
|
// Get embed parameter
|
|
const embed = !params.get('embed');
|
|
|
|
// Get filterShorts parameter (default to true if not specified)
|
|
const filterShortsStr = params.get('filterShorts');
|
|
const filterShorts = [null, '', 'true'].includes(filterShortsStr);
|
|
|
|
const isJsonFeed = ctx.req.query('format') === 'json';
|
|
|
|
const data = await callApi({
|
|
googleApi: getDataByUsernameGoogle,
|
|
youtubeiApi: getDataByUsernameYoutubei,
|
|
params: { username, embed, filterShorts, isJsonFeed },
|
|
});
|
|
|
|
return data;
|
|
}
|