From b93e1598e6acba4e18e808dc5fac5b954925ce9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=A8=8B=E5=BA=8F=E5=91=98=E5=B0=8F=E5=A2=A8?= <2291200076@qq.com> Date: Sat, 29 Oct 2022 14:40:58 +0800 Subject: [PATCH] =?UTF-8?q?hifini=20=E6=B7=BB=E5=8A=A0=20order=20limit=20?= =?UTF-8?q?=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- hifini_music/auto desc.bat | 2 ++ hifini_music/auto.bat | 2 +- hifini_music/index.js | 5 +++++ hifini_music/src/dataManager.js | 16 ++++++++++++++-- 4 files changed, 22 insertions(+), 3 deletions(-) create mode 100644 hifini_music/auto desc.bat diff --git a/hifini_music/auto desc.bat b/hifini_music/auto desc.bat new file mode 100644 index 0000000..0f42a1d --- /dev/null +++ b/hifini_music/auto desc.bat @@ -0,0 +1,2 @@ +start cmd /k "node index --order DESC --limit 200" +exit \ No newline at end of file diff --git a/hifini_music/auto.bat b/hifini_music/auto.bat index 9ceca01..a02e684 100644 --- a/hifini_music/auto.bat +++ b/hifini_music/auto.bat @@ -1,2 +1,2 @@ -start cmd /k "node index" +start cmd /k "node index --order ASC --limit 200" exit \ No newline at end of file diff --git a/hifini_music/index.js b/hifini_music/index.js index 4efa4e1..85f79f2 100644 --- a/hifini_music/index.js +++ b/hifini_music/index.js @@ -14,6 +14,11 @@ const dataManager = require('./src/dataManager'); const requestUtils = require('../utils/requestUtils'); async function main() { + var args = require('minimist')(process.argv.slice(2)); + global.args = { + "order": args.order, + "limit": args.limit, + } // async function timeout1() { // await getList(); // setTimeout(() => console.log("getList已完成"), 2000); diff --git a/hifini_music/src/dataManager.js b/hifini_music/src/dataManager.js index 546a41b..5685a67 100644 --- a/hifini_music/src/dataManager.js +++ b/hifini_music/src/dataManager.js @@ -20,11 +20,23 @@ module.exports = { }, getIdsToFetch: async () => { - return await dbUtils.query(`SELECT thread_id FROM hifini_thread where music_title='' and music_pic='' and music_url=''`); + let sql = ` + SELECT thread_id FROM hifini_thread WHERE music_title='' and music_pic='' and music_url='' + ${global.args?.order ? `ORDER BY thread_id ${global.args.order}` : ""} + ${global.args?.limit ? `LIMIT ${global.args.limit}` : ""} + `; + console.log(sql); + return await dbUtils.query(sql); }, getIdsToFetchRealUrl: async () => { - return await dbUtils.query(`SELECT thread_id,music_url FROM hifini_thread where music_url like 'get_music.php?key=%' and music_real_url=''`); + let sql = ` + SELECT thread_id,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}` : ""} + `; + console.log(sql); + return await dbUtils.query(sql); } },