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:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -4152,6 +4152,7 @@ dependencies = [
|
|||||||
"chrono",
|
"chrono",
|
||||||
"futures",
|
"futures",
|
||||||
"pmoaudiocache",
|
"pmoaudiocache",
|
||||||
|
"pmocache",
|
||||||
"pmoconfig",
|
"pmoconfig",
|
||||||
"pmocovers",
|
"pmocovers",
|
||||||
"pmodidl",
|
"pmodidl",
|
||||||
|
|||||||
@@ -49,6 +49,7 @@ pmodidl = { path = "../pmodidl", optional = true }
|
|||||||
pmoconfig = { path = "../pmoconfig", optional = true }
|
pmoconfig = { path = "../pmoconfig", optional = true }
|
||||||
|
|
||||||
# Cache support
|
# Cache support
|
||||||
|
pmocache = { path = "../pmocache", optional = true }
|
||||||
pmocovers = { path = "../pmocovers", optional = true }
|
pmocovers = { path = "../pmocovers", optional = true }
|
||||||
pmoaudiocache = { path = "../pmoaudiocache", optional = true }
|
pmoaudiocache = { path = "../pmoaudiocache", optional = true }
|
||||||
|
|
||||||
@@ -66,7 +67,7 @@ default = ["pmoconfig"]
|
|||||||
# Feature for pmoconfig support
|
# Feature for pmoconfig support
|
||||||
pmoconfig = ["dep:pmoconfig"]
|
pmoconfig = ["dep:pmoconfig"]
|
||||||
# Feature for cache support
|
# Feature for cache support
|
||||||
cache = ["dep:pmocovers", "dep:pmoaudiocache"]
|
cache = ["dep:pmocache", "dep:pmocovers", "dep:pmoaudiocache"]
|
||||||
# Feature for playlist/FIFO support
|
# Feature for playlist/FIFO support
|
||||||
playlist = ["dep:pmoplaylist", "dep:pmodidl"]
|
playlist = ["dep:pmoplaylist", "dep:pmodidl"]
|
||||||
# Feature for logging (tracing)
|
# Feature for logging (tracing)
|
||||||
|
|||||||
@@ -32,6 +32,8 @@ use crate::models::{ImageSize, LiveResponse, Station, StationType, StreamFormat}
|
|||||||
use pmodidl::{Item, Resource};
|
use pmodidl::{Item, Resource};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
#[cfg(feature = "cache")]
|
||||||
|
use pmocache::cache_trait::FileCache;
|
||||||
#[cfg(feature = "cache")]
|
#[cfg(feature = "cache")]
|
||||||
use pmocovers::Cache as CoverCache;
|
use pmocovers::Cache as CoverCache;
|
||||||
#[cfg(feature = "cache")]
|
#[cfg(feature = "cache")]
|
||||||
@@ -336,6 +338,14 @@ impl StationPlaylist {
|
|||||||
Self::extract_cover_url(metadata, server_base_url)
|
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)
|
// Construction de la ressource (stream)
|
||||||
let resource = Self::build_stream_resource(metadata);
|
let resource = Self::build_stream_resource(metadata);
|
||||||
|
|
||||||
@@ -496,10 +506,14 @@ impl StationPlaylist {
|
|||||||
"{}/api/radiofrance/default-logo",
|
"{}/api/radiofrance/default-logo",
|
||||||
base.trim_end_matches('/')
|
base.trim_end_matches('/')
|
||||||
);
|
);
|
||||||
|
#[cfg(feature = "logging")]
|
||||||
|
tracing::debug!("Using default Radio France logo: {}", logo_url);
|
||||||
return (Some(logo_url), None);
|
return (Some(logo_url), None);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Pas de cover trouvée et pas de serveur configuré
|
// 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)
|
(None, None)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -548,8 +562,13 @@ impl StationPlaylist {
|
|||||||
match cache.add_from_url(&cover_url, Some("radiofrance")).await {
|
match cache.add_from_url(&cover_url, Some("radiofrance")).await {
|
||||||
Ok(pk) => {
|
Ok(pk) => {
|
||||||
// Construire l'URL publique si server_base_url est fourni
|
// Construire l'URL publique si server_base_url est fourni
|
||||||
let public_url = server_base_url
|
let public_url = server_base_url.map(|base| {
|
||||||
.map(|base| format!("{}/covers/{}", base.trim_end_matches('/'), pk));
|
format!(
|
||||||
|
"{}{}",
|
||||||
|
base.trim_end_matches('/'),
|
||||||
|
cache.route_for(&pk, None)
|
||||||
|
)
|
||||||
|
});
|
||||||
|
|
||||||
(public_url.or(Some(cover_url)), Some(pk))
|
(public_url.or(Some(cover_url)), Some(pk))
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user