From 4b20c966e017e12fbe65c428cc5887e219eb38af Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Sat, 24 Jan 2026 21:20:35 +0100 Subject: [PATCH] Bump version to 0.3.18 and improve stream handling Version bump from 0.3.17 to 0.3.18 - Updated version in Cargo.toml and version.txt - Removed unused LiveResponse import in pmoradiofrance - Added tracing info for stream proxyfication - Improved Media::best_hifi_stream logic to prioritize AAC over MP3 and never use HLS streams - Updated comments to reflect new stream priority logic --- Cargo.lock | 2 +- PMOMusic/Cargo.toml | 2 +- pmoradiofrance/src/api_rest.rs | 7 ++++++- pmoradiofrance/src/models.rs | 23 ++++++++++++----------- version.txt | 2 +- 5 files changed, 21 insertions(+), 15 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index ce9b081a..48838a9e 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,7 +4,7 @@ version = 4 [[package]] name = "PMOMusic" -version = "0.3.17" +version = "0.3.18" dependencies = [ "axum 0.8.7", "console-subscriber", diff --git a/PMOMusic/Cargo.toml b/PMOMusic/Cargo.toml index c2229785..ebc7ba86 100644 --- a/PMOMusic/Cargo.toml +++ b/PMOMusic/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "PMOMusic" -version = "0.3.17" +version = "0.3.18" edition = "2024" [dependencies] diff --git a/pmoradiofrance/src/api_rest.rs b/pmoradiofrance/src/api_rest.rs index adf98c1c..59102440 100644 --- a/pmoradiofrance/src/api_rest.rs +++ b/pmoradiofrance/src/api_rest.rs @@ -3,7 +3,6 @@ //! Ce module définit les handlers HTTP pour accéder aux stations Radio France, //! leurs métadonnées live et les flux de streaming. -use crate::models::LiveResponse; use crate::playlist::StationGroups; use crate::pmoserver_ext::RadioFranceState; use axum::{ @@ -16,6 +15,7 @@ use axum::{ }; use futures::StreamExt; use serde_json; +use tracing::info; // ============ Gestion des erreurs ============ @@ -97,6 +97,11 @@ async fn proxy_stream( Err(e) => return AppError(format!("Stream not found: {}", e)).into_response(), }; + info!( + "Proxyfying RadioFrance stream for {} ==> {}", + &slug, &stream_url + ); + // Connect to the Radio France stream let response = match reqwest::get(&stream_url).await { Ok(r) => r, diff --git a/pmoradiofrance/src/models.rs b/pmoradiofrance/src/models.rs index 15895291..3e7a82e2 100644 --- a/pmoradiofrance/src/models.rs +++ b/pmoradiofrance/src/models.rs @@ -158,20 +158,21 @@ pub struct Media { } impl Media { - /// Find the best HiFi stream (AAC 192 kbps or HLS) + /// Find the best HiFi stream (AAC ou MP3, bitrate maximum, jamais HLS) pub fn best_hifi_stream(&self) -> Option<&StreamSource> { - // Priority: AAC 192 kbps > HLS + // Priority: AAC 192 kbps > AAC autre bitrate > MP3 bitrate max > autre + // JAMAIS HLS (incompatible avec beaucoup de lecteurs) self.sources .iter() - .find(|s| { - s.format == StreamFormat::Aac - && s.broadcast_type == BroadcastType::Live - && s.bitrate == 192 - }) - .or_else(|| { - self.sources.iter().find(|s| { - s.format == StreamFormat::Hls && s.broadcast_type == BroadcastType::Live - }) + .filter(|s| s.broadcast_type == BroadcastType::Live && s.format != StreamFormat::Hls) + .max_by_key(|s| { + // Priorité: format puis bitrate + let format_priority = match s.format { + StreamFormat::Aac => 1000, + StreamFormat::Mp3 => 500, + StreamFormat::Hls => 0, // Filtré de toute façon + }; + format_priority + s.bitrate }) } diff --git a/version.txt b/version.txt index e5a9958c..8355eafc 100644 --- a/version.txt +++ b/version.txt @@ -1 +1 @@ -0.3.17 +0.3.18