From 6ade288b69179926a946cba8a64ae91879e00dc7 Mon Sep 17 00:00:00 2001 From: absidue <48293849+absidue@users.noreply.github.com> Date: Sat, 5 Aug 2023 12:54:24 +0200 Subject: [PATCH] Ignore broken audio tracks for videos with multiple audio tracks --- src/renderer/views/Watch/Watch.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/renderer/views/Watch/Watch.js b/src/renderer/views/Watch/Watch.js index a6de6edad6512..fe8fe0ff8f3ec 100644 --- a/src/renderer/views/Watch/Watch.js +++ b/src/renderer/views/Watch/Watch.js @@ -596,7 +596,14 @@ export default defineComponent({ /** @type {import('youtubei.js').Misc.Format[][]} */ const sourceLists = [] - audioFormats.forEach(format => { + for (const format of audioFormats) { + // Some videos with multiple audio tracks, have a broken one, that doesn't have any audio track information + // It seems to be the same as default audio track but broken + // At the time of writing, this video has a broken audio track: https://youtu.be/UJeSWbR6W04 + if (!format.audio_track) { + continue + } + const index = ids.indexOf(format.audio_track.id) if (index === -1) { ids.push(format.audio_track.id) @@ -628,7 +635,7 @@ export default defineComponent({ } else { sourceLists[index].push(format) } - }) + } for (let i = 0; i < audioTracks.length; i++) { audioTracks[i].sourceList = this.createLocalAudioSourceList(sourceLists[i])