[YouTube] Add descriptive and locale audio support in ItagItem

This commit is contained in:
AudricV 2022-11-18 21:52:46 +01:00
parent 14bf3fb05b
commit 3bb5eeef30
No known key found for this signature in database
GPG Key ID: DA92EC7905614198
1 changed files with 53 additions and 3 deletions

View File

@ -6,6 +6,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.io.Serializable; import java.io.Serializable;
import java.util.Locale;
import static org.schabi.newpipe.extractor.MediaFormat.M4A; import static org.schabi.newpipe.extractor.MediaFormat.M4A;
import static org.schabi.newpipe.extractor.MediaFormat.MPEG_4; import static org.schabi.newpipe.extractor.MediaFormat.MPEG_4;
@ -198,6 +199,10 @@ public class ItagItem implements Serializable {
this.targetDurationSec = itagItem.targetDurationSec; this.targetDurationSec = itagItem.targetDurationSec;
this.approxDurationMs = itagItem.approxDurationMs; this.approxDurationMs = itagItem.approxDurationMs;
this.contentLength = itagItem.contentLength; this.contentLength = itagItem.contentLength;
this.audioTrackId = itagItem.audioTrackId;
this.audioTrackName = itagItem.audioTrackName;
this.isDescriptiveAudio = itagItem.isDescriptiveAudio;
this.audioLocale = itagItem.audioLocale;
} }
public MediaFormat getMediaFormat() { public MediaFormat getMediaFormat() {
@ -246,6 +251,9 @@ public class ItagItem implements Serializable {
private long contentLength = CONTENT_LENGTH_UNKNOWN; private long contentLength = CONTENT_LENGTH_UNKNOWN;
private String audioTrackId; private String audioTrackId;
private String audioTrackName; private String audioTrackName;
private boolean isDescriptiveAudio;
@Nullable
private Locale audioLocale;
public int getBitrate() { public int getBitrate() {
return bitrate; return bitrate;
@ -569,7 +577,7 @@ public class ItagItem implements Serializable {
/** /**
* Get the {@code audioTrackName} of the stream, if present. * Get the {@code audioTrackName} of the stream, if present.
* *
* @return the {@code audioTrackName} of the stream or null * @return the {@code audioTrackName} of the stream or {@code null}
*/ */
@Nullable @Nullable
public String getAudioTrackName() { public String getAudioTrackName() {
@ -577,11 +585,53 @@ public class ItagItem implements Serializable {
} }
/** /**
* Set the {@code audioTrackName} of the stream. * Set the {@code audioTrackName} of the stream, if present.
* *
* @param audioTrackName the {@code audioTrackName} of the stream * @param audioTrackName the {@code audioTrackName} of the stream or {@code null}
*/ */
public void setAudioTrackName(@Nullable final String audioTrackName) { public void setAudioTrackName(@Nullable final String audioTrackName) {
this.audioTrackName = audioTrackName; this.audioTrackName = audioTrackName;
} }
/**
* Return whether the stream is a descriptive audio.
*
* @return whether the stream is a descriptive audio
*/
public boolean isDescriptiveAudio() {
return isDescriptiveAudio;
}
/**
* Set whether the stream is a descriptive audio.
*
* @param isDescriptiveAudio whether the stream is a descriptive audio
*/
public void setIsDescriptiveAudio(final boolean isDescriptiveAudio) {
this.isDescriptiveAudio = isDescriptiveAudio;
}
/**
* Return the audio {@link Locale} of the stream, if known.
*
* @return the audio {@link Locale} of the stream, if known, or {@code null} if that's not the
* case
*/
@Nullable
public Locale getAudioLocale() {
return audioLocale;
}
/**
* Set the audio {@link Locale} of the stream.
*
* <p>
* If it is unknown, {@code null} could be passed, which is the default value.
* </p>
*
* @param audioLocale the audio {@link Locale} of the stream, which could be {@code null}
*/
public void setAudioLocale(@Nullable final Locale audioLocale) {
this.audioLocale = audioLocale;
}
} }