From 2f3920c6482bab4196111246c5728354653bd14e Mon Sep 17 00:00:00 2001 From: TiA4f8R <74829229+TiA4f8R@users.noreply.github.com> Date: Sat, 7 May 2022 19:32:12 +0200 Subject: [PATCH] [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. --- .../services/youtube/extractors/YoutubeStreamExtractor.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java index 507c21f28..012700129 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamExtractor.java @@ -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);