Skip to content

Commit 3bb5eee

Browse files
committed
[YouTube] Add descriptive and locale audio support in ItagItem
1 parent 14bf3fb commit 3bb5eee

1 file changed

Lines changed: 53 additions & 3 deletions

File tree

  • extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/ItagItem.java

Lines changed: 53 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import javax.annotation.Nonnull;
77
import javax.annotation.Nullable;
88
import java.io.Serializable;
9+
import java.util.Locale;
910

1011
import static org.schabi.newpipe.extractor.MediaFormat.M4A;
1112
import static org.schabi.newpipe.extractor.MediaFormat.MPEG_4;
@@ -198,6 +199,10 @@ public ItagItem(@Nonnull final ItagItem itagItem) {
198199
this.targetDurationSec = itagItem.targetDurationSec;
199200
this.approxDurationMs = itagItem.approxDurationMs;
200201
this.contentLength = itagItem.contentLength;
202+
this.audioTrackId = itagItem.audioTrackId;
203+
this.audioTrackName = itagItem.audioTrackName;
204+
this.isDescriptiveAudio = itagItem.isDescriptiveAudio;
205+
this.audioLocale = itagItem.audioLocale;
201206
}
202207

203208
public MediaFormat getMediaFormat() {
@@ -246,6 +251,9 @@ public MediaFormat getMediaFormat() {
246251
private long contentLength = CONTENT_LENGTH_UNKNOWN;
247252
private String audioTrackId;
248253
private String audioTrackName;
254+
private boolean isDescriptiveAudio;
255+
@Nullable
256+
private Locale audioLocale;
249257

250258
public int getBitrate() {
251259
return bitrate;
@@ -569,19 +577,61 @@ public void setAudioTrackId(@Nullable final String audioTrackId) {
569577
/**
570578
* Get the {@code audioTrackName} of the stream, if present.
571579
*
572-
* @return the {@code audioTrackName} of the stream or null
580+
* @return the {@code audioTrackName} of the stream or {@code null}
573581
*/
574582
@Nullable
575583
public String getAudioTrackName() {
576584
return audioTrackName;
577585
}
578586

579587
/**
580-
* Set the {@code audioTrackName} of the stream.
588+
* Set the {@code audioTrackName} of the stream, if present.
581589
*
582-
* @param audioTrackName the {@code audioTrackName} of the stream
590+
* @param audioTrackName the {@code audioTrackName} of the stream or {@code null}
583591
*/
584592
public void setAudioTrackName(@Nullable final String audioTrackName) {
585593
this.audioTrackName = audioTrackName;
586594
}
595+
596+
/**
597+
* Return whether the stream is a descriptive audio.
598+
*
599+
* @return whether the stream is a descriptive audio
600+
*/
601+
public boolean isDescriptiveAudio() {
602+
return isDescriptiveAudio;
603+
}
604+
605+
/**
606+
* Set whether the stream is a descriptive audio.
607+
*
608+
* @param isDescriptiveAudio whether the stream is a descriptive audio
609+
*/
610+
public void setIsDescriptiveAudio(final boolean isDescriptiveAudio) {
611+
this.isDescriptiveAudio = isDescriptiveAudio;
612+
}
613+
614+
/**
615+
* Return the audio {@link Locale} of the stream, if known.
616+
*
617+
* @return the audio {@link Locale} of the stream, if known, or {@code null} if that's not the
618+
* case
619+
*/
620+
@Nullable
621+
public Locale getAudioLocale() {
622+
return audioLocale;
623+
}
624+
625+
/**
626+
* Set the audio {@link Locale} of the stream.
627+
*
628+
* <p>
629+
* If it is unknown, {@code null} could be passed, which is the default value.
630+
* </p>
631+
*
632+
* @param audioLocale the audio {@link Locale} of the stream, which could be {@code null}
633+
*/
634+
public void setAudioLocale(@Nullable final Locale audioLocale) {
635+
this.audioLocale = audioLocale;
636+
}
587637
}

0 commit comments

Comments
 (0)