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 @@
|
||||
// 千千音乐链接解析
|
||||
// 歌曲:music.91q.com/song/<TSID>(上游 Parse:取 song/info 后顺带取直链,失败不影响返回)
|
||||
// 专辑:music.91q.com/album/<P码> / ?albumAssetCode= / ?albumid=
|
||||
// 歌单:music.91q.com/songlist|tracklist|playlist/<id> / ?*id= / 裸歌单 id
|
||||
import { getDownloadUrl } from '../apis/qian.ts'
|
||||
import { getSongInfo } from './musicInfo.ts'
|
||||
import { parseAlbumLink } from './album.ts'
|
||||
import { parsePlaylistLink } from './playlist.ts'
|
||||
import { firstNonEmpty } from './util.ts'
|
||||
|
||||
const TSID_RE = /music\.91q\.com\/song\/(\w+)/
|
||||
|
||||
/** 上游 Parse:歌曲链接 → Song(尽力附带直链 url/type) */
|
||||
export const parseSong = async(link: string) => {
|
||||
const match = TSID_RE.exec(String(link ?? ''))
|
||||
if (!match) throw new Error('无效的千千歌曲链接')
|
||||
const tsid = match[1]
|
||||
|
||||
const song: any = await getSongInfo(tsid)
|
||||
try {
|
||||
const hit = await getDownloadUrl(tsid)
|
||||
song.url = hit.url
|
||||
song.type = hit.type
|
||||
} catch {
|
||||
// 与上游一致:直链获取失败忽略(VIP/下架曲目仍返回元数据)
|
||||
}
|
||||
delete song.lyricUrl
|
||||
delete song.raw
|
||||
return { ...song, songmid: firstNonEmpty(song.songmid, tsid), source: 'qian' as const }
|
||||
}
|
||||
|
||||
export const parseAlbum = async(link: string) => parseAlbumLink(link)
|
||||
export const parsePlaylist = async(link: string) => parsePlaylistLink(link)
|
||||
|
||||
export default { parseSong, parseAlbum, parsePlaylist }
|
||||
Reference in new issue
Block a user