feat(handler): 为歌曲处理添加日志记录
在buildPageUrl和mapTunehubResult函数中添加日志记录,方便追踪URL生成过程 在search函数中添加日志记录搜索结果和过滤项
This commit is contained in:
@@ -7,19 +7,26 @@ function buildPageUrl(source, songId) {
|
|||||||
if (!source || !songId) {
|
if (!source || !songId) {
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
logger.info(`[buildPageUrl] source=${source}, songId=${songId}`);
|
||||||
// 使用 TuneHub 格式的页面 URL
|
// 使用 TuneHub 格式的页面 URL
|
||||||
if (source === 'netease') {
|
if (source === 'netease') {
|
||||||
return `https://music-dl.sayqz.com/?source=${source}&id=${songId}`;
|
const url = `https://music-dl.sayqz.com/?source=${source}&id=${songId}`;
|
||||||
|
logger.info(`[buildPageUrl] Generated TuneHub URL: ${url}`);
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
if (source === 'qq') {
|
if (source === 'qq') {
|
||||||
return `https://music-dl.sayqz.com/?source=${source}&id=${songId}`;
|
const url = `https://music-dl.sayqz.com/?source=${source}&id=${songId}`;
|
||||||
|
logger.info(`[buildPageUrl] Generated TuneHub URL: ${url}`);
|
||||||
|
return url;
|
||||||
}
|
}
|
||||||
|
logger.warn(`[buildPageUrl] Unknown source: ${source}`);
|
||||||
return '';
|
return '';
|
||||||
}
|
}
|
||||||
|
|
||||||
function mapTunehubResult(item) {
|
function mapTunehubResult(item) {
|
||||||
const playUrl = item.url || buildSongUrl(item.platform, item.id);
|
const playUrl = item.url || buildSongUrl(item.platform, item.id);
|
||||||
const pageUrl = buildPageUrl(item.platform, item.id);
|
const pageUrl = buildPageUrl(item.platform, item.id);
|
||||||
|
logger.info(`[mapTunehubResult] item=${JSON.stringify(item)}, pageUrl=${pageUrl}, playUrl=${playUrl}`);
|
||||||
return {
|
return {
|
||||||
songId: item.id || '',
|
songId: item.id || '',
|
||||||
songName: item.name || '',
|
songName: item.name || '',
|
||||||
@@ -92,9 +99,11 @@ async function search(req, res) {
|
|||||||
|
|
||||||
const globalConfig = await configManager.getGlobalConfig();
|
const globalConfig = await configManager.getGlobalConfig();
|
||||||
const enabledSources = globalConfig && Array.isArray(globalConfig.sources) ? globalConfig.sources : [];
|
const enabledSources = globalConfig && Array.isArray(globalConfig.sources) ? globalConfig.sources : [];
|
||||||
|
logger.info(`[search] searchData.results = ${JSON.stringify(searchData.results, null, 2)}`);
|
||||||
const songs = searchData.results
|
const songs = searchData.results
|
||||||
.filter(item => {
|
.filter(item => {
|
||||||
if (!item.platform) {
|
if (!item.platform) {
|
||||||
|
logger.warn(`[search] Filtered out item without platform: ${JSON.stringify(item)}`);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (enabledSources.length === 0) {
|
if (enabledSources.length === 0) {
|
||||||
|
|||||||
Reference in New Issue
Block a user