2024-09-13 15:08:31 +02:00
|
|
|
# Display lyrics for the given search string;
|
|
|
|
# search string can contain a substring of band name, album name, song title
|
|
|
|
#
|
|
|
|
# Use the database dump from https://lrclib.net/db-dumps and place it in ~/.cache/lyric/lrclib-db-dump.sqlite3
|
|
|
|
|
|
|
|
{ depot, pkgs, lib, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
bins = depot.nix.getBins pkgs.sqlite-utils [ "sqlite-utils" ]
|
|
|
|
// depot.nix.getBins pkgs.jq [ "jq" ];
|
|
|
|
|
|
|
|
in
|
|
|
|
depot.nix.writeExecline "lyric" { readNArgs = 1; } [
|
|
|
|
"backtick"
|
|
|
|
"-E"
|
|
|
|
"cache"
|
|
|
|
[ depot.users.Profpatsch.xdg-cache-home ]
|
|
|
|
"pipeline"
|
|
|
|
[
|
|
|
|
bins.sqlite-utils
|
|
|
|
"query"
|
|
|
|
"\${cache}/lyric/lrclib-db-dump.sqlite3"
|
|
|
|
''
|
|
|
|
select
|
|
|
|
synced_lyrics,
|
2024-09-13 15:29:31 +02:00
|
|
|
has_synced_lyrics,
|
|
|
|
plain_lyrics
|
2024-09-13 15:08:31 +02:00
|
|
|
from
|
|
|
|
tracks_fts(:searchstring) tf
|
|
|
|
join tracks t on t.rowid = tf.rowid
|
|
|
|
join lyrics l on t.rowid = l.track_id
|
|
|
|
order by
|
|
|
|
t.id
|
|
|
|
limit
|
|
|
|
1
|
|
|
|
''
|
|
|
|
"--param"
|
|
|
|
"searchstring"
|
|
|
|
"$1"
|
|
|
|
]
|
|
|
|
bins.jq
|
|
|
|
"-r"
|
2024-09-13 15:29:31 +02:00
|
|
|
''
|
|
|
|
if .[0] == null
|
|
|
|
then ""
|
|
|
|
else
|
|
|
|
.[0]
|
|
|
|
| if .has_synced_lyrics == 1
|
|
|
|
then .synced_lyrics
|
|
|
|
else .plain_lyrics
|
|
|
|
end
|
|
|
|
end
|
|
|
|
''
|
2024-09-13 15:08:31 +02:00
|
|
|
]
|