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 <m@rtyn.berlin>
This commit is contained in:
Martyn Ranyard 2024-12-13 12:28:40 +00:00 committed by Cadence Ember
parent 4823f8ec73
commit be33a66e8c
1 changed files with 10 additions and 2 deletions

View File

@ -19,11 +19,19 @@ for (const f of [].concat(
function getBestAudioFormat() { function getBestAudioFormat() {
let best = null let best = null
let aidub = false
for (const f of audioFormats.values()) { for (const f of audioFormats.values()) {
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) { if (best === null || f.bitrate > best.bitrate) {
best = f best = f
} }
} }
}
return best return best
} }