Skip to content

Commit

Permalink
1.6.1-patch4
Browse files Browse the repository at this point in the history
  • Loading branch information
axellse committed Sep 27, 2024
1 parent 9a4be61 commit 4c6ca92
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 20 deletions.
50 changes: 33 additions & 17 deletions helpers/core/commandProcessor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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!`)
Expand Down
2 changes: 1 addition & 1 deletion helpers/misc/discordRpc.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
})
Expand Down
3 changes: 2 additions & 1 deletion installConfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,6 @@
"discordRpcEnabled": true,
"useWinIconLauncher": "notSure",
"fps": 5,
"memorySavingMode": false
"memorySavingMode": false,
"queueCommaSeperation" : false
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 4c6ca92

Please sign in to comment.