Skip to content

Commit f36ef21

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 8c044a0 commit f36ef21

2 files changed

Lines changed: 26 additions & 0 deletions

File tree

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

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -268,6 +268,7 @@ public MediaFormat getMediaFormat() {
268268
private Locale audioLocale;
269269
private boolean isDrc;
270270
private long lastModified;
271+
private String xtags;
271272

272273
public int getBitrate() {
273274
return bitrate;
@@ -695,4 +696,28 @@ public void setLastModified(final long lastModified) {
695696
this.lastModified = lastModified;
696697
}
697698

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

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)