From 35589cab81bcb5a8007d83eab9fbbae5e83bb4b4 Mon Sep 17 00:00:00 2001 From: shunwork <128399189+shunwork@users.noreply.github.com> Date: Thu, 28 Nov 2024 23:59:19 +0900 Subject: [PATCH] feat(route/apple/podcast): add optional region parameter (#17741) * feat(route/apple/podcast): add optional region parameter * fix(route/apple/podcast): fix lint --- lib/routes/apple/podcast.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/routes/apple/podcast.ts b/lib/routes/apple/podcast.ts index 11980e092..6eb313987 100644 --- a/lib/routes/apple/podcast.ts +++ b/lib/routes/apple/podcast.ts @@ -4,10 +4,13 @@ import { load } from 'cheerio'; import { parseDate } from '@/utils/parse-date'; export const route: Route = { - path: '/podcast/:id', + path: '/podcast/:id/:region?', categories: ['multimedia'], - example: '/apple/podcast/id1559695855', - parameters: { id: '播客id,可以在 Apple 播客app 内分享的播客的 URL 中找到' }, + example: '/apple/podcast/id1559695855/cn', + parameters: { + id: '播客id,可以在 Apple 播客app 内分享的播客的 URL 中找到', + region: '地區代碼,例如 cn、us、jp,預設為 cn', + }, features: { requireConfig: false, requirePuppeteer: false, @@ -18,17 +21,18 @@ export const route: Route = { }, radar: [ { - source: ['podcasts.apple.com/cn/podcast/:id'], + source: ['podcasts.apple.com/:region/podcast/:id'], }, ], name: '播客', maintainers: ['Acring'], handler, - url: 'www.apple.com.cn/apple-podcasts/', + url: 'www.apple.com/apple-podcasts/', }; async function handler(ctx) { - const link = `https://podcasts.apple.com/cn/podcast/${ctx.req.param('id')}`; + const { id, region } = ctx.req.param(); + const link = `https://podcasts.apple.com/${region || `cn`}/podcast/${id}`; const response = await got({ method: 'get', url: link,