YT: Use new DASHManifestCreators
This commit is contained in:
parent
1d0a27cd60
commit
411b6c130d
|
@ -17,8 +17,8 @@ import javax.annotation.Nonnull;
|
|||
|
||||
public class YoutubePostLiveStreamDvrDashManifestCreator extends AbstractYoutubeDashManifestCreator {
|
||||
|
||||
protected YoutubePostLiveStreamDvrDashManifestCreator(@Nonnull final ItagInfo<?> itagInfo,
|
||||
final long durationSecondsFallback) {
|
||||
public YoutubePostLiveStreamDvrDashManifestCreator(@Nonnull final ItagInfo<?> itagInfo,
|
||||
final long durationSecondsFallback) {
|
||||
super(itagInfo, durationSecondsFallback);
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,9 @@ import org.schabi.newpipe.extractor.localization.TimeAgoPatternsManager;
|
|||
import org.schabi.newpipe.extractor.services.youtube.YoutubeJavaScriptExtractor;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper;
|
||||
import org.schabi.newpipe.extractor.services.youtube.YoutubeThrottlingDecrypter;
|
||||
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubeOtfDashManifestCreator;
|
||||
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubePostLiveStreamDvrDashManifestCreator;
|
||||
import org.schabi.newpipe.extractor.services.youtube.dashmanifestcreator.YoutubeProgressiveDashManifestCreator;
|
||||
import org.schabi.newpipe.extractor.services.youtube.itag.delivery.HLSItagFormatDeliveryData;
|
||||
import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ItagFormatDeliveryData;
|
||||
import org.schabi.newpipe.extractor.services.youtube.itag.delivery.ProgressiveHTTPItagFormatDeliveryData;
|
||||
|
@ -82,6 +85,8 @@ import org.schabi.newpipe.extractor.stream.Privacy;
|
|||
import org.schabi.newpipe.extractor.stream.StreamExtractor;
|
||||
import org.schabi.newpipe.extractor.stream.StreamSegment;
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.DeliveryData;
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.dashmanifestcreator.DashManifestCreator;
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleDASHManifestDeliveryDataImpl;
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleHLSDeliveryDataImpl;
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl.SimpleProgressiveHTTPDeliveryDataImpl;
|
||||
import org.schabi.newpipe.extractor.streamdata.format.registry.SubtitleFormatRegistry;
|
||||
|
@ -1254,16 +1259,27 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
|||
}
|
||||
|
||||
// DASH
|
||||
// TODO
|
||||
if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) {
|
||||
// OTF DASH MANIFEST
|
||||
} else if (isPostLive()) {
|
||||
// YoutubePostLiveStreamDvrDashManifestCreator
|
||||
// Duration in seconds used as fallback inside the dashManifestCreators
|
||||
long durationInSec;
|
||||
try {
|
||||
durationInSec = getLength();
|
||||
} catch (final ParsingException e) {
|
||||
durationInSec = -1;
|
||||
}
|
||||
// YoutubeProgressiveDashManifestCreator
|
||||
|
||||
return new SimpleDASHManifestDeliveryDataImpl(
|
||||
getDashManifestCreatorConstructor(itagInfo).apply(itagInfo, durationInSec));
|
||||
}
|
||||
|
||||
return null;
|
||||
private BiFunction<ItagInfo<?>, Long, DashManifestCreator> getDashManifestCreatorConstructor(
|
||||
final ItagInfo<?> itagInfo
|
||||
) {
|
||||
if ("FORMAT_STREAM_TYPE_OTF".equalsIgnoreCase(itagInfo.getType())) {
|
||||
return YoutubeOtfDashManifestCreator::new;
|
||||
} else if (isPostLive()) {
|
||||
return YoutubePostLiveStreamDvrDashManifestCreator::new;
|
||||
}
|
||||
return YoutubeProgressiveDashManifestCreator::new;
|
||||
}
|
||||
|
||||
@Nonnull
|
||||
|
|
|
@ -1,18 +1,12 @@
|
|||
package org.schabi.newpipe.extractor.streamdata.delivery;
|
||||
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.dashmanifestcreator.DashManifestCreator;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
public interface DASHManifestDeliveryData extends DASHDeliveryData {
|
||||
/**
|
||||
* Returns the base url for the DashManifest.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
// TODO: Check removal
|
||||
@Nonnull
|
||||
default String getBaseUrl() {
|
||||
return "";
|
||||
}
|
||||
DashManifestCreator getDashManifestCreator();
|
||||
|
||||
String getManifestAsString();
|
||||
String getCachedDashManifestAsString();
|
||||
}
|
||||
|
|
|
@ -1,9 +1,9 @@
|
|||
package org.schabi.newpipe.extractor.streamdata.delivery.simpleimpl;
|
||||
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.DASHManifestDeliveryData;
|
||||
import org.schabi.newpipe.extractor.streamdata.delivery.dashmanifestcreator.DashManifestCreator;
|
||||
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
import javax.annotation.Nonnull;
|
||||
|
||||
|
@ -21,14 +21,27 @@ import javax.annotation.Nonnull;
|
|||
public class SimpleDASHManifestDeliveryDataImpl extends AbstractDeliveryDataImpl
|
||||
implements DASHManifestDeliveryData {
|
||||
@Nonnull
|
||||
private final Supplier<String> dashManifestBuilder;
|
||||
private final DashManifestCreator dashManifestCreator;
|
||||
|
||||
public SimpleDASHManifestDeliveryDataImpl(@Nonnull final Supplier<String> dashManifestBuilder) {
|
||||
this.dashManifestBuilder = Objects.requireNonNull(dashManifestBuilder);
|
||||
private String cachedDashManifest;
|
||||
|
||||
public SimpleDASHManifestDeliveryDataImpl(
|
||||
@Nonnull final DashManifestCreator dashManifestCreator
|
||||
) {
|
||||
this.dashManifestCreator = Objects.requireNonNull(dashManifestCreator);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getManifestAsString() {
|
||||
return dashManifestBuilder.get();
|
||||
@Nonnull
|
||||
public DashManifestCreator getDashManifestCreator() {
|
||||
return dashManifestCreator;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCachedDashManifestAsString() {
|
||||
if (cachedDashManifest != null) {
|
||||
cachedDashManifest = getDashManifestCreator().generateManifest();
|
||||
}
|
||||
return cachedDashManifest;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue