diff options
Diffstat (limited to 'import/src/trakt.rs')
-rw-r--r-- | import/src/trakt.rs | 55 |
1 files changed, 23 insertions, 32 deletions
diff --git a/import/src/trakt.rs b/import/src/trakt.rs index 52a5cb0..2f8618d 100644 --- a/import/src/trakt.rs +++ b/import/src/trakt.rs @@ -48,7 +48,7 @@ impl Trakt { kinds: &[TraktKind], query: &str, ) -> anyhow::Result<Arc<Vec<TraktSearchResult>>> { - async_cache_memory(&["api-trakt-lookup", query], || async move { + async_cache_memory("api-trakt-lookup", (kinds, query), || async move { let url = format!( "https://api.trakt.tv/search/{}?query={}&extended=full", kinds @@ -66,38 +66,32 @@ impl Trakt { } pub async fn lookup(&self, kind: TraktKind, id: u64) -> anyhow::Result<Arc<TraktMediaObject>> { - async_cache_memory( - &["api-trakt-lookup", &format!("{kind} {id}")], - || async move { - info!("trakt lookup {kind:?}:{id:?}"); - let url = format!("https://api.trakt.tv/{}/{id}?extended=full", kind.plural()); - let res = self.client.get(url).send().await?.error_for_status()?; - Ok(res.json().await?) - }, - ) + async_cache_memory("api-trakt-lookup", (kind, id), || async move { + info!("trakt lookup {kind:?}:{id:?}"); + let url = format!("https://api.trakt.tv/{}/{id}?extended=full", kind.plural()); + let res = self.client.get(url).send().await?.error_for_status()?; + Ok(res.json().await?) + }) .await .context("trakt lookup") } pub async fn people(&self, kind: TraktKind, id: u64) -> anyhow::Result<Arc<TraktPeople>> { - async_cache_memory( - &["api-trakt-people", &format!("{kind} {id}")], - || async move { - info!("trakt people {kind:?}:{id:?}"); - let url = format!( - "https://api.trakt.tv/{}/{id}/people?extended=full", - kind.plural() - ); - let res = self.client.get(url).send().await?.error_for_status()?; - Ok(res.json().await?) - }, - ) + async_cache_memory("api-trakt-people", (kind, id), || async move { + info!("trakt people {kind:?}:{id:?}"); + let url = format!( + "https://api.trakt.tv/{}/{id}/people?extended=full", + kind.plural() + ); + let res = self.client.get(url).send().await?.error_for_status()?; + Ok(res.json().await?) + }) .await .context("trakt people") } pub async fn show_seasons(&self, id: u64) -> anyhow::Result<Arc<Vec<TraktSeason>>> { - async_cache_memory(&["api-trakt-seasons", &id.to_string()], || async move { + async_cache_memory("api-trakt-seasons", id, || async move { info!("trakt seasons {id:?}"); let url = format!("https://api.trakt.tv/shows/{id}/seasons?extended=full"); let res = self.client.get(url).send().await?.error_for_status()?; @@ -112,15 +106,12 @@ impl Trakt { id: u64, season: usize, ) -> anyhow::Result<Arc<Vec<TraktEpisode>>> { - async_cache_memory( - &["api-trakt-episodes", &id.to_string(), &season.to_string()], - || async move { - info!("trakt episodes {id:?} season={season}"); - let url = format!("https://api.trakt.tv/shows/{id}/seasons/{season}?extended=full"); - let res = self.client.get(url).send().await?.error_for_status()?; - Ok(res.json().await?) - }, - ) + async_cache_memory("api-trakt-episodes", (id, season), || async move { + info!("trakt episodes {id:?} season={season}"); + let url = format!("https://api.trakt.tv/shows/{id}/seasons/{season}?extended=full"); + let res = self.client.get(url).send().await?.error_for_status()?; + Ok(res.json().await?) + }) .await .context("trakt show season episodes") } |