aboutsummaryrefslogtreecommitdiff
path: root/import
diff options
context:
space:
mode:
Diffstat (limited to 'import')
-rw-r--r--import/src/tmdb.rs33
-rw-r--r--import/src/trakt.rs2
2 files changed, 19 insertions, 16 deletions
diff --git a/import/src/tmdb.rs b/import/src/tmdb.rs
index 219c1f6..3d6e832 100644
--- a/import/src/tmdb.rs
+++ b/import/src/tmdb.rs
@@ -5,7 +5,7 @@
*/
use crate::USER_AGENT;
use anyhow::{anyhow, bail, Context, Result};
-use jellycache::{cache_memory, cache_store, HashKey};
+use jellycache::{cache_memory, cache_store, EscapeKey, HashKey};
use jellycommon::{
chrono::{format::Parsed, Utc},
Asset,
@@ -108,20 +108,23 @@ impl Tmdb {
.context("tmdb person images")
}
pub fn image(&self, path: &str, rt: &Handle) -> Result<Asset> {
- cache_store(format!("ext/tmdb/image/{path}.json"), move || {
- rt.block_on(async {
- info!("downloading image {path:?}");
- Ok(self
- .image_client
- .get(format!("https://image.tmdb.org/t/p/original{path}"))
- .send()
- .await?
- .error_for_status()?
- .bytes()
- .await?
- .to_vec())
- })
- })
+ cache_store(
+ format!("ext/tmdb/image/{}.image", EscapeKey(path)),
+ move || {
+ rt.block_on(async {
+ info!("downloading image {path:?}");
+ Ok(self
+ .image_client
+ .get(format!("https://image.tmdb.org/t/p/original{path}"))
+ .send()
+ .await?
+ .error_for_status()?
+ .bytes()
+ .await?
+ .to_vec())
+ })
+ },
+ )
.context("tmdb image download")
.map(Asset)
}
diff --git a/import/src/trakt.rs b/import/src/trakt.rs
index a241725..270c589 100644
--- a/import/src/trakt.rs
+++ b/import/src/trakt.rs
@@ -101,7 +101,7 @@ impl Trakt {
}
pub fn show_seasons(&self, id: u64, rt: &Handle) -> Result<Arc<Vec<TraktSeason>>> {
- cache_memory(&format!("ext/trakt/seasons/{id}"), move || {
+ cache_memory(&format!("ext/trakt/seasons/{id}.json"), move || {
rt.block_on(async {
info!("trakt seasons {id:?}");
let url = format!("https://api.trakt.tv/shows/{id}/seasons?extended=full");