Skip to content

Commit a431a90

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 a431a90

2 files changed

Lines changed: 27 additions & 0 deletions

File tree

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

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ public static ItagItem getItag(final int itagId) throws ParsingException {
134134
public static final int AUDIO_CHANNELS_NOT_APPLICABLE_OR_UNKNOWN = -1;
135135
public static final long CONTENT_LENGTH_UNKNOWN = -1;
136136
public static final long APPROX_DURATION_MS_UNKNOWN = -1;
137+
public static final long LAST_MODIFIED_UNKOWN = -1;
137138

138139
/*//////////////////////////////////////////////////////////////////////////
139140
// Constructors and misc
@@ -267,6 +268,7 @@ public MediaFormat getMediaFormat() {
267268
@Nullable
268269
private Locale audioLocale;
269270
private boolean isDrc;
271+
private long lastModified;
270272

271273
public int getBitrate() {
272274
return bitrate;
@@ -675,4 +677,28 @@ public void setIsDrc(final Boolean isDrc) {
675677
this.isDrc = isDrc;
676678
}
677679

680+
681+
/**
682+
* When the stream was last modified.
683+
*
684+
* <p>
685+
* If the timestamp is unknown, {@link #LAST_MODIFIED_UNKOWN} is returned.
686+
* </p>
687+
*
688+
* @return unix timestamp of when the stream was last modified or
689+
* {@link #LAST_MODIFIED_UNKOWN} if the timestamp is unknown.
690+
*/
691+
public long getLastModified() {
692+
return lastModified;
693+
}
694+
695+
/**
696+
* Sets the timestamp when the stream was last modified.
697+
*
698+
* @param lastModified unix timestamp of when the stream was last modified
699+
*/
700+
public void setLastModified(final long lastModified) {
701+
this.lastModified = lastModified;
702+
}
703+
678704
}

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)