Skip to content

Commit 12e8e6d

Browse files
committed
[YouTube] Return the POST_LIVE_STREAM stream type
Return the POST_LIVE_STREAM stream type when a stream has the boolean isPostLiveDvr present and when this boolean is set to true
1 parent abdd706 commit 12e8e6d

1 file changed

Lines changed: 23 additions & 11 deletions

File tree

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

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -689,11 +689,13 @@ public List<SubtitlesStream> getSubtitles(final MediaFormat format) throws Parsi
689689
public StreamType getStreamType() {
690690
assertPageFetched();
691691

692-
if (playerResponse.getObject("playabilityStatus").has("liveStreamability")
693-
|| playerResponse.getObject("videoDetails").getBoolean("isPostLiveDvr", false)) {
692+
if (playerResponse.getObject("playabilityStatus").has("liveStreamability")) {
694693
return StreamType.LIVE_STREAM;
694+
} else if (playerResponse.getObject("videoDetails").getBoolean("isPostLiveDvr", false)) {
695+
return StreamType.POST_LIVE_STREAM;
696+
} else {
697+
return StreamType.VIDEO_STREAM;
695698
}
696-
return StreamType.VIDEO_STREAM;
697699
}
698700

699701
@Nullable
@@ -1167,12 +1169,22 @@ private List<ContentAndItagItemAndIsUrl> getItags(final String streamingDataKey,
11671169
throws ParsingException {
11681170
final List<ContentAndItagItemAndIsUrl> contentsAndItagItems = new ArrayList<>();
11691171
if (mobileStreamingData != null || desktopStreamingData != null) {
1170-
// Use the mobileStreamingData object first because there is no n param and no
1171-
// signatureCiphers in streaming URLs of the Android client
1172-
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
1173-
streamingDataKey, itagTypeWanted));
1174-
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
1175-
streamingDataKey, itagTypeWanted));
1172+
final StreamType streamType = getStreamType();
1173+
if (streamType == StreamType.VIDEO_STREAM) {
1174+
// Use the mobileStreamingData JSON object first because there is no n param and no
1175+
// signatureCiphers in streaming URLs of the Android client
1176+
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
1177+
streamingDataKey, itagTypeWanted, streamType));
1178+
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
1179+
streamingDataKey, itagTypeWanted, streamType));
1180+
} else {
1181+
// Use the desktopStreamingData JSON object first because there are less redirects
1182+
// from the desktop endpoint
1183+
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
1184+
streamingDataKey, itagTypeWanted, streamType));
1185+
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
1186+
streamingDataKey, itagTypeWanted, streamType));
1187+
}
11761188
}
11771189

11781190
return contentsAndItagItems;
@@ -1182,13 +1194,13 @@ private List<ContentAndItagItemAndIsUrl> getItags(final String streamingDataKey,
11821194
private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
11831195
final JsonObject streamingData,
11841196
final String streamingDataKey,
1185-
final ItagItem.ItagType itagTypeWanted) throws ParsingException {
1197+
final ItagItem.ItagType itagTypeWanted,
1198+
final StreamType streamType) throws ParsingException {
11861199

11871200
final List<ContentAndItagItemAndIsUrl> contentsAndItagItemsAndAreUrls = new ArrayList<>();
11881201
if (streamingData != null && streamingData.has(streamingDataKey)) {
11891202
final YoutubeThrottlingDecrypter throttlingDecrypter = new YoutubeThrottlingDecrypter(
11901203
getId());
1191-
final StreamType streamType = getStreamType();
11921204
final JsonArray formats = streamingData.getArray(streamingDataKey);
11931205
for (int i = 0; i != formats.size(); ++i) {
11941206
final JsonObject formatData = formats.getObject(i);

0 commit comments

Comments
 (0)