From 8a3350f79d37d3a48669c257566a1d08f4c5d694 Mon Sep 17 00:00:00 2001 From: AudricV <74829229+AudricV@users.noreply.github.com> Date: Sat, 26 Oct 2024 20:32:39 +0200 Subject: [PATCH] [YouTube] Add support for automatic dubbed and secondary tracks --- .../services/youtube/YoutubeParsingHelper.java | 3 +++ .../YoutubeDashManifestCreatorsUtils.java | 2 ++ .../extractor/stream/AudioTrackType.java | 18 +++++++++++++++--- 3 files changed, 20 insertions(+), 3 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java index 53031e734..c0aee17cc 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/YoutubeParsingHelper.java @@ -1720,9 +1720,12 @@ public final class YoutubeParsingHelper { case "original": return AudioTrackType.ORIGINAL; case "dubbed": + case "dubbed-auto": return AudioTrackType.DUBBED; case "descriptive": return AudioTrackType.DESCRIPTIVE; + case "secondary": + return AudioTrackType.SECONDARY; default: return null; } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java index 5e0fb6d4c..0b4c41157 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/dashmanifestcreators/YoutubeDashManifestCreatorsUtils.java @@ -325,6 +325,8 @@ public final class YoutubeDashManifestCreatorsUtils { case DESCRIPTIVE: return "description"; default: + // Secondary track types do not seem to have a dedicated role in the DASH + // specification, so use alternate for them return "alternate"; } } diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioTrackType.java b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioTrackType.java index baba9dc42..c57cf261b 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioTrackType.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/stream/AudioTrackType.java @@ -1,12 +1,13 @@ package org.schabi.newpipe.extractor.stream; /** - * An enum representing the track type of an {@link AudioStream} extracted by a {@link + * An enum representing the track type of {@link AudioStream}s extracted by a {@link * StreamExtractor}. */ public enum AudioTrackType { + /** - * An original audio track of the video. + * An original audio track of a video. */ ORIGINAL, @@ -20,6 +21,7 @@ public enum AudioTrackType { /** * A descriptive audio track. + * *

* A descriptive audio track is an audio track in which descriptions of visual elements of * a video are added to the original audio, with the goal to make a video more accessible to @@ -29,5 +31,15 @@ public enum AudioTrackType { * @see * https://en.wikipedia.org/wiki/Audio_description */ - DESCRIPTIVE + DESCRIPTIVE, + + /** + * A secondary audio track. + * + *

+ * A secondary audio track can be an alternate audio track from the original language of a + * video or an alternate language. + *

+ */ + SECONDARY }