Files
snowy-yang 8c02fb5c15 refactor(sdk): 审计 P2 卫生项清理——请求层收敛与死代码清除
- 删除旧 sdk/request.ts,全部 import 收敛到 sdk/common/request.ts(85 文件)
- 注释死代码 630+ 行、裸 console.log 吞错 6 处、未使用符号 26 处清零
- bili 状态校验去重;utils DNS 预解析失败日志改 warn 带上下文
- CODE-AUDIT.md:第四节 P2 清理记录 + 第八节线索逐条复核结论(kw/kg/tx/wy parse 骨架相似实质各异,不抽公共层)
2026-10-03 20:48:54 +08:00

56 lines
2.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 猫耳FM 广播剧集列表(web 通道,匿名免签)
// 接口: https://www.missevan.com/dramaapi/getdramaepisodes?drama_id=&season=&page=&order=0&pageSize=
// 结果在 info.episodes.episode[](name/sound_id/pay_type/vip);剧名在 info.drama.name
// 注意:getdrama(不带 type=2 时)的 info.episodes.episode 同样可用(MusicFree 插件用法),本接口支持翻页故用之
import { httpFetch } from '../common/request.ts'
import { formatPlayTime } from '../index.ts'
const EPISODES_URL = 'https://www.missevan.com/dramaapi/getdramaepisodes'
export const getAlbumDetail = async(dramaIdRaw: string, page = 1, limit = 30) => {
// 搜索结果的剧条目带 d: 前缀(songmid="d:<id>"),这里剥掉
const dramaId = dramaIdRaw.startsWith('d:') ? dramaIdRaw.slice(2) : dramaIdRaw
if (!/^\d+$/.test(dramaId)) throw new Error('剧 id 无效')
const { statusCode, body } = await httpFetch(
`${EPISODES_URL}?drama_id=${dramaId}&season=1&page=${page}&order=0&pageSize=${Math.max(30, limit)}`,
{
headers: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/125.0.0.0 Safari/537.36',
Referer: `https://www.missevan.com/mdrama/drama/${dramaId}`,
Accept: 'application/json',
},
timeout: 15000,
},
).promise as any
if (statusCode != 200 || body?.success === false) {
throw new Error(body?.info || `获取剧集失败(HTTP ${statusCode})`)
}
const info = body?.info ?? {}
const drama = info.drama ?? {}
const episodes = info.episodes?.episode ?? []
return {
info: { name: drama.name || String(dramaId), total: episodes.length },
list: episodes.slice(0, limit).map((item: any) => ({
songmid: String(item.sound_id),
name: item.name || '',
singer: drama.name || '',
albumId: String(dramaId),
albumName: drama.name || '',
interval: item.duration ? formatPlayTime(Math.round(Number(item.duration) / 1000)) : 0,
payPlay: Number(item.pay_type) > 0,
img: drama.cover || null,
lrc: '',
lrcx: '',
types: [],
_types: {},
disabled: false,
})),
total: episodes.length,
limit,
allPage: 1,
source: 'me' as const,
}
}
export default { getAlbumDetail }