feat(route/qingting): return first page program instead of 10
This commit is contained in:
parent
310515b969
commit
4c0925157f
|
|
@ -1,6 +1,6 @@
|
|||
import { Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import got from '@/utils/got';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
|
||||
|
|
@ -18,18 +18,18 @@ export const route: Route = {
|
|||
supportScihub: false,
|
||||
},
|
||||
name: '专辑',
|
||||
maintainers: ['nczitzk'],
|
||||
maintainers: ['nczitzk', 'pseudoyu'],
|
||||
handler,
|
||||
};
|
||||
|
||||
async function handler(ctx) {
|
||||
const channelUrl = `https://i.qingting.fm/capi/v3/channel/${ctx.req.param('id')}`;
|
||||
let response = await got(channelUrl);
|
||||
const title = response.data.data.title;
|
||||
const programUrl = `https://i.qingting.fm/capi/channel/${ctx.req.param('id')}/programs/${response.data.data.v}?curpage=1&pagesize=10&order=asc`;
|
||||
response = await got(programUrl);
|
||||
let response = await ofetch(channelUrl);
|
||||
const title = response.data.title;
|
||||
const programUrl = `https://i.qingting.fm/capi/channel/${ctx.req.param('id')}/programs/${response.data.v}?curpage=1&order=asc`;
|
||||
response = await ofetch(programUrl);
|
||||
|
||||
const items = response.data.data.programs.map((item) => ({
|
||||
const items = response.data.programs.map((item) => ({
|
||||
title: item.title,
|
||||
link: `https://www.qingting.fm/channels/${ctx.req.param('id')}/programs/${item.id}/`,
|
||||
pubDate: timezone(parseDate(item.update_time), +8),
|
||||
|
|
@ -41,8 +41,8 @@ async function handler(ctx) {
|
|||
item: await Promise.all(
|
||||
items.map((item) =>
|
||||
cache.tryGet(item.link, async () => {
|
||||
response = await got(item.link);
|
||||
const data = JSON.parse(response.data.match(/},"program":(.*?),"plist":/)[1]);
|
||||
response = await ofetch(item.link);
|
||||
const data = JSON.parse(response.match(/},"program":(.*?),"plist":/)[1]);
|
||||
item.description = data.richtext;
|
||||
return item;
|
||||
})
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
import type { DataItem, Route } from '@/types';
|
||||
import cache from '@/utils/cache';
|
||||
import crypto from 'crypto';
|
||||
import got from '@/utils/got';
|
||||
import ofetch from '@/utils/ofetch';
|
||||
import timezone from '@/utils/timezone';
|
||||
import { parseDate } from '@/utils/parse-date';
|
||||
import { config } from '@/config';
|
||||
|
|
@ -29,7 +29,7 @@ export const route: Route = {
|
|||
},
|
||||
],
|
||||
name: '播客',
|
||||
maintainers: ['RookieZoe', 'huyyi'],
|
||||
maintainers: ['RookieZoe', 'huyyi', 'pseudoyu'],
|
||||
handler,
|
||||
description: `获取的播放 URL 有效期只有 1 天,需要开启播客 APP 的自动下载功能。`,
|
||||
};
|
||||
|
|
@ -44,35 +44,27 @@ async function handler(ctx) {
|
|||
const channelId = ctx.req.param('id');
|
||||
|
||||
const channelUrl = `https://i.qingting.fm/capi/v3/channel/${channelId}`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: channelUrl,
|
||||
const response = await ofetch(channelUrl, {
|
||||
headers: {
|
||||
Referer: 'https://www.qingting.fm/',
|
||||
},
|
||||
});
|
||||
|
||||
const title = response.data.data.title;
|
||||
const channel_img = response.data.data.thumbs['400_thumb'];
|
||||
const authors = response.data.data.podcasters.map((author) => author.nick_name).join(',');
|
||||
const desc = response.data.data.description;
|
||||
const programUrl = `https://i.qingting.fm/capi/channel/${channelId}/programs/${response.data.data.v}?curpage=1&pagesize=10&order=asc`;
|
||||
const title = response.data.title;
|
||||
const channel_img = response.data.thumbs['400_thumb'];
|
||||
const authors = response.data.podcasters.map((author) => author.nick_name).join(',');
|
||||
const desc = response.data.description;
|
||||
const programUrl = `https://i.qingting.fm/capi/channel/${channelId}/programs/${response.data.v}?curpage=1&pagesize=10&order=asc`;
|
||||
|
||||
const {
|
||||
data: {
|
||||
data: { programs },
|
||||
},
|
||||
} = await got({
|
||||
method: 'get',
|
||||
url: programUrl,
|
||||
data: { programs },
|
||||
} = await ofetch(programUrl, {
|
||||
headers: {
|
||||
Referer: 'https://www.qingting.fm/',
|
||||
},
|
||||
});
|
||||
|
||||
const {
|
||||
data: { data: channelInfo },
|
||||
} = await got(`https://i.qingting.fm/capi/v3/channel/${channelId}?user_id=${qingtingId}`);
|
||||
const { data: channelInfo } = await ofetch(`https://i.qingting.fm/capi/v3/channel/${channelId}?user_id=${qingtingId}`);
|
||||
|
||||
const isCharged = channelInfo.purchase?.item_type !== 0;
|
||||
|
||||
|
|
@ -83,15 +75,13 @@ async function handler(ctx) {
|
|||
const data = (await cache.tryGet(`qingting:podcast:${channelId}:${item.id}`, async () => {
|
||||
const link = `https://www.qingting.fm/channels/${channelId}/programs/${item.id}/`;
|
||||
|
||||
const detailRes = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
const detailRes = await ofetch(link, {
|
||||
headers: {
|
||||
Referer: 'https://www.qingting.fm/',
|
||||
},
|
||||
});
|
||||
|
||||
const detail = JSON.parse(detailRes.data.match(/},"program":(.*?),"plist":/)[1]);
|
||||
const detail = JSON.parse(detailRes.match(/},"program":(.*?),"plist":/)[1]);
|
||||
|
||||
const rssItem = {
|
||||
title: item.title,
|
||||
|
|
|
|||
Loading…
Reference in New Issue