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,73 @@
|
||||
// JOOX 歌曲形状映射(统一 Song 形状,见 tmp/port-spec.md)
|
||||
// 兼容来源:openjoox2 track/album/playlist 条目、openjoox v3 search 的 song_info、
|
||||
// 以及 SSR 页面上的 track 条目(字段有 snake/camel 两套命名,上游 Go 也两套都兜底)。
|
||||
|
||||
import { formatPlayTime } from '../common/utils.ts'
|
||||
import {
|
||||
normalizeJooxID,
|
||||
pickJooxImage,
|
||||
jooxArtists,
|
||||
firstNonEmpty,
|
||||
firstNonZero,
|
||||
} from './util.ts'
|
||||
|
||||
/** 详情/列表 track 条目 → 统一 Song 形状 */
|
||||
export const jooxSongFromTrack = (
|
||||
item: any,
|
||||
fallbackAlbum = '',
|
||||
fallbackCover = '',
|
||||
fallbackAlbumId = '',
|
||||
): any | null => {
|
||||
const songmid = normalizeJooxID(item?.id)
|
||||
if (!songmid) return null
|
||||
|
||||
const artists = Array.isArray(item?.artist_list) && item.artist_list.length
|
||||
? item.artist_list
|
||||
: item?.artistList
|
||||
const albumId = normalizeJooxID(firstNonEmpty(item?.album_id, item?.albumId, fallbackAlbumId))
|
||||
|
||||
return {
|
||||
songmid,
|
||||
name: String(firstNonEmpty(item?.name, item?.title, 'Unknown')),
|
||||
singer: String(firstNonEmpty(jooxArtists(artists), 'Unknown')),
|
||||
albumId: String(albumId || ''),
|
||||
albumName: String(firstNonEmpty(item?.album_name, item?.albumName, fallbackAlbum)),
|
||||
interval: formatPlayTime(firstNonZero(item?.play_duration, item?.playDuration, item?.duration)),
|
||||
img: String(firstNonEmpty(
|
||||
pickJooxImage(item?.images),
|
||||
item?.imgSrc,
|
||||
item?.cover,
|
||||
item?.image,
|
||||
item?.pic,
|
||||
fallbackCover,
|
||||
)) || null,
|
||||
lrc: null,
|
||||
vip: Number(item?.vip_flag ?? 0) === 1,
|
||||
types: [],
|
||||
_types: {},
|
||||
source: 'joox' as const,
|
||||
}
|
||||
}
|
||||
|
||||
/** openjoox v3 搜索歌曲条目(song_info)→ 统一 Song 形状 */
|
||||
export const jooxSongFromSearch = (info: any): any | null => jooxSongFromTrack(info)
|
||||
|
||||
/** 详情接口返回的整曲信息(parse 用,含可播放地址)→ 统一 Song 形状 */
|
||||
export const jooxSongFromDetail = (detail: any, playUrl = ''): any => {
|
||||
const song = jooxSongFromTrack(detail) ?? {
|
||||
songmid: normalizeJooxID(detail?.id),
|
||||
name: String(detail?.name ?? ''),
|
||||
singer: String(jooxArtists(detail?.artist_list)),
|
||||
albumId: String(normalizeJooxID(detail?.album_id)),
|
||||
albumName: String(detail?.album_name ?? ''),
|
||||
interval: formatPlayTime(firstNonZero(detail?.play_duration)),
|
||||
img: String(pickJooxImage(detail?.images)) || null,
|
||||
lrc: null,
|
||||
types: [],
|
||||
_types: {},
|
||||
source: 'joox' as const,
|
||||
}
|
||||
if (playUrl) song.url = playUrl
|
||||
song.vip = Number(detail?.vip_flag ?? 0) === 1
|
||||
return song
|
||||
}
|
||||
Reference in new issue
Block a user