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
@@ -5,7 +5,7 @@
|
||||
// 兜底:www.joox.com/<region>/album/<id> SSR __NEXT_DATA__.props.pageProps.albumData(上游做法,需 X-Forwarded-For)
|
||||
// 链接解析:ParseAlbum 的正则与裸 ID 规则同上游。
|
||||
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import {
|
||||
jooxHeaders,
|
||||
jooxSign,
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@
|
||||
// 解码:base64 → UTF-8 → HTML 实体(& 等)→ { lyric, tlyric: '' }
|
||||
// 统一接口约定:{ promise, cancelHttp };promise resolve → { lyric, tlyric }
|
||||
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { jooxHeaders, decodeJooxLyric, normalizeJooxID, firstNonEmpty } from './util.ts'
|
||||
import { buildTrackUrl } from './musicInfo.ts'
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
// 返回体含 play_url_list / refrain_url / lrc_content(base64) / qrc_content(base64) /
|
||||
// has_hq / has_hifi / vip_flag / node_is_preview 等。
|
||||
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import {
|
||||
jooxHeaders,
|
||||
jooxSign,
|
||||
|
||||
@@ -4,13 +4,13 @@
|
||||
// 该接口无分页参数(上游也未分页),page 参数仅为统一契约保留;allPage 恒为 1。
|
||||
// 实测(2026-10-02):英文/中文关键词均 HTTP 200。
|
||||
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { jooxHeaders } from './util.ts'
|
||||
import { jooxSongFromSearch } from './song.ts'
|
||||
|
||||
const SEARCH_URL = 'https://cache.api.joox.com/openjoox/v3/search'
|
||||
|
||||
export const search = async(keyword: string, page = 1, limit = 20) => {
|
||||
export const search = async(keyword: string, _page = 1, limit = 20) => {
|
||||
const url = `${SEARCH_URL}?country=sg&lang=zh_cn&keyword=${encodeURIComponent(String(keyword ?? ''))}`
|
||||
const { statusCode, body } = await httpFetch(url, { headers: jooxHeaders(), timeout: 20000 }).promise as any
|
||||
if (statusCode != 200 || !body?.section_list) {
|
||||
|
||||
+2
-2
@@ -6,8 +6,8 @@
|
||||
import { normalizeJooxID } from './util.ts'
|
||||
import { getTrackDetail, pickTrackUrl } from './musicInfo.ts'
|
||||
import { jooxSongFromDetail } from './song.ts'
|
||||
import { getAlbumDetail, parseAlbum } from './album.ts'
|
||||
import { getPlaylistDetail, parsePlaylist } from './playlist.ts'
|
||||
import { parseAlbum } from './album.ts'
|
||||
import { parsePlaylist } from './playlist.ts'
|
||||
|
||||
/** 歌曲链接 → Song(上游 Parse 的正则与裸 ID 规则) */
|
||||
export const parseSong = async(link: string) => {
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
// 分类:www.joox.com/sg/playlist(302 → /<region> 首页)__NEXT_DATA__.props.pageProps.mlList
|
||||
// 链接解析:joox.com/{region}/playlist/<id>、playlistid/id 查询参数、裸 ID
|
||||
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import {
|
||||
jooxHeaders,
|
||||
jooxSign,
|
||||
|
||||
+1
-1
@@ -11,7 +11,7 @@
|
||||
// 在签名参数里作为 uid/usk 参与(可拿到完整曲目/更高档位)。
|
||||
|
||||
import crypto from 'node:crypto'
|
||||
import { httpFetch } from '../request.ts'
|
||||
import { httpFetch } from '../common/request.ts'
|
||||
import { getCredentials } from '../auth/store.ts'
|
||||
|
||||
export const JOOX_UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/139.0.0.0 Safari/537.36'
|
||||
|
||||
Reference in new issue
Block a user