feat(sync_music): 添加同步歌曲时的详细日志记录

在sync_single_song_with_url.js中添加详细的日志记录,包括开始同步时的参数、TuneHub参数解析结果、下载URL以及歌曲信息获取状态。这有助于调试和追踪同步过程中的问题。
This commit is contained in:
史悦
2026-01-08 14:55:03 +08:00
parent 76003d4bcd
commit 288016a95f

View File

@@ -101,26 +101,38 @@ module.exports = async function syncSingleSongWithUrl(uid, url, {
album = "",
songFromWyCloud = null
} = {}, jobId = 0, jobType = JobType.SyncSongFromUrl, playlistName = "", collectRet) {
logger.info(`[syncSingleSongWithUrl] ===== Start =====`);
logger.info(`[syncSingleSongWithUrl] uid=${uid}, url=${url}, songName=${songName}, artist=${artist}, album=${album}`);
logger.info(`[syncSingleSongWithUrl] jobId=${jobId}, jobType=${jobType}`);
// step 1. fetch song info
let songInfo = null;
let downloadUrl = url;
let useTunehubDownload = false;
const tunehubParams = parseTunehubParams(url) || parsePageUrlParams(url);
logger.info(`[syncSingleSongWithUrl] tunehubParams=${JSON.stringify(tunehubParams)}`);
if (tunehubParams) {
logger.info(`[syncSingleSongWithUrl] Using TuneHub for ${tunehubParams.source}:${tunehubParams.id}`);
useTunehubDownload = true;
downloadUrl = buildSongUrl(tunehubParams.source, tunehubParams.id);
logger.info(`[syncSingleSongWithUrl] downloadUrl=${downloadUrl}`);
const tunehubInfo = await getSongInfo(tunehubParams.source, tunehubParams.id);
if (tunehubInfo) {
songInfo = buildSongInfoFromTunehub(tunehubParams.source, tunehubInfo);
logger.info(`[syncSingleSongWithUrl] TuneHub success: ${songInfo.songName} - ${songInfo.artist}`);
} else if (tunehubParams.source === 'netease') {
const wyInfo = await getWySongInfo(uid, tunehubParams.id);
if (wyInfo) {
songInfo = buildSongInfoFromWyCloud(wyInfo);
logger.info(`[syncSingleSongWithUrl] WyCloud success: ${songInfo.songName} - ${songInfo.artist}`);
}
}
}
if (!songInfo) {
if (!tunehubParams) {
logger.error(`[syncSingleSongWithUrl] ERROR: URL not recognized, cannot parse params. url=${url}`);
logger.info(`[syncSingleSongWithUrl] Will call getMetaWithUrl (deprecated - may fail with media-get)`);
songInfo = await getMetaWithUrl(url);
logger.info(songInfo);
if (songInfo === false || songInfo.isTrial) {
@@ -128,6 +140,7 @@ module.exports = async function syncSingleSongWithUrl(uid, url, {
return false;
}
} else {
logger.info(`[syncSingleSongWithUrl] TuneHub failed, using fallback with provided metadata`);
songInfo = buildFallbackSongInfo({
songName,
artist,