mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2025-04-29 00:10:35 +05:30
[YouTube] Extract whether a track is a descriptive audio and audio locale when available
Also use audio track setters only for audio itags.
This commit is contained in:
parent
3bb5eeef30
commit
76b7c19c5d
@ -82,6 +82,7 @@ import org.schabi.newpipe.extractor.stream.StreamType;
|
|||||||
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
|
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
|
||||||
import org.schabi.newpipe.extractor.stream.VideoStream;
|
import org.schabi.newpipe.extractor.stream.VideoStream;
|
||||||
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
import org.schabi.newpipe.extractor.utils.JsonUtils;
|
||||||
|
import org.schabi.newpipe.extractor.utils.LocaleCompat;
|
||||||
import org.schabi.newpipe.extractor.utils.Pair;
|
import org.schabi.newpipe.extractor.utils.Pair;
|
||||||
import org.schabi.newpipe.extractor.utils.Parser;
|
import org.schabi.newpipe.extractor.utils.Parser;
|
||||||
import org.schabi.newpipe.extractor.utils.Utils;
|
import org.schabi.newpipe.extractor.utils.Utils;
|
||||||
@ -1323,6 +1324,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
.setAverageBitrate(itagItem.getAverageBitrate())
|
.setAverageBitrate(itagItem.getAverageBitrate())
|
||||||
.setAudioTrackId(itagItem.getAudioTrackId())
|
.setAudioTrackId(itagItem.getAudioTrackId())
|
||||||
.setAudioTrackName(itagItem.getAudioTrackName())
|
.setAudioTrackName(itagItem.getAudioTrackName())
|
||||||
|
.setAudioLocale(itagItem.getAudioLocale())
|
||||||
|
.setIsDescriptive(itagItem.isDescriptiveAudio())
|
||||||
.setItagItem(itagItem);
|
.setItagItem(itagItem);
|
||||||
|
|
||||||
if (streamType == StreamType.LIVE_STREAM
|
if (streamType == StreamType.LIVE_STREAM
|
||||||
@ -1468,9 +1471,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
itagItem.setQuality(formatData.getString("quality"));
|
itagItem.setQuality(formatData.getString("quality"));
|
||||||
itagItem.setCodec(codec);
|
itagItem.setCodec(codec);
|
||||||
|
|
||||||
itagItem.setAudioTrackId(formatData.getObject("audioTrack").getString("id"));
|
|
||||||
itagItem.setAudioTrackName(formatData.getObject("audioTrack").getString("displayName"));
|
|
||||||
|
|
||||||
if (streamType == StreamType.LIVE_STREAM || streamType == StreamType.POST_LIVE_STREAM) {
|
if (streamType == StreamType.LIVE_STREAM || streamType == StreamType.POST_LIVE_STREAM) {
|
||||||
itagItem.setTargetDurationSec(formatData.getInt("targetDurationSec"));
|
itagItem.setTargetDurationSec(formatData.getInt("targetDurationSec"));
|
||||||
}
|
}
|
||||||
@ -1487,6 +1487,27 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||||||
// AudioChannelConfiguration element of DASH manifests of audio streams in
|
// AudioChannelConfiguration element of DASH manifests of audio streams in
|
||||||
// YoutubeDashManifestCreatorUtils
|
// YoutubeDashManifestCreatorUtils
|
||||||
2));
|
2));
|
||||||
|
|
||||||
|
final String audioTrackId = formatData.getObject("audioTrack")
|
||||||
|
.getString("id");
|
||||||
|
if (!isNullOrEmpty(audioTrackId)) {
|
||||||
|
itagItem.setAudioTrackId(audioTrackId);
|
||||||
|
final int audioTrackIdLastLocaleCharacter = audioTrackId.indexOf(".");
|
||||||
|
if (audioTrackIdLastLocaleCharacter != -1) {
|
||||||
|
// Audio tracks IDs are in the form LANGUAGE_CODE.TRACK_NUMBER
|
||||||
|
itagItem.setAudioLocale(LocaleCompat.forLanguageTag(
|
||||||
|
audioTrackId.substring(0, audioTrackIdLastLocaleCharacter)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
itagItem.setAudioTrackName(formatData.getObject("audioTrack")
|
||||||
|
.getString("displayName"));
|
||||||
|
|
||||||
|
// Descriptive audio tracks
|
||||||
|
// This information is also provided as a protobuf object in the formatData
|
||||||
|
itagItem.setIsDescriptiveAudio(streamUrl.contains("acont%3Ddescriptive")
|
||||||
|
// Support "decoded" URLs
|
||||||
|
|| streamUrl.contains("acont=descriptive"));
|
||||||
}
|
}
|
||||||
|
|
||||||
// YouTube return the content length and the approximate duration as strings
|
// YouTube return the content length and the approximate duration as strings
|
||||||
|
Loading…
x
Reference in New Issue
Block a user