From 1d2ef196bebdba45651340ff52901526d84dd532 Mon Sep 17 00:00:00 2001 From: Kavin <20838718+FireMasterK@users.noreply.github.com> Date: Wed, 30 Aug 2023 13:23:43 +0100 Subject: [PATCH] Fix channel save new video handling. --- .../me/kavin/piped/utils/DatabaseHelper.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/src/main/java/me/kavin/piped/utils/DatabaseHelper.java b/src/main/java/me/kavin/piped/utils/DatabaseHelper.java index 9b9ae91..93563cc 100644 --- a/src/main/java/me/kavin/piped/utils/DatabaseHelper.java +++ b/src/main/java/me/kavin/piped/utils/DatabaseHelper.java @@ -214,9 +214,11 @@ public class DatabaseHelper { CollectionUtils.collectPreloadedTabs(info.getTabs()) .stream() .parallel() - .map(tab -> { + .mapMulti((tab, consumer) -> { try { - return ChannelTabInfo.getInfo(YOUTUBE_SERVICE, tab).getRelatedItems(); + ChannelTabInfo.getInfo(YOUTUBE_SERVICE, tab) + .getRelatedItems() + .forEach(consumer); } catch (ExtractionException | IOException e) { throw new RuntimeException(e); } @@ -224,11 +226,11 @@ public class DatabaseHelper { .filter(StreamInfoItem.class::isInstance) .map(StreamInfoItem.class::cast) .forEach(item -> { - long time = item.getUploadDate() != null - ? item.getUploadDate().offsetDateTime().toInstant().toEpochMilli() - : System.currentTimeMillis(); - if ((System.currentTimeMillis() - time) < TimeUnit.DAYS.toMillis(Constants.FEED_RETENTION)) - VideoHelpers.handleNewVideo(item.getUrl(), time, channel); + long time = item.getUploadDate() != null + ? item.getUploadDate().offsetDateTime().toInstant().toEpochMilli() + : System.currentTimeMillis(); + if ((System.currentTimeMillis() - time) < TimeUnit.DAYS.toMillis(Constants.FEED_RETENTION)) + VideoHelpers.handleNewVideo(item.getUrl(), time, channel); }); });