- 删除旧 sdk/request.ts,全部 import 收敛到 sdk/common/request.ts(85 文件) - 注释死代码 630+ 行、裸 console.log 吞错 6 处、未使用符号 26 处清零 - bili 状态校验去重;utils DNS 预解析失败日志改 warn 带上下文 - CODE-AUDIT.md:第四节 P2 清理记录 + 第八节线索逐条复核结论(kw/kg/tx/wy parse 骨架相似实质各异,不抽公共层)
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { httpFetch } from '../common/request.ts'
|
|
|
|
export default {
|
|
getPic(songInfo) {
|
|
const requestObj = httpFetch(
|
|
'http://media.store.kugou.com/v1/get_res_privilege',
|
|
{
|
|
method: 'POST',
|
|
headers: {
|
|
'KG-RC': '1',
|
|
'KG-THash': 'expand_search_manager.cpp:852736169:451',
|
|
'User-Agent': 'KuGou2012-9020-ExpandSearchManager',
|
|
},
|
|
body: {
|
|
appid: 1001,
|
|
area_code: '1',
|
|
behavior: 'play',
|
|
clientver: '9020',
|
|
need_hash_offset: 1,
|
|
relate: 1,
|
|
resource: [
|
|
{
|
|
album_audio_id:
|
|
songInfo.songmid.length == 32 // 修复歌曲ID存储变更导致图片获取失败的问题
|
|
? songInfo.audioId.split('_')[0]
|
|
: songInfo.songmid,
|
|
album_id: songInfo.albumId,
|
|
hash: songInfo.hash,
|
|
id: 0,
|
|
name: `${songInfo.singer} - ${songInfo.name}.mp3`,
|
|
type: 'audio',
|
|
},
|
|
],
|
|
token: '',
|
|
userid: 2626431536,
|
|
vip: 1,
|
|
},
|
|
},
|
|
)
|
|
return requestObj.promise.then(({ body }) => {
|
|
if (body.error_code !== 0) return Promise.reject(new Error('图片获取失败'))
|
|
let info = body.data[0].info
|
|
const img = info.imgsize ? info.image.replace('{size}', info.imgsize[0]) : info.image
|
|
if (!img) return Promise.reject(new Error('Pic get failed'))
|
|
return img
|
|
})
|
|
},
|
|
}
|