diff --git a/hifini_music/index.js b/hifini_music/index.js index 85f79f2..4527302 100644 --- a/hifini_music/index.js +++ b/hifini_music/index.js @@ -159,24 +159,22 @@ async function getDetail(threadId) { async function startFetchRealUrl() { let urlsToFetch = await dataManager.thread.getIdsToFetchRealUrl(); // console.log(urlsToFetch.map(item => item.thread_id)); - urlsToFetch = urlsToFetch.map(item => { return { threadId: item.thread_id, fakeUrl: item.music_url } }); for (let i = 0; i < urlsToFetch.length; i++) { const urlToFetch = urlsToFetch[i]; - console.log(`getRealUrl\t| ${i + 1}/${urlsToFetch.length} | threadId: ${urlToFetch.threadId}`); - await getRealUrl(urlToFetch); + console.log(`getRealUrl\t| ${i + 1}/${urlsToFetch.length} | threadId: ${urlToFetch.thread_id} | music_index: ${urlToFetch.music_index}`); + await getRealUrl(urlToFetch.thread_id, urlToFetch.music_index, urlToFetch.music_url); // await sleepUtils.sleep(100); } } -async function getRealUrl(urlToFetch) { - let { threadId, fakeUrl } = urlToFetch; +async function getRealUrl(threadId, musicIndex, fakeUrl) { let url = "原地址已失效"; try { url = await requestUtils.getRedirectUrl(`https://hifini.com/${fakeUrl}`); } catch (e) { console.log("重定向地址获取失败"); } - result = await dataManager.thread.update(threadId, 0, { music_real_url: url }); + result = await dataManager.thread.update(threadId, musicIndex, { music_real_url: url }); } main(); \ No newline at end of file diff --git a/hifini_music/src/dataManager.js b/hifini_music/src/dataManager.js index 5685a67..ff8921f 100644 --- a/hifini_music/src/dataManager.js +++ b/hifini_music/src/dataManager.js @@ -31,7 +31,7 @@ module.exports = { getIdsToFetchRealUrl: async () => { let sql = ` - SELECT thread_id,music_url FROM hifini_thread WHERE music_url like 'get_music.php?key=%' and music_real_url='' + SELECT thread_id,music_index,music_url FROM hifini_thread WHERE music_url like 'get_music.php?key=%' and music_real_url='' ${global.args?.order ? `ORDER BY thread_id ${global.args.order}` : ""} ${global.args?.limit ? `LIMIT ${global.args.limit}` : ""} `;