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 53031e7341..c0aee17ccb 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 static AudioTrackType extractAudioTrackType(final String streamUrl) { 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 5e0fb6d4cf..0b4c411574 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 @@ private static String getRoleValue(@Nullable final AudioTrackType trackType) { 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 baba9dc42a..c57cf261b0 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 }