feat(sdk): 新增咪咕/千千/JOOX/哔哩哔哩/5sing/Apple Music 六平台
平台注册表由 9 个扩到 15 个,同时补齐 sdk/types.ts 的类型与 OpenAPI 文档里的能力位声明。 - migu:命中 Z3D/I3D 加密候选时不返回直链,改由服务端解密代理出流, SDK 侧只负责登记票据,避免客户端拿到无法播放的密文 - apple:只提供 preview 试听片段(完整曲为 DRM),标 noAggregate 排除在跨平台精确匹配之外,防止用它顶掉其它平台的可播结果 - 其余平台按既有 PlatformModule 约定实现搜索/专辑/歌单/歌词 为什么合并成一次提交:六平台共用同一份注册表与能力位声明, 拆开会产生互相引用、单独无法通过类型检查的中间态。
This commit is contained in:
1 parent
47ce651f46
commit
33b96f92c4
54 files changed
+6161
-5
No files matched your search
@@ -0,0 +1,35 @@
|
||||
// 千千音乐搜索(/v1/search?word=&type=1&pageNo=&pageSize=,appid + 签名)
|
||||
// 响应 data.typeTrack[]:TSID/title/albumTitle/albumAssetCode/pic/duration/artist/rateFileInfo/isVip
|
||||
// 注:上游会跳过 isVip != 0 的曲目(VIP 无法匿名取流);本实现保留并标记 payPlay,
|
||||
// 以便聚合搜索/顺播时仍能展示(取流失败会返回明确错误,路由可走兜底链路)。
|
||||
import { APP_ID, apiGet, apiOk, mapTrack } from './util.ts'
|
||||
|
||||
export const search = async(keyword: string, page = 1, limit = 20) => {
|
||||
const word = String(keyword ?? '').trim()
|
||||
const empty = { list: [] as any[], allPage: 1, total: 0, limit, source: 'qian' as const }
|
||||
if (!word) return empty
|
||||
|
||||
const body = await apiGet('/v1/search', {
|
||||
word,
|
||||
type: '1',
|
||||
pageNo: String(page),
|
||||
pageSize: String(limit),
|
||||
appid: APP_ID,
|
||||
})
|
||||
if (!apiOk(body) && Number(body?.errno) !== 23001) {
|
||||
throw new Error(body?.errmsg || `千千搜索失败(errno ${body?.errno})`)
|
||||
}
|
||||
const tracks = Array.isArray(body?.data?.typeTrack) ? body.data.typeTrack : []
|
||||
const total = Number(body?.data?.total) || tracks.length
|
||||
const haveMore = Number(body?.data?.haveMore) === 1
|
||||
|
||||
return {
|
||||
list: tracks.map((item: any) => mapTrack(item)).filter((song: any) => song.songmid),
|
||||
allPage: haveMore ? page + 1 : Math.max(page, Math.ceil(total / Math.max(1, limit)) || 1),
|
||||
total,
|
||||
limit,
|
||||
source: 'qian' as const,
|
||||
}
|
||||
}
|
||||
|
||||
export default { search }
|
||||
Reference in new issue
Block a user