MCPcopy Create free account
hub / github.com/Moosync/Moosync / get_lyrics

Function get_lyrics

src-tauri/src/lyrics/mod.rs:34–56  ·  view source on GitHub ↗
(
    lyrics: State<'_, LyricsFetcher>,
    librespot: State<'_, LibrespotHolder>,
    cache: State<'_, CacheHolder>,
    id: String,
    url: String,
    artists: Vec<String>,
    title: String,
)

Source from the content-addressed store, hash-verified

32#[tauri_invoke_proc::parse_tauri_command]
33#[tauri::command()]
34pub async fn get_lyrics(
35 lyrics: State<'_, LyricsFetcher>,
36 librespot: State<'_, LibrespotHolder>,
37 cache: State<'_, CacheHolder>,
38 id: String,
39 url: String,
40 artists: Vec<String>,
41 title: String,
42) -> Result<String> {
43 let cache_string = format!("get_lyrics_{}_{}_{:?}_{}", id, url, artists, title);
44
45 let cached = cache.get(&cache_string);
46 if cached.is_ok() {
47 return cached;
48 }
49
50 let res = lyrics
51 .get_lyrics(librespot.inner(), id, url, artists, title)
52 .await?;
53
54 let _ = cache.set(cache_string.as_str(), &res, 7200);
55 Ok(res)
56}

Callers 1

fetch_lyricsFunction · 0.50

Calls 3

getMethod · 0.80
setMethod · 0.80
get_lyricsMethod · 0.45

Tested by

no test coverage detected