-Fixed live stream info using video stream type.
This commit is contained in:
parent
690f241357
commit
837dbd6b86
|
@ -441,7 +441,7 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
@Override
|
@Override
|
||||||
@Nonnull
|
@Nonnull
|
||||||
public List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException {
|
public List<Subtitles> getSubtitlesDefault() throws IOException, ExtractionException {
|
||||||
return getSubtitles(SubtitlesFormat.VTT);
|
return getSubtitles(SubtitlesFormat.TTML);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -457,7 +457,17 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public StreamType getStreamType() throws ParsingException {
|
public StreamType getStreamType() throws ParsingException {
|
||||||
//todo: if implementing livestream support this value should be generated dynamically
|
assertPageFetched();
|
||||||
|
if (playerArgs == null) return StreamType.NONE;
|
||||||
|
|
||||||
|
try {
|
||||||
|
if (playerArgs.has("ps") && playerArgs.get("ps").toString().equals("live") ||
|
||||||
|
playerArgs.get(URL_ENCODED_FMT_STREAM_MAP).toString().isEmpty()) {
|
||||||
|
return StreamType.LIVE_STREAM;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new ParsingException("Could not get hls manifest url", e);
|
||||||
|
}
|
||||||
return StreamType.VIDEO_STREAM;
|
return StreamType.VIDEO_STREAM;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -547,7 +557,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
doc = Jsoup.parse(pageContent, getCleanUrl());
|
doc = Jsoup.parse(pageContent, getCleanUrl());
|
||||||
|
|
||||||
final String playerUrl;
|
final String playerUrl;
|
||||||
// TODO: use embedded videos to fetch DASH manifest for all videos
|
|
||||||
// Check if the video is age restricted
|
// Check if the video is age restricted
|
||||||
if (pageContent.contains("<meta property=\"og:restrictions:age")) {
|
if (pageContent.contains("<meta property=\"og:restrictions:age")) {
|
||||||
final EmbeddedInfo info = getEmbeddedInfo();
|
final EmbeddedInfo info = getEmbeddedInfo();
|
||||||
|
@ -595,15 +604,8 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
JsonObject playerArgs;
|
JsonObject playerArgs;
|
||||||
|
|
||||||
//attempt to load the youtube js player JSON arguments
|
//attempt to load the youtube js player JSON arguments
|
||||||
boolean isLiveStream = false; //used to determine if this is a livestream or not
|
|
||||||
try {
|
try {
|
||||||
playerArgs = playerConfig.getObject("args");
|
playerArgs = playerConfig.getObject("args");
|
||||||
|
|
||||||
// check if we have a live stream. We need to filter it, since its not yet supported.
|
|
||||||
if ((playerArgs.has("ps") && playerArgs.get("ps").toString().equals("live"))
|
|
||||||
|| (playerArgs.get(URL_ENCODED_FMT_STREAM_MAP).toString().isEmpty())) {
|
|
||||||
isLiveStream = true;
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new ParsingException("Could not parse yt player config", e);
|
throw new ParsingException("Could not parse yt player config", e);
|
||||||
}
|
}
|
||||||
|
@ -816,11 +818,6 @@ public class YoutubeStreamExtractor extends StreamExtractor {
|
||||||
"&sts=" + sts + "&ps=default&gl=US&hl=en";
|
"&sts=" + sts + "&ps=default&gl=US&hl=en";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Nonnull
|
|
||||||
private static String getSubtitleFormatUrl(final String baseUrl, final SubtitlesFormat format) {
|
|
||||||
return baseUrl.replaceAll("&fmt=[^&]*", "") + "&fmt=" + format.getExtension();
|
|
||||||
}
|
|
||||||
|
|
||||||
private Map<String, ItagItem> getItags(String encodedUrlMapKey, ItagItem.ItagType itagTypeWanted) throws ParsingException {
|
private Map<String, ItagItem> getItags(String encodedUrlMapKey, ItagItem.ItagType itagTypeWanted) throws ParsingException {
|
||||||
Map<String, ItagItem> urlAndItags = new LinkedHashMap<>();
|
Map<String, ItagItem> urlAndItags = new LinkedHashMap<>();
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue