|
66 | 66 | import org.schabi.newpipe.extractor.services.youtube.YoutubeJavaScriptExtractor; |
67 | 67 | import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper; |
68 | 68 | import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecrypter; |
| 69 | +import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubeOtfDashManifestCreator; |
| 70 | +import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubePostLiveStreamDvrDashManifestCreator; |
| 71 | +import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubeProgressiveDashManifestCreator; |
69 | 72 | import org.schabi.newpipe.extractor.services.youtube.itag.delivery.HLSItagFormatDeliveryData; |
70 | 73 | import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ItagFormatDeliveryData; |
71 | 74 | import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ProgressiveHTTPItagFormatDeliveryData; |
|
82 | 85 | import org.schabi.newpipe.extractor.stream.StreamExtractor; |
83 | 86 | import org.schabi.newpipe.extractor.stream.StreamSegment; |
84 | 87 | import org.schabi.newpipe.extractor.streamdata.delivery.DeliveryData; |
| 88 | +import org.schabi.newpipe.extractor.streamdata.delivery.dashmanifestcreator.DashManifestCreator; |
| 89 | +import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleDASHManifestDeliveryDataImpl; |
85 | 90 | import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleHLSDeliveryDataImpl; |
86 | 91 | import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleProgressiveHTTPDeliveryDataImpl; |
87 | 92 | import org.schabi.newpipe.extractor.streamdata.format.registry.SubtitleFormatRegistry; |
@@ -1254,16 +1259,27 @@ private <I extends ItagFormat<?>> DeliveryData buildDeliveryData(final ItagInfo< |
1254 | 1259 | } |
1255 | 1260 |
|
1256 | 1261 | // DASH |
1257 | | - // TODO |
1258 | | - if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) { |
1259 | | - // OTF DASH MANIFEST |
1260 | | - } else if (isPostLive()) { |
1261 | | - // YoutubePostLiveStreamDvrDashManifestCreator |
| 1262 | + // Duration in seconds used as fallback inside the dashManifestCreators |
| 1263 | + long durationInSec; |
| 1264 | + try { |
| 1265 | + durationInSec = getLength(); |
| 1266 | + } catch (final ParsingException e) { |
| 1267 | + durationInSec = -1; |
1262 | 1268 | } |
1263 | | - // YoutubeProgressiveDashManifestCreator |
1264 | 1269 |
|
| 1270 | + return new SimpleDASHManifestDeliveryDataImpl( |
| 1271 | + getDashManifestCreatorConstructor(itagInfo).apply(itagInfo, durationInSec)); |
| 1272 | + } |
1265 | 1273 |
|
1266 | | - return null; |
| 1274 | + private BiFunction<ItagInfo<?>, Long, DashManifestCreator> getDashManifestCreatorConstructor( |
| 1275 | + final ItagInfo<?> itagInfo |
| 1276 | + ) { |
| 1277 | + if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) { |
| 1278 | + return YoutubeOtfDashManifestCreator::new; |
| 1279 | + } else if (isPostLive()) { |
| 1280 | + return YoutubePostLiveStreamDvrDashManifestCreator::new; |
| 1281 | + } |
| 1282 | + return YoutubeProgressiveDashManifestCreator::new; |
1267 | 1283 | } |
1268 | 1284 |
|
1269 | 1285 | @Nonnull |
|
0 commit comments