[YouTube] Return approxDurationMs value from YouTube's player response in ItagItems generated

This change allows to build DASH manifests using YoutubeDashManifestCreator with the real duration of streams and prevent potential cuts of the end of progressive streams, because the duration in YouTube's player response is in seconds and not milliseconds.
This commit is contained in:
TiA4f8R 2022-05-07 19:32:12 +02:00
parent 4158fc46a0
commit 2f3920c648
No known key found for this signature in database
GPG key ID: E6D3E7F5949450DD

View file

@ -20,6 +20,7 @@
package org.schabi.newpipe.extractor.services.youtube.extractors;
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.APPROX_DURATION_MS_UNKNOWN;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CONTENT_CHECK_OK;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CPN;
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.RACY_CHECK_OK;
@ -1396,9 +1397,11 @@ public class YoutubeStreamExtractor extends StreamExtractor {
itagItem.setAudioChannels(formatData.getInt("audioChannels"));
}
// YouTube return the content length as a string
// YouTube return the content length and the approximate duration as strings
itagItem.setContentLength(Long.parseLong(formatData.getString("contentLength",
String.valueOf(CONTENT_LENGTH_UNKNOWN))));
itagItem.setApproxDurationMs(Long.parseLong(formatData.getString("approxDurationMs",
String.valueOf(APPROX_DURATION_MS_UNKNOWN))));
final ItagInfo itagInfo = new ItagInfo(streamUrl, itagItem);