refactor(sdk): 审计 P2 卫生项清理——请求层收敛与死代码清除
- 删除旧 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 骨架相似实质各异,不抽公共层)
This commit is contained in:
1 parent
ecca1b8458
commit
8c02fb5c15
85 files changed
+112
-839
No files matched your search
+1
-1
@@ -1,6 +1,6 @@
|
||||
import { getMusicInfosByList } from './musicInfo.ts'
|
||||
import { createHttpFetch } from './util.ts'
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
|
||||
const albumCover = (url: any): string => String(url ?? '').replace('{size}', '240')
|
||||
|
||||
|
||||
+1
-5
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { decodeName, dateFormat2 } from '../index.ts'
|
||||
import { signatureParams } from './util.ts'
|
||||
// import { getMusicInfoRaw } from './musicInfo.ts'
|
||||
@@ -22,13 +22,11 @@ export default {
|
||||
},
|
||||
})
|
||||
const { body, statusCode } = await _requestObj.promise
|
||||
// console.log(body)
|
||||
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取评论失败')
|
||||
const total = body.count ?? 0
|
||||
return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
|
||||
},
|
||||
async getHotComment({ hash }, page = 1, limit = 20) {
|
||||
// console.log(songmid)
|
||||
if (this._requestObj2) this._requestObj2.cancelHttp()
|
||||
let timestamp = Date.now()
|
||||
const params = `dfid=0&mid=16249512204336365674023395779019&clienttime=${timestamp}&uuid=0&extdata=${hash}&appid=1005&code=fc4be23b4e972707f36b8a828a93ba8a&schash=${hash}&clientver=11409&p=${page}&clienttoken=&pagesize=${limit}&ver=10&kugouid=0`
|
||||
@@ -39,7 +37,6 @@ export default {
|
||||
},
|
||||
})
|
||||
const { body, statusCode } = await _requestObj2.promise
|
||||
// console.log(body)
|
||||
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取热门评论失败')
|
||||
const total = body.count ?? 0
|
||||
return { source: 'kg', comments: this.filterComment(body.list || []), total, page, limit, maxPage: Math.ceil(total / limit) || 1 }
|
||||
@@ -57,7 +54,6 @@ export default {
|
||||
},
|
||||
})
|
||||
const { body, statusCode } = await _requestObj2.promise
|
||||
// console.log(body)
|
||||
if (statusCode != 200 || body.err_code !== 0) throw new Error('获取回复评论失败')
|
||||
return { source: 'kg', comments: this.filterComment(body.list || []) }
|
||||
},
|
||||
|
||||
+1
-2
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { decodeName } from '../index.ts'
|
||||
import type { HttpRequestObject } from '../types.ts'
|
||||
|
||||
@@ -21,7 +21,6 @@ export default {
|
||||
})
|
||||
const { body, statusCode } = await _requestObj.promise
|
||||
if (statusCode != 200 || body.errcode !== 0) throw new Error('获取热搜词失败')
|
||||
// console.log(body, statusCode)
|
||||
return { source: 'kg', list: this.filterList(body.data.list) }
|
||||
},
|
||||
filterList(rawList) {
|
||||
|
||||
+2
-23
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { decodeName, formatPlayTime, sizeFormate } from '../index.ts'
|
||||
import { formatSingerName } from '../utils.ts'
|
||||
import type { HttpRequestObject, SongType, QualityInfo } from '../types.ts'
|
||||
@@ -91,7 +91,6 @@ export default {
|
||||
return arr.join('、')
|
||||
},
|
||||
filterData(rawList) {
|
||||
// console.log(rawList)
|
||||
return rawList.map(item => {
|
||||
const types: Array<SongType & { hash?: string }> = []
|
||||
const _types: Record<string, QualityInfo & { hash?: string }> = {}
|
||||
@@ -147,7 +146,6 @@ export default {
|
||||
},
|
||||
|
||||
filterBoardsData(rawList) {
|
||||
// console.log(rawList)
|
||||
let list: Array<{ id: string; name: string; bangid: string }> = []
|
||||
for (const board of rawList) {
|
||||
if (board.isvol != 1) continue
|
||||
@@ -159,24 +157,7 @@ export default {
|
||||
}
|
||||
return list
|
||||
},
|
||||
async getBoards(retryNum = 0) {
|
||||
// if (++retryNum > 3) return Promise.reject(new Error('try max num'))
|
||||
// let response
|
||||
// try {
|
||||
// response = await this.getBoardsData()
|
||||
// } catch (error) {
|
||||
// return this.getBoards(retryNum)
|
||||
// }
|
||||
// // console.log(response.body)
|
||||
// if (response.statusCode !== 200 || response.body.errcode !== 0) return this.getBoards(retryNum)
|
||||
// const list = this.filterBoardsData(response.body.data.info)
|
||||
// console.log(list)
|
||||
// // console.log(JSON.stringify(list))
|
||||
// this.list = list
|
||||
// return {
|
||||
// list,
|
||||
// source: 'kg',
|
||||
// }
|
||||
async getBoards() {
|
||||
this.list = boardList
|
||||
return {
|
||||
list: boardList,
|
||||
@@ -189,11 +170,9 @@ export default {
|
||||
|
||||
if (body.errcode != 0) return this.getList(bangid, page, retryNum)
|
||||
|
||||
// console.log(body)
|
||||
let total = body.data.total
|
||||
let limit = 100
|
||||
let listData = this.filterData(body.data.info)
|
||||
// console.log(listData)
|
||||
return {
|
||||
total,
|
||||
list: listData,
|
||||
|
||||
+2
-24
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { decodeKrc } from './krcDecode.ts'
|
||||
|
||||
export default {
|
||||
@@ -13,28 +13,6 @@ export default {
|
||||
}
|
||||
return parseInt(intv as unknown as string)
|
||||
},
|
||||
// getLyric(songInfo, tryNum = 0) {
|
||||
// let requestObj = httpFetch(`http://m.kugou.com/app/i/krc.php?cmd=100&keyword=${encodeURIComponent(songInfo.name)}&hash=${songInfo.hash}&timelength=${songInfo._interval || this.getIntv(songInfo.interval)}&d=0.38664927426725626`, {
|
||||
// headers: {
|
||||
// 'KG-RC': 1,
|
||||
// 'KG-THash': 'expand_search_manager.cpp:852736169:451',
|
||||
// 'User-Agent': 'KuGou2012-9020-ExpandSearchManager',
|
||||
// },
|
||||
// })
|
||||
// requestObj.promise = requestObj.promise.then(({ body, statusCode }) => {
|
||||
// if (statusCode !== 200) {
|
||||
// if (tryNum > 5) return Promise.reject(new Error('歌词获取失败'))
|
||||
// let tryRequestObj = this.getLyric(songInfo, ++tryNum)
|
||||
// requestObj.cancelHttp = tryRequestObj.cancelHttp.bind(tryRequestObj)
|
||||
// return tryRequestObj.promise
|
||||
// }
|
||||
// return {
|
||||
// lyric: body,
|
||||
// tlyric: '',
|
||||
// }
|
||||
// })
|
||||
// return requestObj
|
||||
// },
|
||||
searchLyric(name, hash, time, tryNum = 0) {
|
||||
let requestObj = httpFetch(`http://lyrics.kugou.com/search?ver=1&man=yes&client=pc&keyword=${encodeURIComponent(name)}&hash=${hash}&timelength=${time}&lrctxt=1`, {
|
||||
headers: {
|
||||
@@ -92,7 +70,7 @@ export default {
|
||||
|
||||
return requestObj
|
||||
},
|
||||
getLyric(songInfo, tryNum = 0) {
|
||||
getLyric(songInfo) {
|
||||
let requestObj = this.searchLyric(songInfo.name, songInfo.hash, songInfo._interval || this.getIntv(songInfo.interval))
|
||||
|
||||
requestObj.promise = requestObj.promise.then(result => {
|
||||
|
||||
@@ -39,7 +39,6 @@ const createGetMusicInfosTask = (hashs: Array<{ hash: string }>): Array<Promise<
|
||||
}
|
||||
|
||||
export const filterMusicInfoList = (rawList: any[]): SongInfo[] => {
|
||||
// console.log(rawList)
|
||||
let ids = new Set()
|
||||
let list: SongInfo[] = []
|
||||
rawList.forEach(item => {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { decodeName, formatPlayTime, sizeFormate } from '../index.ts'
|
||||
import { formatSingerName } from '../utils.ts'
|
||||
import type { SongType, QualityInfo } from '../types.ts'
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// 上游对应:music-lib/kugou/song.go Parse / kugou.go fetchSongInfo
|
||||
// 元数据 m.kugou.com/app/i/getSongInfo.php(songName/author_name/timeLength/album_img/bitRate)
|
||||
// 另尽力合并 musicInfo.getMusicInfo 的专辑/多档 hash,直链取流失败不影响返回(上游为必得 URL)。
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { formatPlayTime, decodeName } from '../index.ts'
|
||||
import kgApi from '../apis/kg.ts'
|
||||
import { getMusicInfo } from './musicInfo.ts'
|
||||
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
|
||||
export default {
|
||||
getPic(songInfo) {
|
||||
|
||||
+1
-1
@@ -3,7 +3,7 @@
|
||||
// 链接解析优先复用既有 sdk/kg/songList.ts 的 getUserListDetail / getListDetailBySpecialId /
|
||||
// getListInfoByChain / decodeGcid 等能力(覆盖 special/single、songlist/gcid、share chain、
|
||||
// zlist、global_collection_id 等形态),本模块只做统一形状归一。
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import songList from './songList.ts'
|
||||
|
||||
const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1'
|
||||
|
||||
+2
-145
@@ -1,4 +1,4 @@
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { decodeName, formatPlayTime, sizeFormate, dateFormat, formatPlayCount } from '../index.ts'
|
||||
import { toMD5 } from '../utils.ts'
|
||||
import { signatureParams } from './util.ts'
|
||||
@@ -66,51 +66,6 @@ export default {
|
||||
// https://www.kugou.com/yy/special/single/1067062.html
|
||||
listDetailLink: /^.+\/(\d+)\.html(?:\?.*|&.*$|#.*$|$)/,
|
||||
},
|
||||
// async getGlobalSpecialId(specialId) {
|
||||
// return httpFetch(`http://mobilecdnbj.kugou.com/api/v5/special/info?specialid=${specialId}`, {
|
||||
// headers: {
|
||||
// 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HLK-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Mobile Safari/537.36 EdgA/104.0.1293.70',
|
||||
// },
|
||||
// }).promise.then(({ body }) => {
|
||||
// // console.log(body)
|
||||
// if (!body.data.global_specialid) Promise.reject(new Error('Failed to get global collection id.'))
|
||||
// return body.data.global_specialid
|
||||
// })
|
||||
// },
|
||||
// async getListInfoBySpecialId(special_id, retry = 0) {
|
||||
// if (++retry > 2) throw new Error('failed')
|
||||
// return httpFetch(`https://m.kugou.com/plist/list/${special_id}/?json=true`, {
|
||||
// headers: {
|
||||
// 'User-Agent': 'Mozilla/5.0 (Linux; Android 10; HLK-AL00) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/104.0.5112.102 Mobile Safari/537.36 EdgA/104.0.1293.70',
|
||||
// },
|
||||
// follow_max: 2,
|
||||
// }).promise.then(({ body }) => {
|
||||
// // console.log(body)
|
||||
// if (!body.info.list) return this.getListInfoBySpecialId(special_id, retry)
|
||||
// let listinfo = body.info.list
|
||||
// return {
|
||||
// listInfo: {
|
||||
// name: listinfo.specialname,
|
||||
// image: listinfo.imgurl.replace('{size}', '150'),
|
||||
// intro: listinfo.intro,
|
||||
// author: listinfo.nickname,
|
||||
// playcount: listinfo.playcount,
|
||||
// total: listinfo.songcount,
|
||||
// },
|
||||
// globalSpecialId: listinfo.global_specialid,
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
// async getSongListDetailByGlobalSpecialId(id, page, limit = 100, retry = 0) {
|
||||
// if (++retry > 2) throw new Error('failed')
|
||||
// console.log(id)
|
||||
// const params = `specialid=0&need_sort=1&module=CloudMusic&clientver=11409&pagesize=${limit}&global_collection_id=${id}&userid=0&page=${page}&type=1&area_code=1&appid=1005`
|
||||
// return httpFetch(`http://pubsongscdn.tx.kugou.com/v2/get_other_list_file?${params}&signature=${signatureParams(params)}`).promise.then(({ body }) => {
|
||||
// // console.log(body)
|
||||
// if (body.data?.info == null) return this.getSongListDetailByGlobalSpecialId(id, page, limit, retry)
|
||||
// return body.data.info
|
||||
// })
|
||||
// },
|
||||
parseHtmlDesc(html) {
|
||||
const prefix = '<div class="pc_specail_text pc_singer_tab_content" id="specailIntroduceWrap">'
|
||||
let index = html.indexOf(prefix)
|
||||
@@ -148,30 +103,9 @@ export default {
|
||||
name,
|
||||
img: pic,
|
||||
desc,
|
||||
// author: body.result.info.userinfo.username,
|
||||
// play_count: formatPlayCount(body.result.listen_num),
|
||||
},
|
||||
}
|
||||
|
||||
// const globalSpecialId = await this.getGlobalSpecialId(id)
|
||||
// const limit = 100
|
||||
// const listData = await this.getSongListDetailByGlobalSpecialId(globalSpecialId, page, limit)
|
||||
// if (!Array.isArray(listData))
|
||||
// return this.getUserListDetail2(globalSpecialId)
|
||||
// return {
|
||||
// list: this.filterDatav9(listData),
|
||||
// page,
|
||||
// limit,
|
||||
// total: listInfo.total,
|
||||
// source: 'kg',
|
||||
// info: {
|
||||
// name: listInfo.name,
|
||||
// img: listInfo.image,
|
||||
// desc: listInfo.intro,
|
||||
// author: listInfo.author,
|
||||
// play_count: formatPlayCount(listInfo.playcount),
|
||||
// },
|
||||
// }
|
||||
},
|
||||
getInfoUrl(tagId?) {
|
||||
return tagId
|
||||
@@ -276,10 +210,9 @@ export default {
|
||||
try {
|
||||
result = await httpFetch(url, options).promise
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.warn(`[kg] 歌单请求失败将重试(${retryNum + 1}/3) ${url}: ${(err as Error).message}`)
|
||||
return this.createHttp(url, options, ++retryNum)
|
||||
}
|
||||
// console.log(result.statusCode, result.body)
|
||||
if (result.statusCode !== 200 ||
|
||||
(
|
||||
(result.body.error_code !== undefined
|
||||
@@ -349,7 +282,6 @@ export default {
|
||||
},
|
||||
body: { appid: 1001, clientver: 9020, mid: '21511157a05844bd085308bc76ef3343', clienttime: 640612895, key: '36164c4015e704673c588ee202b9ecb8', data: id },
|
||||
})
|
||||
// console.log(songInfo)
|
||||
// type 1单曲,2歌单,3电台,4酷狗码,5别人的播放队列
|
||||
let songList
|
||||
let info = songInfo.info
|
||||
@@ -372,7 +304,6 @@ export default {
|
||||
},
|
||||
body: { appid: 1001, clientver: 9020, mid: '21511157a05844bd085308bc76ef3343', clienttime: 640612895, key: '36164c4015e704673c588ee202b9ecb8', data: { id: info.id, type: 3, userid: info.userid, collect_type: 0, page: 1, pagesize: info.count } },
|
||||
})
|
||||
// console.log(songList)
|
||||
}
|
||||
let list = await this.getMusicInfos(songList || songInfo.list)
|
||||
return {
|
||||
@@ -402,7 +333,6 @@ export default {
|
||||
else return this.getUserListDetail4(songInfo, chain, page).catch(() => this.getUserListDetail5(chain))
|
||||
}
|
||||
let list = await this.getMusicInfos(songInfo.list)
|
||||
// console.log(info, songInfo)
|
||||
return {
|
||||
list,
|
||||
page: 1,
|
||||
@@ -468,7 +398,6 @@ export default {
|
||||
}
|
||||
let result = await Promise.all(tasks).then(([...datas]) => datas.flat())
|
||||
result = await this.getMusicInfos(result)
|
||||
// console.log(result)
|
||||
return {
|
||||
list: result,
|
||||
page,
|
||||
@@ -519,7 +448,6 @@ export default {
|
||||
})
|
||||
const songInfo = await this.createGetListDetail2Task(id, info.songcount)
|
||||
let list = await this.getMusicInfos(songInfo)
|
||||
// console.log(info, songInfo, list)
|
||||
return {
|
||||
list,
|
||||
page: 1,
|
||||
@@ -561,7 +489,6 @@ export default {
|
||||
if (result) result = JSON.parse(result[1])
|
||||
this.cache.set(chain, result)
|
||||
result = await this.getMusicInfos(result)
|
||||
// console.log(info, songInfo)
|
||||
return result
|
||||
},
|
||||
|
||||
@@ -618,9 +545,7 @@ export default {
|
||||
},
|
||||
})
|
||||
|
||||
// console.log(info)
|
||||
let result = await this.getMusicInfos(info.info)
|
||||
// console.log(info, songInfo)
|
||||
return result
|
||||
},
|
||||
|
||||
@@ -655,10 +580,8 @@ export default {
|
||||
})
|
||||
const { headers: { location }, statusCode, body } = await requestObj_listDetailLink.promise
|
||||
const loc = location as string | undefined
|
||||
// console.log(body, location)
|
||||
if (statusCode > 400) return this.getUserListDetail(link, page, ++retryNum)
|
||||
if (loc) {
|
||||
// console.log(location)
|
||||
if (loc.includes('global_collection_id')) return this.getUserListDetail2(loc.replace(/^.*?global_collection_id=(\w+)(?:&.*$|#.*$|$)/, '$1'))
|
||||
if (loc.includes('gcid_')) {
|
||||
let gcid = link.match(/gcid_\w+/)?.[0]
|
||||
@@ -679,7 +602,6 @@ export default {
|
||||
return this.getUserListDetail(link, page, ++retryNum)
|
||||
} else return this.getUserListDetail3(loc.replace(/.+\/(\w+).html(?:\?.*|&.*$|#.*$|$)/, '$1'), page)
|
||||
}
|
||||
// console.log('location', location)
|
||||
return this.getUserListDetail(loc, page, ++retryNum)
|
||||
}
|
||||
if (typeof body == 'string') {
|
||||
@@ -713,7 +635,6 @@ export default {
|
||||
return this.getListDetailBySpecialId(id, page)
|
||||
},
|
||||
filterData(rawList) {
|
||||
// console.log(rawList)
|
||||
return rawList.map(item => {
|
||||
const types: Array<{ type: string; size: string; hash?: string }> = []
|
||||
const _types: Record<string, QualityInfo & { hash?: string }> = {}
|
||||
@@ -766,72 +687,9 @@ export default {
|
||||
}
|
||||
})
|
||||
},
|
||||
// getSinger(singers) {
|
||||
// let arr = []
|
||||
// singers?.forEach(singer => {
|
||||
// arr.push(singer.name)
|
||||
// })
|
||||
// return arr.join('、')
|
||||
// },
|
||||
// v9 API
|
||||
// filterDatav9(rawList) {
|
||||
// console.log(rawList)
|
||||
// return rawList.map(item => {
|
||||
// const types = []
|
||||
// const _types = {}
|
||||
// item.relate_goods.forEach(qualityObj => {
|
||||
// if (qualityObj.level === 2) {
|
||||
// let size = sizeFormate(qualityObj.size)
|
||||
// types.push({ type: '128k', size, hash: qualityObj.hash })
|
||||
// _types['128k'] = {
|
||||
// size,
|
||||
// hash: qualityObj.hash,
|
||||
// }
|
||||
// } else if (qualityObj.level === 4) {
|
||||
// let size = sizeFormate(qualityObj.size)
|
||||
// types.push({ type: '320k', size, hash: qualityObj.hash })
|
||||
// _types['320k'] = {
|
||||
// size,
|
||||
// hash: qualityObj.hash,
|
||||
// }
|
||||
// } else if (qualityObj.level === 5) {
|
||||
// let size = sizeFormate(qualityObj.size)
|
||||
// types.push({ type: 'flac', size, hash: qualityObj.hash })
|
||||
// _types.flac = {
|
||||
// size,
|
||||
// hash: qualityObj.hash,
|
||||
// }
|
||||
// } else if (qualityObj.level === 6) {
|
||||
// let size = sizeFormate(qualityObj.size)
|
||||
// types.push({ type: 'flac24bit', size, hash: qualityObj.hash })
|
||||
// _types.flac24bit = {
|
||||
// size,
|
||||
// hash: qualityObj.hash,
|
||||
// }
|
||||
// }
|
||||
// })
|
||||
// const nameInfo = item.name.split(' - ')
|
||||
// return {
|
||||
// singer: this.getSinger(item.singerinfo),
|
||||
// name: decodeName((nameInfo[1] ?? nameInfo[0]).trim()),
|
||||
// albumName: decodeName(item.albuminfo.name),
|
||||
// albumId: item.albuminfo.id,
|
||||
// songmid: item.audio_id,
|
||||
// source: 'kg',
|
||||
// interval: formatPlayTime(item.timelen / 1000),
|
||||
// img: null,
|
||||
// lrc: null,
|
||||
// hash: item.hash,
|
||||
// types,
|
||||
// _types,
|
||||
// typeUrl: {},
|
||||
// }
|
||||
// })
|
||||
// },
|
||||
|
||||
// hash list filter
|
||||
filterData2(rawList) {
|
||||
// console.log(rawList)
|
||||
let ids = new Set()
|
||||
let list: SongInfo[] = []
|
||||
rawList.forEach(item => {
|
||||
@@ -959,7 +817,6 @@ export default {
|
||||
return httpFetch(`http://msearchretry.kugou.com/api/v3/search/special?keyword=${encodeURIComponent(text)}&page=${page}&pagesize=${limit}&showtype=10&filter=0&version=7910&sver=2`)
|
||||
.promise.then(({ body }) => {
|
||||
if (body.errcode != 0) throw new Error('filed')
|
||||
// console.log(body.data.info)
|
||||
return {
|
||||
list: body.data.info.map(item => {
|
||||
return {
|
||||
|
||||
+2
-4
@@ -1,9 +1,8 @@
|
||||
import { toMD5 } from '../utils.ts'
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import type { HttpOptions } from '../types.ts'
|
||||
|
||||
// s.content[0].lyricContent.forEach(([str]) => {
|
||||
// console.log(str)
|
||||
// })
|
||||
|
||||
/**
|
||||
@@ -32,10 +31,9 @@ export const createHttpFetch = async(url: string, options?: HttpOptions, retryNu
|
||||
try {
|
||||
result = await httpFetch(url, options).promise
|
||||
} catch (err) {
|
||||
console.log(err)
|
||||
console.warn(`[kg] 请求失败将重试(${retryNum + 1}/3) ${url}: ${(err as Error).message}`)
|
||||
return createHttpFetch(url, options, ++retryNum)
|
||||
}
|
||||
// console.log(result.statusCode, result.body)
|
||||
if (result.statusCode !== 200 ||
|
||||
(
|
||||
result.body.error_code ??
|
||||
|
||||
Reference in new issue
Block a user