From 5f1fdc14e0f4afdb6dadf9c03711952ad4854590 Mon Sep 17 00:00:00 2001 From: ajisth69 Date: Sat, 5 Dec 2026 21:09:57 +0530 Subject: [PATCH] fix(addons): route extensionless progressive addon URLs through loopback accelerator --- .../src/integrations/addons/addon_api.rs | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/src-tauri/src/integrations/addons/addon_api.rs b/src-tauri/src/integrations/addons/addon_api.rs index 47fd5876..d6e91225 100644 --- a/src-tauri/src/integrations/addons/addon_api.rs +++ b/src-tauri/src/integrations/addons/addon_api.rs @@ -1960,15 +1960,41 @@ impl AddonApi { )); } - let mime = if is_stream_atmos { - "audio/mp4" + let (mime, ext): (&'static str, &'static str) = if is_stream_atmos { + ("audio/mp4", "m4a") } else if lower.ends_with(".mp3") { - "audio/mpeg" + ("audio/mpeg", "mp3") } else if lower.ends_with(".m4a") || lower.ends_with(".mp4") { - "audio/mp4" + ("audio/mp4", "m4a") } else { - "audio/flac" + ("audio/flac", "flac") }; + // Extensionless progressive URLs (e.g. /st/track/) used to be + // handed straight to mpv on a single TLS connection, which buffered. + // Every progressive addon stream goes through the loopback server so + // the adaptive multi-connection fetcher actually sees it. + if !is_stream_atmos { + if let Some(local_url) = LocalMediaServer::global() + .url_for_direct(self.http.clone(), &direct, &media_cache_name, ext, mime) + .await + { + return Some(( + ResolvedStream { + url: local_url, + mime_type: mime.to_string(), + bitrate_kbps, + audio_codec: codec.to_string(), + cache_key, + is_lossless: !mp3, + bit_depth, + sampling_rate_khz: sample_rate, + expires_at: Some(Utc::now() + ChronoDuration::hours(24)), + ..Default::default() + }, + Some(media_cache_name), + )); + } + } Some(( ResolvedStream { url: direct,