From be33a66e8c113bb5869cceec1ed6777f0d40ceb8 Mon Sep 17 00:00:00 2001 From: Martyn Ranyard Date: Fri, 13 Dec 2024 12:28:40 +0000 Subject: [PATCH] If multiple languages found, look for default Fix for Google rolling out AI dubbed translations and cloudtube picking the first audio stream, not the default. Chooses the best audio format by filtering for default. If none of the audio streams are marked as default, then use old codepath. Signed-off-by: Martyn Ranyard --- html/static/js/player.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/html/static/js/player.js b/html/static/js/player.js index 18dbe1c..f053224 100644 --- a/html/static/js/player.js +++ b/html/static/js/player.js @@ -19,9 +19,17 @@ for (const f of [].concat( function getBestAudioFormat() { let best = null + let aidub = false for (const f of audioFormats.values()) { - if (best === null || f.bitrate > best.bitrate) { - best = f + if (f.resolution.includes("default")) { + aidub = true + } + } + for (const f of audioFormats.values()) { + if (!aidub || f.resolution.includes("default")) { + if (best === null || f.bitrate > best.bitrate) { + best = f + } } } return best