From 89f315052b7db0717a66b6711b70791e65a1473d Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Fri, 23 Jan 2026 19:10:37 +0100 Subject: [PATCH] Add pmocache dependency and update cache implementation This commit adds the pmocache dependency to support enhanced caching functionality and updates the cache implementation to use the new cache routing system. It also includes logging improvements for cover fetching operations. --- Cargo.lock | 1 + pmoradiofrance/Cargo.toml | 3 ++- pmoradiofrance/src/playlist.rs | 23 +++++++++++++++++++++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a019320a..241e0e6b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4152,6 +4152,7 @@ dependencies = [ "chrono", "futures", "pmoaudiocache", + "pmocache", "pmoconfig", "pmocovers", "pmodidl", diff --git a/pmoradiofrance/Cargo.toml b/pmoradiofrance/Cargo.toml index 19666ff5..d8bef018 100644 --- a/pmoradiofrance/Cargo.toml +++ b/pmoradiofrance/Cargo.toml @@ -49,6 +49,7 @@ pmodidl = { path = "../pmodidl", optional = true } pmoconfig = { path = "../pmoconfig", optional = true } # Cache support +pmocache = { path = "../pmocache", optional = true } pmocovers = { path = "../pmocovers", optional = true } pmoaudiocache = { path = "../pmoaudiocache", optional = true } @@ -66,7 +67,7 @@ default = ["pmoconfig"] # Feature for pmoconfig support pmoconfig = ["dep:pmoconfig"] # Feature for cache support -cache = ["dep:pmocovers", "dep:pmoaudiocache"] +cache = ["dep:pmocache", "dep:pmocovers", "dep:pmoaudiocache"] # Feature for playlist/FIFO support playlist = ["dep:pmoplaylist", "dep:pmodidl"] # Feature for logging (tracing) diff --git a/pmoradiofrance/src/playlist.rs b/pmoradiofrance/src/playlist.rs index 292c2100..9a01d1d7 100644 --- a/pmoradiofrance/src/playlist.rs +++ b/pmoradiofrance/src/playlist.rs @@ -32,6 +32,8 @@ use crate::models::{ImageSize, LiveResponse, Station, StationType, StreamFormat} use pmodidl::{Item, Resource}; use serde::{Deserialize, Serialize}; +#[cfg(feature = "cache")] +use pmocache::cache_trait::FileCache; #[cfg(feature = "cache")] use pmocovers::Cache as CoverCache; #[cfg(feature = "cache")] @@ -336,6 +338,14 @@ impl StationPlaylist { Self::extract_cover_url(metadata, server_base_url) }; + #[cfg(feature = "logging")] + tracing::debug!( + "Cover for {}: album_art={:?}, album_art_pk={:?}", + station.slug, + album_art, + album_art_pk + ); + // Construction de la ressource (stream) let resource = Self::build_stream_resource(metadata); @@ -496,10 +506,14 @@ impl StationPlaylist { "{}/api/radiofrance/default-logo", base.trim_end_matches('/') ); + #[cfg(feature = "logging")] + tracing::debug!("Using default Radio France logo: {}", logo_url); return (Some(logo_url), None); } // Pas de cover trouvée et pas de serveur configuré + #[cfg(feature = "logging")] + tracing::warn!("No cover found and no server_base_url configured"); (None, None) } @@ -548,8 +562,13 @@ impl StationPlaylist { match cache.add_from_url(&cover_url, Some("radiofrance")).await { Ok(pk) => { // Construire l'URL publique si server_base_url est fourni - let public_url = server_base_url - .map(|base| format!("{}/covers/{}", base.trim_end_matches('/'), pk)); + let public_url = server_base_url.map(|base| { + format!( + "{}{}", + base.trim_end_matches('/'), + cache.route_for(&pk, None) + ) + }); (public_url.or(Some(cover_url)), Some(pk)) }