fix(users/Profpatsch/lyrics): remove special chars from search

Leaving out any symbol characters improves the search accuracy.

Change-Id: I00c993d4099bb8e9701783b53afc9423f1b2f674
Reviewed-on: https://cl.tvl.fyi/c/depot/+/12480
Reviewed-by: Profpatsch <mail@profpatsch.de>
Tested-by: BuildkiteCI
This commit is contained in:
Profpatsch 2024-09-14 15:56:54 +02:00
parent ffdcb3bb5e
commit 970dcaa04f

View file

@ -1,5 +1,11 @@
-- get_lrc_subtitles.lua
-- Function to remove Unicode symbol characters
function remove_symbols(str)
-- This pattern matches anything that is not a letter, digit, or whitespace
return str:gsub("[%p%c%z]", "") -- remove punctuation, control, and zero-width characters
end
-- Asynchronous callback function to handle the result of the 'get_subtitles' command
function handle_subtitle_result(success, result)
if not success or result.status ~= 0 then
@ -41,6 +47,9 @@ function load_lrc_subtitles()
-- Concatenate the metadata
local query = string.format("%s %s %s", artist, album, title)
-- Remove Unicode symbols from the query string
query = remove_symbols(query)
-- Create the command array
local cmd = {"@get_subtitles_command@", query}