(song: &Option<Song>)
| 122 | } |
| 123 | |
| 124 | pub 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 | } |
no test coverage detected