feat: migrate ChKSz API and support API key authentication

This commit is contained in:
Jocay
2026-10-10 20:22:49 +08:00
parent 480233f01b
commit 5bd62645ab
13 changed files with 82 additions and 49 deletions
+2 -2
View File
@@ -1,6 +1,6 @@
const fs = require('fs');
const path = require('path');
const { API, DEFAULT_RETRIES, DOWNLOAD_DIR } = require('./config');
const { API, DEFAULT_RETRIES, DOWNLOAD_DIR, buildApiUrl } = require('./config');
const { addHistory } = require('./history');
const { fetchLyric, mergeLrc, parseCredits } = require('./lyrics');
const { fetchNeteaseAlbumDetail, fetchNeteaseSongDetail } = require('./metadata');
@@ -39,7 +39,7 @@ async function downloadSongOnce(songId, level, {
outputBaseName = null,
} = {}) {
console.log(`\n🎵 解析歌曲 ID: ${songId} ...`);
const result = await fetchJSON(`${API.music}?id=${songId}&level=${level}`);
const result = await fetchJSON(buildApiUrl(API.music, { id: songId, level }));
if (result.code !== 200 || !result.data?.url) throw new Error(result.msg || 'API 返回错误');
const { name, artist: rawArtist, album, url: audioUrl, br, size, level: actualLevel, picUrl } = result.data;