Lyrics providers
A lyrics provider searches for the lyrics of a song. Nari asks every provider that’s on, ranks the hits against the song and shows the best one.
nari.lyrics_provider({ id = "my_lyrics", -- unique id, stored in the lyrics settings name = "My Lyrics", -- shown in Settings → Lyrics → Lyrics provider trust = 0, -- tie breaker when ranking results from different providers online = true, -- false for providers that don't use the network color = "#c58af9", -- log color search = function(provider, song, done) nari.http({ url = "https://example.com/lyrics?q=" .. song.title }, function(response) if not response or response.status ~= 200 then return done({}) end local lyrics = LyricsParser.parse(response.body, "online_lrc", song.duration, "lrc") done({ provider:hit(lyrics, song.title, song.artist, song.album, song.duration) }) end) end,})New providers start off: users turn them on in Settings → Lyrics → Lyrics provider.
Searching
Section titled “Searching”search(provider, song, done) gives back a list of hits, either by returning it right away or by calling
done(list) later. If done isn’t called within 20 seconds, the search counts as empty.
LyricsParser.parse(text, source, duration_ms, extension)turns LRC ("lrc"), plain text ("txt") or TTML ("ttml") into Nari’s lyrics.provider:hit(lyrics, title, artist, album, duration_ms, instrumental)wraps them into a hit. Nari uses the title, artist, album and duration to rank hits against the song.LyricsProvider.rebuilt(lines, source, provider_name, language)builds lyrics from your own lines (seesystems/lyrics/lyrics_parser.gdin Nari’s code for the line format).