Skip to content

Commit 8c044a0

Browse files
committed
[YouTube] Extract lastModified format data
Extracts the `lastModified` field of format, which is need for initiating SABR playback.
1 parent f6bfd8e commit 8c044a0

2 files changed

Lines changed: 21 additions & 0 deletions

File tree

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,7 @@ public MediaFormat getMediaFormat() {
267267
@Nullable
268268
private Locale audioLocale;
269269
private boolean isDrc;
270+
private long lastModified;
270271

271272
public int getBitrate() {
272273
return bitrate;
@@ -675,4 +676,23 @@ public void setIsDrc(final Boolean isDrc) {
675676
this.isDrc = isDrc;
676677
}
677678

679+
680+
/**
681+
* When the stream was last modified.
682+
*
683+
* @return unix timestamp of when the stream was last modified
684+
*/
685+
public long getLastModified() {
686+
return lastModified;
687+
}
688+
689+
/**
690+
* Sets the timestamp when the stream was last modified.
691+
*
692+
* @param lastModified unix timestamp of when the stream was last modified
693+
*/
694+
public void setLastModified(final long lastModified) {
695+
this.lastModified = lastModified;
696+
}
697+
678698
}

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
@@ -1422,6 +1422,7 @@ private ItagInfo buildAndAddItagInfoToList(
14221422
itagItem.setQuality(formatData.getString("quality"));
14231423
itagItem.setCodec(codec);
14241424
itagItem.setIsDrc(formatData.getBoolean("isDrc", false));
1425+
itagItem.setLastModified(Long.parseLong(formatData.getString("lastModified", "-1")));
14251426

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

0 commit comments

Comments
 (0)