Skip to content

Commit

Permalink
[YouTube] Don't generate DASH manifests for OTF streams when loading …
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
AudricV committed Aug 14, 2021
1 parent cef6678 commit eb03497
Showing 1 changed file with 12 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1170,21 +1170,12 @@ private List<ContentAndItagItemAndIsUrl> getItags(final String streamingDataKey,
final List<ContentAndItagItemAndIsUrl> contentsAndItagItems = new ArrayList<>();
if (mobileStreamingData != null || desktopStreamingData != null) {
final StreamType streamType = getStreamType();
if (streamType == StreamType.VIDEO_STREAM) {
// Use the mobileStreamingData JSON object first because there is no n param and no
// signatureCiphers in streaming URLs of the Android client
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
streamingDataKey, itagTypeWanted, streamType));
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
streamingDataKey, itagTypeWanted, streamType));
} else {
// Use the desktopStreamingData JSON object first because there are less redirects
// from the desktop endpoint
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
streamingDataKey, itagTypeWanted, streamType));
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
streamingDataKey, itagTypeWanted, streamType));
}
// Use the desktopStreamingData JSON object first because there are fewer redirects
// from the desktop endpoint for OTF and post live streams
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(desktopStreamingData,
streamingDataKey, itagTypeWanted, streamType));
contentsAndItagItems.addAll(getStreamsFromStreamingDataKey(mobileStreamingData,
streamingDataKey, itagTypeWanted, streamType));
}

return contentsAndItagItems;
Expand Down Expand Up @@ -1256,25 +1247,18 @@ private List<ContentAndItagItemAndIsUrl> getStreamsFromStreamingDataKey(
if (streamType == StreamType.VIDEO_STREAM) {
if (formatData.getString("type", EMPTY_STRING)
.equalsIgnoreCase("FORMAT_STREAM_TYPE_OTF")) {
try {
final String content =
createDashManifestFromOtfStreamingUrl(streamUrl,
itagItem);
contentsAndItagItemsAndAreUrls.add(
new ContentAndItagItemAndIsUrl(content, itagItem,
false));
} catch (final YoutubeDashManifestCreator
.YoutubeDashManifestCreationException ignored) {
// Something went wrong when generating the DASH manifest
// of the OTF stream, don't add this stream to the stream
// list
}
contentsAndItagItemsAndAreUrls.add(
new ContentAndItagItemAndIsUrl(streamUrl, itagItem,
false));
} else {
contentsAndItagItemsAndAreUrls.add(
new ContentAndItagItemAndIsUrl(streamUrl, itagItem,
true));
}
} else if (streamType == StreamType.POST_LIVE_STREAM) {
// Even if it increases the content loading, we need to generate
// manifests of post live streams now because the
// targetDurationSec value is required to create these manifests
try {
final String content =
createDashManifestFromPostLiveStreamDvrStreamingUrl(
Expand Down

0 comments on commit eb03497

Please sign in to comment.