1
0
Fork 0
mirror of https://github.com/Reuh/daccord.git synced 2025-10-27 12:49:30 +00:00

Filename search

This commit is contained in:
Étienne Fildadut 2018-06-08 19:27:06 +02:00
parent 8415d9e7d4
commit 869e8cdd39

View file

@ -64,6 +64,8 @@ let config = {
host = "localhost", host = "localhost",
port = 6600, port = 6600,
password = "", password = "",
-- Default behaviour
filenameSearch = false, -- instant search search also in filename (not only tags), slower
-- Interface -- Interface
songDisplay = { "Track", { "Title", "file" }, "Artist", "Album" } -- list of tags or list of alternative tags (first one to exist will be used) to display for each song songDisplay = { "Track", { "Title", "file" }, "Artist", "Album" } -- list of tags or list of alternative tags (first one to exist will be used) to display for each song
} }
@ -188,6 +190,32 @@ gui {
let r, songs = mpc:search(unpack(query)) let r, songs = mpc:search(unpack(query))
if r then results = songs end if r then results = songs end
-- Filename search
if config.filenameSearch then
for i=1, #query, 2 do
if query[i] == "any" then
query[i] = "file"
end
end
let r, songs = mpc:search(unpack(query))
if r then
-- Merge
for _, newSong in ipairs(songs) do
let found = false
for _, existingSong in ipairs(results) do
if newSong.file == existingSong.file then
found = true
break
end
end
if not found then
table.insert(results, newSong)
end
end
end
end
-- Update widget -- Update widget
for _, s in ipairs(results) do for _, s in ipairs(results) do
list:insert(songTable(s)) list:insert(songTable(s))