From 1498e1905e4b50a4a4d762d15c9e60c8b31cbe43 Mon Sep 17 00:00:00 2001 From: TobiGr Date: Wed, 31 Mar 2021 13:30:06 +0200 Subject: [PATCH] Reduce number of type conversions in YouTubeSearchExtractor.collectStreamsFrom by introducing new variable --- .../extractors/YoutubeSearchExtractor.java | 23 ++++++++++--------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java index c444a6ae5..71f5d8715 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeSearchExtractor.java @@ -192,19 +192,20 @@ public class YoutubeSearchExtractor extends SearchExtractor { } } - private void collectStreamsFrom(final InfoItemsSearchCollector collector, final JsonArray videos) throws NothingFoundException, ParsingException { + private void collectStreamsFrom(final InfoItemsSearchCollector collector, final JsonArray contents) throws NothingFoundException, ParsingException { final TimeAgoParser timeAgoParser = getTimeAgoParser(); - for (Object item : videos) { - if (((JsonObject) item).has("backgroundPromoRenderer")) { - throw new NothingFoundException(getTextFromObject(((JsonObject) item) - .getObject("backgroundPromoRenderer").getObject("bodyText"))); - } else if (((JsonObject) item).has("videoRenderer")) { - collector.commit(new YoutubeStreamInfoItemExtractor(((JsonObject) item).getObject("videoRenderer"), timeAgoParser)); - } else if (((JsonObject) item).has("channelRenderer")) { - collector.commit(new YoutubeChannelInfoItemExtractor(((JsonObject) item).getObject("channelRenderer"))); - } else if (((JsonObject) item).has("playlistRenderer")) { - collector.commit(new YoutubePlaylistInfoItemExtractor(((JsonObject) item).getObject("playlistRenderer"))); + for (Object content : contents) { + final JsonObject item = (JsonObject) content; + if (item.has("backgroundPromoRenderer")) { + throw new NothingFoundException(getTextFromObject( + item.getObject("backgroundPromoRenderer").getObject("bodyText"))); + } else if (item.has("videoRenderer")) { + collector.commit(new YoutubeStreamInfoItemExtractor(item.getObject("videoRenderer"), timeAgoParser)); + } else if (item.has("channelRenderer")) { + collector.commit(new YoutubeChannelInfoItemExtractor(item.getObject("channelRenderer"))); + } else if (item.has("playlistRenderer")) { + collector.commit(new YoutubePlaylistInfoItemExtractor(item.getObject("playlistRenderer"))); } } }