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

Method get_api_client

src-tauri/src/providers/youtube.rs:179–202  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

177 }
178
179 async fn get_api_client(&self) -> RwLockReadGuard<'_, Option<ApiClient>> {
180 if let Some(expired) = self
181 .api_client
182 .read()
183 .await
184 .as_ref()
185 .map(|api_client| api_client.token_expiry <= Instant::now())
186 {
187 if expired {
188 tracing::info!(
189 "youtube token expired. refreshing {:?}",
190 self.api_client
191 .read()
192 .await
193 .as_ref()
194 .map(|api_client| api_client.token_expiry)
195 );
196
197 let _ = self.refresh_login().await;
198 }
199 }
200
201 self.api_client.read().await
202 }
203
204 #[tracing::instrument(level = "debug", skip(self))]
205 async fn refresh_login(&self) -> Result<()> {

Callers 9

fetch_song_detailsMethod · 0.45
search_playlistsMethod · 0.45
search_artistsMethod · 0.45
fetch_artist_contentMethod · 0.45
fetch_user_playlistsMethod · 0.45
get_playlist_contentMethod · 0.45
searchMethod · 0.45
playlist_from_urlMethod · 0.45
get_suggestionsMethod · 0.45

Calls 1

refresh_loginMethod · 0.45

Tested by

no test coverage detected