Files
snowy-yang e1357dd412 refactor(api)!: 平台 id 回退——joox/5sing/bili/apple 恢复全名,目录对齐 bd/mg
- 撤销 3381e9b/1b972ec 中 jx/5s/bl/ap 四个短码,恢复 joox/5sing/bili/apple;
  qian→bd、migu→mg 保留
- 目录与文件对齐保留的新 id:sdk/qian/→sdk/bd/、sdk/migu/→sdk/mg/、
  sdk/apis/qian.ts→bd.ts、migu.ts→mg.ts、src/http/migu-stream.ts→mg-stream.ts
  (规则改为「目录=对外 id」,聚合入口的模块变量同步更名;music.migu.cn 等域名、
  上游 music-lib 对照注释、miguGet 等功能标识符不动)
- 对外 id 全表:kw kg tx wy qs xm me qt lr mg bd joox 5sing bili apple

**破坏性变更**:joox/5sing/bili/apple 四平台的 URL、/sources 返回与
data/auth.json 凭据键恢复全名,已存短码键的登录态需重新登录。

验证:typecheck ✓、pnpm test 112/112 ✓
2026-10-03 21:04:55 +08:00

35 lines
1.3 KiB
TypeScript
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// 千千音乐歌词
// 链路:/v1/song/info → data[0].lyric 为歌词文本 URL(static-qianqian.taihe.com/*.txt)→ 直接下载文本。
// 返回 { lyric, tlyric: '' }(千千只有原文歌词,无翻译)。
import { httpFetch } from '../common/request.ts'
import { getSongInfo } from './musicInfo.ts'
import { requestHeaders } from './util.ts'
export const getLyric = (songInfo: any) => {
const requestObj: any = { promise: null, cancelHttp() {} }
const tsid = String(songInfo?.songmid ?? songInfo?.TSID ?? '').trim()
let lyricReq: any = null
requestObj.cancelHttp = () => {
lyricReq?.cancelHttp?.()
lyricReq = null
}
requestObj.promise = (async() => {
if (!tsid) throw new Error('千千歌词需要 songmid(TSID)')
const info = await getSongInfo(tsid)
const lyricUrl = info?.lyricUrl
if (!lyricUrl) throw new Error('千千该歌曲暂无歌词')
lyricReq = httpFetch(lyricUrl, { headers: requestHeaders(), timeout: 15000 })
const { statusCode, body, raw } = await lyricReq.promise as any
if (statusCode != 200) throw new Error(`千千歌词下载失败(HTTP ${statusCode})`)
const lyric = typeof body === 'string' ? body : raw?.toString('utf8') ?? ''
return { lyric, tlyric: '' }
})()
return requestObj
}
export default { getLyric }