|
67 | 67 | import org.schabi.newpipe.extractor.services.youtube.YoutubeJavaScriptExtractor; |
68 | 68 | import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper; |
69 | 69 | import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecrypter; |
| 70 | +import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubeOtfDashManifestCreator; |
| 71 | +import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubePostLiveStreamDvrDashManifestCreator; |
| 72 | +import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubeProgressiveDashManifestCreator; |
70 | 73 | import org.schabi.newpipe.extractor.services.youtube.itag.delivery.HLSItagFormatDeliveryData; |
71 | 74 | import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ItagFormatDeliveryData; |
72 | 75 | import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ProgressiveHTTPItagFormatDeliveryData; |
|
83 | 86 | import org.schabi.newpipe.extractor.stream.StreamExtractor; |
84 | 87 | import org.schabi.newpipe.extractor.stream.StreamSegment; |
85 | 88 | import org.schabi.newpipe.extractor.streamdata.delivery.DeliveryData; |
| 89 | +import org.schabi.newpipe.extractor.streamdata.delivery.dashmanifestcreator.DashManifestCreator; |
| 90 | +import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleDASHManifestDeliveryDataImpl; |
86 | 91 | import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleHLSDeliveryDataImpl; |
87 | 92 | import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleProgressiveHTTPDeliveryDataImpl; |
88 | 93 | import org.schabi.newpipe.extractor.streamdata.format.registry.SubtitleFormatRegistry; |
@@ -1208,16 +1213,27 @@ private <I extends ItagFormat<?>> DeliveryData buildDeliveryData(final ItagInfo< |
1208 | 1213 | } |
1209 | 1214 |
|
1210 | 1215 | // DASH |
1211 | | - // TODO |
1212 | | - if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) { |
1213 | | - // OTF DASH MANIFEST |
1214 | | - } else if (isPostLive()) { |
1215 | | - // YoutubePostLiveStreamDvrDashManifestCreator |
| 1216 | + // Duration in seconds used as fallback inside the dashManifestCreators |
| 1217 | + long durationInSec; |
| 1218 | + try { |
| 1219 | + durationInSec = getLength(); |
| 1220 | + } catch (final ParsingException e) { |
| 1221 | + durationInSec = -1; |
1216 | 1222 | } |
1217 | | - // YoutubeProgressiveDashManifestCreator |
1218 | 1223 |
|
| 1224 | + return new SimpleDASHManifestDeliveryDataImpl( |
| 1225 | + getDashManifestCreatorConstructor(itagInfo).apply(itagInfo, durationInSec)); |
| 1226 | + } |
1219 | 1227 |
|
1220 | | - return null; |
| 1228 | + private BiFunction<ItagInfo<?>, Long, DashManifestCreator> getDashManifestCreatorConstructor( |
| 1229 | + final ItagInfo<?> itagInfo |
| 1230 | + ) { |
| 1231 | + if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) { |
| 1232 | + return YoutubeOtfDashManifestCreator::new; |
| 1233 | + } else if (isPostLive()) { |
| 1234 | + return YoutubePostLiveStreamDvrDashManifestCreator::new; |
| 1235 | + } |
| 1236 | + return YoutubeProgressiveDashManifestCreator::new; |
1221 | 1237 | } |
1222 | 1238 |
|
1223 | 1239 | @Nonnull |
|
0 commit comments