Skip to content

Commit e34b4f1

Browse files
committed
[YouTube] Avoid using Consumer
1 parent ef67c7c commit e34b4f1

1 file changed

Lines changed: 22 additions & 26 deletions

File tree

extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube/extractors/YoutubeChannelTabExtractor.java

Lines changed: 22 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323
import java.nio.charset.StandardCharsets;
2424
import java.util.List;
2525
import java.util.Optional;
26-
import java.util.function.Consumer;
2726

2827
import static org.schabi.newpipe.extractor.services.youtube.YoutubeChannelHelper.getChannelResponse;
2928
import static org.schabi.newpipe.extractor.services.youtube.YoutubeChannelHelper.resolveChannelId;
@@ -299,20 +298,20 @@ private Optional<JsonObject> collectItem(@Nonnull final MultiInfoItemsCollector
299298
.getObject("content");
300299

301300
if (richItem.has("videoRenderer")) {
302-
getCommitVideoConsumer(collector, timeAgoParser, channelIds).accept(
301+
getCommitVideoConsumer(collector, timeAgoParser, channelIds,
303302
richItem.getObject("videoRenderer"));
304303
} else if (richItem.has("reelItemRenderer")) {
305-
getCommitReelItemConsumer(collector, timeAgoParser, channelIds).accept(
304+
getCommitReelItemConsumer(collector, timeAgoParser, channelIds,
306305
richItem.getObject("reelItemRenderer"));
307306
} else if (richItem.has("playlistRenderer")) {
308-
getCommitPlaylistConsumer(collector, channelIds).accept(
307+
getCommitPlaylistConsumer(collector, channelIds,
309308
item.getObject("playlistRenderer"));
310309
}
311310
} else if (item.has("gridVideoRenderer")) {
312-
getCommitVideoConsumer(collector, timeAgoParser, channelIds).accept(
311+
getCommitVideoConsumer(collector, timeAgoParser, channelIds,
313312
item.getObject("gridVideoRenderer"));
314313
} else if (item.has("gridPlaylistRenderer")) {
315-
getCommitPlaylistConsumer(collector, channelIds).accept(
314+
getCommitPlaylistConsumer(collector, channelIds,
316315
item.getObject("gridPlaylistRenderer"));
317316
} else if (item.has("gridChannelRenderer")) {
318317
collector.commit(new YoutubeChannelInfoItemExtractor(
@@ -336,13 +335,12 @@ private Optional<JsonObject> collectItem(@Nonnull final MultiInfoItemsCollector
336335
return Optional.empty();
337336
}
338337

339-
@Nonnull
340-
private Consumer<JsonObject> getCommitVideoConsumer(
341-
@Nonnull final MultiInfoItemsCollector collector,
342-
@Nonnull final TimeAgoParser timeAgoParser,
343-
@Nonnull final List<String> channelIds) {
344-
return videoRenderer -> collector.commit(
345-
new YoutubeStreamInfoItemExtractor(videoRenderer, timeAgoParser) {
338+
private void getCommitVideoConsumer(@Nonnull final MultiInfoItemsCollector collector,
339+
@Nonnull final TimeAgoParser timeAgoParser,
340+
@Nonnull final List<String> channelIds,
341+
@Nonnull final JsonObject jsonObject) {
342+
collector.commit(
343+
new YoutubeStreamInfoItemExtractor(jsonObject, timeAgoParser) {
346344
@Override
347345
public String getUploaderName() throws ParsingException {
348346
if (channelIds.size() >= 2) {
@@ -361,13 +359,12 @@ public String getUploaderUrl() throws ParsingException {
361359
});
362360
}
363361

364-
@Nonnull
365-
private Consumer<JsonObject> getCommitReelItemConsumer(
366-
@Nonnull final MultiInfoItemsCollector collector,
367-
@Nonnull final TimeAgoParser timeAgoParser,
368-
@Nonnull final List<String> channelIds) {
369-
return reelItemRenderer -> collector.commit(
370-
new YoutubeReelInfoItemExtractor(reelItemRenderer, timeAgoParser) {
362+
private void getCommitReelItemConsumer(@Nonnull final MultiInfoItemsCollector collector,
363+
@Nonnull final TimeAgoParser timeAgoParser,
364+
@Nonnull final List<String> channelIds,
365+
@Nonnull final JsonObject jsonObject) {
366+
collector.commit(
367+
new YoutubeReelInfoItemExtractor(jsonObject, timeAgoParser) {
371368
@Override
372369
public String getUploaderName() throws ParsingException {
373370
if (channelIds.size() >= 2) {
@@ -386,12 +383,11 @@ public String getUploaderUrl() throws ParsingException {
386383
});
387384
}
388385

389-
@Nonnull
390-
private Consumer<JsonObject> getCommitPlaylistConsumer(
391-
@Nonnull final MultiInfoItemsCollector collector,
392-
@Nonnull final List<String> channelIds) {
393-
return playlistRenderer -> collector.commit(
394-
new YoutubePlaylistInfoItemExtractor(playlistRenderer) {
386+
private void getCommitPlaylistConsumer(@Nonnull final MultiInfoItemsCollector collector,
387+
@Nonnull final List<String> channelIds,
388+
@Nonnull final JsonObject jsonObject) {
389+
collector.commit(
390+
new YoutubePlaylistInfoItemExtractor(jsonObject) {
395391
@Override
396392
public String getUploaderName() throws ParsingException {
397393
if (channelIds.size() >= 2) {

0 commit comments

Comments
 (0)