From 4c6ca92db1f40b620754a2f327330b73282c5c68 Mon Sep 17 00:00:00 2001 From: axellse Date: Fri, 27 Sep 2024 21:56:13 +0200 Subject: [PATCH] 1.6.1-patch4 --- helpers/core/commandProcessor.js | 50 +++++++++++++++++++++----------- helpers/misc/discordRpc.js | 2 +- installConfig.json | 3 +- package.json | 2 +- 4 files changed, 37 insertions(+), 20 deletions(-) diff --git a/helpers/core/commandProcessor.js b/helpers/core/commandProcessor.js index ef23d27..1479aa8 100644 --- a/helpers/core/commandProcessor.js +++ b/helpers/core/commandProcessor.js @@ -87,29 +87,45 @@ export async function processCommand(command) { break case 'queue' : if (command.split(" ")[1] == "add") { - setPlayStatus("log", "Searching...") - let searchResult = await search(command.replace("queue add ", "")) - let searchType = config['searchEngine'] + let queries = [] - if (searchResult['status'] && searchResult['status'] == 'typeIssue') { - setPlayStatus("log", "Searching again...") - searchResult = await search(searchResult['query']) + if (config['queueCommaSeperation'] && command.replace("queue add ", "").split(',').length > 0) { + queries = command.replace("queue add ", "").split(',') + } else { + queries = [command.replace("queue add ", "")] } - while (!searchResult) { - if (searchType == 'youtube') { - setPlayStatus("log", "Falling back to invidious api") - searchType = 'invidious' - search = getSearchFunction(searchType) - searchResult = await search(command.replace("play ", "")) - } else { - setPlayStatus("log", "Retrying search.") - searchResult = await search(command.replace("play ", "")) + for (let i = 0; i < queries.length; i++) { + setPlayStatus("log", "Searching...") + let searchResult = await search(queries[i]) + let searchType = config['searchEngine'] + + if (searchResult['status'] && searchResult['status'] == 'typeIssue') { + setPlayStatus("log", "Searching again...") + searchResult = await search(searchResult['query']) + } + + while (!searchResult) { + if (searchType == 'youtube') { + setPlayStatus("log", "Falling back to invidious api") + searchType = 'invidious' + search = getSearchFunction(searchType) + searchResult = await search(command.replace("play ", "")) + } else { + setPlayStatus("log", "Retrying search.") + searchResult = await search(command.replace("play ", "")) + } + } + addSong(searchResult) + + if (queries.length == 1) { + setPlayStatus("important", `Added ${searchResult["title"]} to the queue!`) } } - addSong(searchResult) - setPlayStatus("important", `Added ${searchResult["title"]} to the queue!`) + if (queries.length > 1) { + setPlayStatus("important", `Added ${queries.length} songs to the queue!`) + } } else if (command.split(" ")[1] == "remove") { removeLastSong() setPlayStatus('important', `Removed last song from the queue!`) diff --git a/helpers/misc/discordRpc.js b/helpers/misc/discordRpc.js index c70d833..d2bbee8 100644 --- a/helpers/misc/discordRpc.js +++ b/helpers/misc/discordRpc.js @@ -12,7 +12,7 @@ if (process.argv[2]?.includes('launch') && config['discordRpcEnabled']) { ep.on('connected', () => { setPlayStatus('important', 'Connected to Discord.') setTimeout(() => { - if (!lastActivity) return + if (!lastActivity?.['title']) return setPlayStatus("report", lastActivity) }, 500) //wait a little before starting discordrpc }) diff --git a/installConfig.json b/installConfig.json index bb6a0f0..642c21a 100644 --- a/installConfig.json +++ b/installConfig.json @@ -13,5 +13,6 @@ "discordRpcEnabled": true, "useWinIconLauncher": "notSure", "fps": 5, - "memorySavingMode": false + "memorySavingMode": false, + "queueCommaSeperation" : false } \ No newline at end of file diff --git a/package.json b/package.json index 9d63aff..13187eb 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "termusic", - "version": "1.6.1-patch3", + "version": "1.6.1-patch4", "description": "a music player inside your terminal", "main": "termusic.js", "bin": {