Skip to content

Commit

Permalink
Merge pull request #658 from TeamNewPipe/revert-651-fix/streamType
Browse files Browse the repository at this point in the history
[YouTube] Fix getting stream type of live streams
  • Loading branch information
B0pol authored Jun 23, 2021
2 parents fe29c78 + 361f142 commit 65fd874
Showing 1 changed file with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,18 +63,17 @@ public StreamType getStreamType() {

final JsonArray badges = videoInfo.getArray("badges");
for (final Object badge : badges) {
if (((JsonObject) badge).getObject("metadataBadgeRenderer")
.getString("label", EMPTY_STRING).equals("LIVE NOW")) {
final JsonObject badgeRenderer = ((JsonObject) badge).getObject("metadataBadgeRenderer");
if (badgeRenderer.getString("style", EMPTY_STRING).equals("BADGE_STYLE_TYPE_LIVE_NOW") ||
badgeRenderer.getString("label", EMPTY_STRING).equals("LIVE NOW")) {
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")) {
for (final Object overlay : videoInfo.getArray("thumbnailOverlays")) {
final String style = ((JsonObject) overlay)
.getObject("thumbnailOverlayTimeStatusRenderer").getString("style", EMPTY_STRING);
if (style.equalsIgnoreCase("LIVE")) {
return cachedStreamType = StreamType.LIVE_STREAM;
}
}
Expand Down

0 comments on commit 65fd874

Please sign in to comment.