Skip to content

Commit

Permalink
feat(route/apple/podcast): add optional region parameter (DIYgod#17741)
Browse files Browse the repository at this point in the history
* feat(route/apple/podcast): add optional region parameter

* fix(route/apple/podcast): fix lint
  • Loading branch information
shunwork authored Nov 28, 2024
1 parent 899bd05 commit 35589ca
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions lib/routes/apple/podcast.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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,
Expand Down

0 comments on commit 35589ca

Please sign in to comment.