|
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; |
@@ -1204,16 +1209,27 @@ private <I extends ItagFormat<?>> DeliveryData buildDeliveryData(final ItagInfo< |
1204 | 1209 | } |
1205 | 1210 |
|
1206 | 1211 | // DASH |
1207 | | - // TODO |
1208 | | - if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) { |
1209 | | - // OTF DASH MANIFEST |
1210 | | - } else if (isPostLive()) { |
1211 | | - // YoutubePostLiveStreamDvrDashManifestCreator |
| 1212 | + // Duration in seconds used as fallback inside the dashManifestCreators |
| 1213 | + long durationInSec; |
| 1214 | + try { |
| 1215 | + durationInSec = getLength(); |
| 1216 | + } catch (final ParsingException e) { |
| 1217 | + durationInSec = -1; |
1212 | 1218 | } |
1213 | | - // YoutubeProgressiveDashManifestCreator |
1214 | 1219 |
|
| 1220 | + return new SimpleDASHManifestDeliveryDataImpl( |
| 1221 | + getDashManifestCreatorConstructor(itagInfo).apply(itagInfo, durationInSec)); |
| 1222 | + } |
1215 | 1223 |
|
1216 | | - return null; |
| 1224 | + private BiFunction<ItagInfo<?>, Long, DashManifestCreator> getDashManifestCreatorConstructor( |
| 1225 | + final ItagInfo<?> itagInfo |
| 1226 | + ) { |
| 1227 | + if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) { |
| 1228 | + return YoutubeOtfDashManifestCreator::new; |
| 1229 | + } else if (isPostLive()) { |
| 1230 | + return YoutubePostLiveStreamDvrDashManifestCreator::new; |
| 1231 | + } |
| 1232 | + return YoutubeProgressiveDashManifestCreator::new; |
1217 | 1233 | } |
1218 | 1234 |
|
1219 | 1235 | @Nonnull |
|
0 commit comments