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