Skip to content

Commit

Permalink
Merge pull request #651 from TeamNewPipe/fix/streamType
Browse files Browse the repository at this point in the history
[YouTube] Fix getting stream type of live streams
  • Loading branch information
TobiGr authored Jun 12, 2021
2 parents a275750 + 6762fe3 commit 0cb48e3
Showing 1 changed file with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,21 @@ public StreamType getStreamType() {
}

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;
Expand Down

0 comments on commit 0cb48e3

Please sign in to comment.