Merge pull request #651 from TeamNewPipe/fix/streamType

[YouTube] Fix getting stream type of live streams
This commit is contained in:
Tobi 2021-06-12 17:57:18 +02:00 committed by GitHub
commit 0cb48e36bd
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -62,16 +62,21 @@ public class YoutubeStreamInfoItemExtractor implements StreamInfoItemExtractor {
}
final JsonArray badges = videoInfo.getArray("badges");
for (Object badge : badges) {
if (((JsonObject) badge).getObject("metadataBadgeRenderer").getString("label", EMPTY_STRING).equals("LIVE NOW")) {
for (final Object badge : badges) {
if (((JsonObject) badge).getObject("metadataBadgeRenderer")
.getString("label", EMPTY_STRING).equals("LIVE NOW")) {
return cachedStreamType = StreamType.LIVE_STREAM;
}
}
final String style = videoInfo.getArray("thumbnailOverlays").getObject(0)
.getObject("thumbnailOverlayTimeStatusRenderer").getString("style", EMPTY_STRING);
if (style.equalsIgnoreCase("LIVE")) {
return cachedStreamType = StreamType.LIVE_STREAM;
final JsonArray thumbnailOverlays = videoInfo.getArray("thumbnailOverlays");
for (final Object object : thumbnailOverlays) {
final JsonObject thumbnailOverlay = (JsonObject) object;
if (thumbnailOverlay.has("thumbnailOverlayNowPlayingRenderer")
|| thumbnailOverlay.getObject("thumbnailOverlayTimeStatusRenderer")
.getString("style", EMPTY_STRING).equalsIgnoreCase("LIVE")) {
return cachedStreamType = StreamType.LIVE_STREAM;
}
}
return cachedStreamType = StreamType.VIDEO_STREAM;