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

Function fetch_lyrics

src/utils/songs.rs:124–151  ·  view source on GitHub ↗
(song: &Option<Song>)

Source from the content-addressed store, hash-verified

122}
123
124pub async fn fetch_lyrics(song: &Option<Song>) -> Option<String> {
125 tracing::debug!("Fetching lyrics");
126 if let Some(song) = song {
127 let lyrics = song.song.lyrics.clone();
128 if lyrics.is_none() {
129 let res = get_lyrics(
130 song.song._id.clone().unwrap_or_default(),
131 song.song.playback_url.clone().unwrap_or_default(),
132 song.artists
133 .clone()
134 .unwrap_or_default()
135 .iter()
136 .map(|a| a.artist_name.clone().unwrap_or_default())
137 .collect::<Vec<String>>(),
138 song.song.title.clone().unwrap_or_default(),
139 )
140 .await;
141 if let Ok(lyrics) = res {
142 return Some(lyrics);
143 } else {
144 tracing::error!("Failed to fetch lyrics: {:?}", res.unwrap_err());
145 }
146 }
147 return lyrics;
148 }
149
150 None
151}

Callers 2

MusicInfoMobileFunction · 0.85
SongDetailsFunction · 0.85

Calls 2

cloneMethod · 0.80
get_lyricsFunction · 0.50

Tested by

no test coverage detected