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:
snowy-yang committed 2026-10-03 00:26:32 +08:00
1 parent 47ce651f46
commit 33b96f92c4
54 files changed
+6161 -5

No files matched your search

+44
View File
@@ -0,0 +1,44 @@
// 咪咕音乐搜索 —— search_all.do(Android_migu 参数),searchSwitch 控制返回类别
// 上游对应:music-lib/migu/migu.go 的 (*Migu).Search
import { buildUrl, convertItemToSong, miguGet, type MiguSongItem } from './util.ts'
export const SEARCH_ALL_URL = 'http://pd.musicapp.migu.cn/MIGUM2.0/v1.0/content/search_all.do'
/** 搜索开关:只开某一类(song/album/songlist),bestShow 保留最优推荐 */
export const searchSwitch = (kind: 'song' | 'album' | 'songlist'): string => JSON.stringify({
song: kind === 'song' ? 1 : 0,
album: kind === 'album' ? 1 : 0,
singer: 0,
tagSong: 0,
mvSong: 0,
songlist: kind === 'songlist' ? 1 : 0,
bestShow: 1,
})
export const searchAll = async(text: string, kind: 'song' | 'album' | 'songlist', page = 1, limit = 20): Promise<any> => {
const url = buildUrl(SEARCH_ALL_URL, {
ua: 'Android_migu',
version: '5.0.1',
text,
pageNo: page,
pageSize: limit,
searchSwitch: searchSwitch(kind),
})
return miguGet(url)
}
export const search = async(keyword: string, page = 1, limit = 20) => {
const body = await searchAll(keyword, 'song', page, limit)
const result: MiguSongItem[] = body?.songResultData?.result ?? []
const list = result.map(item => convertItemToSong(item, true)).filter((s): s is NonNullable<typeof s> => s != null)
const total = parseInt(String(body?.songResultData?.totalCount ?? list.length), 10) || list.length
return {
list,
allPage: Math.max(1, Math.ceil(total / limit)),
total,
limit,
source: 'migu' as const,
}
}
export default { search }