Skip to content

Commit 2f3920c

Browse files
committed
[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.
1 parent 4158fc4 commit 2f3920c

1 file changed

Lines changed: 4 additions & 1 deletion

File tree

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020

2121
package org.schabi.newpipe.extractor.services.youtube.extractors;
2222

23+
import static org.schabi.newpipe.extractor.services.youtube.ItagItem.APPROX_DURATION_MS_UNKNOWN;
2324
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CONTENT_CHECK_OK;
2425
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.CPN;
2526
import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper.RACY_CHECK_OK;
@@ -1396,9 +1397,11 @@ private void buildAndAddItagInfoToList(
13961397
itagItem.setAudioChannels(formatData.getInt("audioChannels"));
13971398
}
13981399

1399-
// YouTube return the content length as a string
1400+
// YouTube return the content length and the approximate duration as strings
14001401
itagItem.setContentLength(Long.parseLong(formatData.getString("contentLength",
14011402
String.valueOf(CONTENT_LENGTH_UNKNOWN))));
1403+
itagItem.setApproxDurationMs(Long.parseLong(formatData.getString("approxDurationMs",
1404+
String.valueOf(APPROX_DURATION_MS_UNKNOWN))));
14021405

14031406
final ItagInfo itagInfo = new ItagInfo(streamUrl, itagItem);
14041407

0 commit comments

Comments
 (0)