Skip to content

Commit eb03497

Browse files
committed
[YouTube] Don't generate DASH manifests for OTF streams when loading the content
The content loading when there are OTF streams is increased a lot by the fetch of the first segment of each stream and by the generation of the manifests. The generation of these manifests needs now to be requested by clients (by using the createDashManifestFromOtfStreamingUrl method of the YoutubeDashManifestCreator class). Also always use the streams from the desktopStreamingData JSON object first.
1 parent cef6678 commit eb03497

1 file changed

Lines changed: 12 additions & 28 deletions

File tree

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

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1170,21 +1170,12 @@ private List<ContentAndItagItemAndIsUrl> getItags(final String streamingDataKey,
11701170
final List<ContentAndItagItemAndIsUrl> contentsAndItagItems = new ArrayList<>();
11711171
if (mobileStreamingData != null || desktopStreamingData != null) {
11721172
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-
}
1173+
// Use the desktopStreamingData JSON object first because there are fewer redirects
1174+
// from the desktop endpoint for OTF and post live streams
1175+
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
1176+
streamingDataKey, itagTypeWanted, streamType));
1177+
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
1178+
streamingDataKey, itagTypeWanted, streamType));
11881179
}
11891180

11901181
return contentsAndItagItems;
@@ -1256,25 +1247,18 @@ private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
12561247
if (streamType == StreamType.VIDEO_STREAM) {
12571248
if (formatData.getString("type", EMPTY_STRING)
12581249
.equalsIgnoreCase("FORMAT_STREAM_TYPE_OTF")) {
1259-
try {
1260-
final String content =
1261-
createDashManifestFromOtfStreamingUrl(streamUrl,
1262-
itagItem);
1263-
contentsAndItagItemsAndAreUrls.add(
1264-
new ContentAndItagItemAndIsUrl(content, itagItem,
1265-
false));
1266-
} catch (final YoutubeDashManifestCreator
1267-
.YoutubeDashManifestCreationException ignored) {
1268-
// Something went wrong when generating the DASH manifest
1269-
// of the OTF stream, don't add this stream to the stream
1270-
// list
1271-
}
1250+
contentsAndItagItemsAndAreUrls.add(
1251+
new ContentAndItagItemAndIsUrl(streamUrl, itagItem,
1252+
false));
12721253
} else {
12731254
contentsAndItagItemsAndAreUrls.add(
12741255
new ContentAndItagItemAndIsUrl(streamUrl, itagItem,
12751256
true));
12761257
}
12771258
} else if (streamType == StreamType.POST_LIVE_STREAM) {
1259+
// Even if it increases the content loading, we need to generate
1260+
// manifests of post live streams now because the
1261+
// targetDurationSec value is required to create these manifests
12781262
try {
12791263
final String content =
12801264
createDashManifestFromPostLiveStreamDvrStreamingUrl(

0 commit comments

Comments
 (0)