Skip to content

Commit 0617c88

Browse files
committed
[YouTube] Extract xtags of formats
Extracts the `xtags` field, which encodes additional data of the format, such as if the format is using dynamic range compression. This is required for using SABR.
1 parent a431a90 commit 0617c88

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -269,6 +269,7 @@ public MediaFormat getMediaFormat() {
269269
private Locale audioLocale;
270270
private boolean isDrc;
271271
private long lastModified;
272+
private String xtags;
272273

273274
public int getBitrate() {
274275
return bitrate;
@@ -701,4 +702,26 @@ public void setLastModified(final long lastModified) {
701702
this.lastModified = lastModified;
702703
}
703704

705+
/**
706+
* Extra tags about the stream.
707+
*
708+
* <p>
709+
* Contains a Base64 encoded protobuf key-value list of additional tags for the stream,
710+
* such as whether the stream is using {@link #isDrc()}.
711+
* </p>
712+
*
713+
* @return Base64-encoded extra tags.
714+
*/
715+
public String getXtags() {
716+
return xtags;
717+
}
718+
719+
/**
720+
* Sets extra tags of the stream.
721+
*
722+
* @param xtags extra tags of the stream
723+
*/
724+
public void setXtags(final String xtags) {
725+
this.xtags = xtags;
726+
}
704727
}

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1423,6 +1423,7 @@ private ItagInfo buildAndAddItagInfoToList(
14231423
itagItem.setCodec(codec);
14241424
itagItem.setIsDrc(formatData.getBoolean("isDrc", false));
14251425
itagItem.setLastModified(Long.parseLong(formatData.getString("lastModified", "-1")));
1426+
itagItem.setXtags(formatData.getString("xtags"));
14261427

14271428
if (streamType == StreamType.LIVE_STREAM || streamType == StreamType.POST_LIVE_STREAM) {
14281429
itagItem.setTargetDurationSec(formatData.getInt("targetDurationSec"));

0 commit comments

Comments
 (0)