blob: 962a62721a6ceffc5acd7fc6ddaa7e49d6cfc2ba (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
# 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,
source,
t.name,
t.artist_name
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"
".[0].synced_lyrics"
]
|