From c998012c2894f09a4bcc270d1ebafd3e6d35ba16 Mon Sep 17 00:00:00 2001 From: Tobi Date: Fri, 18 Jun 2021 09:20:32 +0200 Subject: [PATCH 1/3] Revert "[YouTube] Fix getting stream type of live streams" --- .../YoutubeStreamInfoItemExtractor.java | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java index cc0ddac7e2..4fa6caab94 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java @@ -62,21 +62,16 @@ 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")) { + for (Object badge : badges) { + if (((JsonObject) badge).getObject("metadataBadgeRenderer").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")) { - 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; } return cachedStreamType = StreamType.VIDEO_STREAM; From 58f109ddeccca9839fb78b722364884222032472 Mon Sep 17 00:00:00 2001 From: bopol Date: Wed, 23 Jun 2021 11:15:40 +0200 Subject: [PATCH 2/3] adress stypox review --- .../extractors/YoutubeStreamInfoItemExtractor.java | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java index 4fa6caab94..4183fc0a2d 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java @@ -62,16 +62,18 @@ public StreamType getStreamType() { } final JsonArray badges = videoInfo.getArray("badges"); - for (Object badge : badges) { + 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; + 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; + } } return cachedStreamType = StreamType.VIDEO_STREAM; From 361f142621b167bd033548d5c5f67804f44a561f Mon Sep 17 00:00:00 2001 From: bopol Date: Wed, 23 Jun 2021 11:25:59 +0200 Subject: [PATCH 3/3] Use badge style instead of label --- .../youtube/extractors/YoutubeStreamInfoItemExtractor.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java index 4183fc0a2d..f7cd38d946 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeStreamInfoItemExtractor.java @@ -63,7 +63,9 @@ 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; } }