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.
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user