fix(downloads,playback): re-encode undecodable audio and carry the media source through

Work from a parallel session in the same working tree, committed here so the
branch is not left half-written. Attribution note: authored in a concurrent
Claude session, not by the author of the preceding commit.

- DR-171: a downloaded video keeps audio the device can actually decode.
  `original` quality asked for a straight copy, so an E-AC-3/AC-3/DTS/TrueHD
  track came down untouched and the webview had nothing to play it with.
- `get_video_download_url` gains the media source, so the URL is built against
  the source actually chosen rather than the item's default.
- Device profile and repository plumbing updated to match.

Verified green as a whole: 656 Rust tests, 945 frontend tests, svelte-check clean.
This commit is contained in:
2026-08-15 23:54:00 +02:00
parent a5535f2941
commit ac4fccd499
10 changed files with 385 additions and 46 deletions
+11 -4
View File
@@ -804,7 +804,7 @@ pub fn repository_get_subtitle_url(
#[tauri::command]
#[specta::specta]
#[allow(dead_code)]
pub fn repository_get_video_download_url(
pub async fn repository_get_video_download_url(
manager: State<'_, RepositoryManagerWrapper>,
handle: String,
item_id: String,
@@ -812,9 +812,16 @@ pub fn repository_get_video_download_url(
media_source_id: Option<String>,
) -> Result<String, String> {
let repo = manager.0.get(&handle).ok_or("Repository not found")?;
Ok(repo
.as_ref()
.get_video_download_url(&item_id, &quality, media_source_id.as_deref()))
// Async because the audio-codec policy has to know what the source's audio
// is before it can decide whether the file may be copied verbatim (DR-171).
// The frontend calls this exactly as before — the decision stays in Rust.
Ok(crate::repository::resolve_video_download_url(
repo.as_ref(),
&item_id,
&quality,
media_source_id.as_deref(),
)
.await)
}
/// Mark an item as favorite