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

+42
View File
@@ -0,0 +1,42 @@
// JOOX 搜索(上游 joox/song.go Search 移植)
// 端点:GET https://cache.api.joox.com/openjoox/v3/search?country=sg&lang=zh_cn&keyword=<kw>
// 返回 section_list(0 歌曲 / 2 歌手 / 1 专辑 / 3 歌单 / 7 用户),歌曲在 item_list[].song[].song_info。
// 该接口无分页参数(上游也未分页),page 参数仅为统一契约保留;allPage 恒为 1。
// 实测(2026-10-02):英文/中文关键词均 HTTP 200。
import { httpFetch } from '../request.ts'
import { jooxHeaders } from './util.ts'
import { jooxSongFromSearch } from './song.ts'
const SEARCH_URL = 'https://cache.api.joox.com/openjoox/v3/search'
export const search = async(keyword: string, page = 1, limit = 20) => {
const url = `${SEARCH_URL}?country=sg&lang=zh_cn&keyword=${encodeURIComponent(String(keyword ?? ''))}`
const { statusCode, body } = await httpFetch(url, { headers: jooxHeaders(), timeout: 20000 }).promise as any
if (statusCode != 200 || !body?.section_list) {
return { list: [], allPage: 0, total: 0, limit, source: 'joox' as const }
}
const list: any[] = []
const seen = new Set<string>()
for (const section of body.section_list) {
for (const item of section?.item_list ?? []) {
for (const entry of item?.song ?? []) {
const song = jooxSongFromSearch(entry?.song_info)
if (!song || seen.has(song.songmid)) continue
seen.add(song.songmid)
list.push(song)
}
}
}
return {
list: list.slice(0, limit),
allPage: 1,
total: list.length,
limit,
source: 'joox' as const,
}
}
export default { search }