diff --git a/build.gradle b/build.gradle index c6ce69d..f701ce6 100644 --- a/build.gradle +++ b/build.gradle @@ -16,7 +16,7 @@ dependencies { implementation 'it.unimi.dsi:fastutil-core:8.5.8' implementation 'commons-codec:commons-codec:1.15' implementation 'org.bouncycastle:bcprov-jdk15on:1.70' - implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:4963fdabd4842b2f1aeb12506e105798b30e0cfa' + implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:87df3331f419e1a93690d3f34eb50c7c14ff4aa1' implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' implementation 'com.fasterxml.jackson.core:jackson-core:2.13.1' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.13.1' diff --git a/src/main/java/me/kavin/piped/utils/ResponseHelper.java b/src/main/java/me/kavin/piped/utils/ResponseHelper.java index d6e83d1..1a8d6c1 100644 --- a/src/main/java/me/kavin/piped/utils/ResponseHelper.java +++ b/src/main/java/me/kavin/piped/utils/ResponseHelper.java @@ -1,9 +1,6 @@ package me.kavin.piped.utils; import com.fasterxml.jackson.core.JsonProcessingException; -import com.github.benmanes.caffeine.cache.Caffeine; -import com.github.benmanes.caffeine.cache.LoadingCache; -import com.github.benmanes.caffeine.cache.Scheduler; import com.grack.nanojson.JsonObject; import com.grack.nanojson.JsonWriter; import com.rometools.rome.feed.synd.*; @@ -67,11 +64,6 @@ import static org.schabi.newpipe.extractor.services.youtube.YoutubeParsingHelper public class ResponseHelper { - public static final LoadingCache commentsCache = Caffeine.newBuilder() - .expireAfterWrite(1, TimeUnit.HOURS) - .scheduler(Scheduler.systemScheduler()) - .maximumSize(1000).build(key -> CommentsInfo.getInfo("https://www.youtube.com/watch?v=" + key)); - public static byte[] streamsResponse(String videoId) throws Exception { CompletableFuture futureStream = CompletableFuture.supplyAsync(() -> { @@ -457,7 +449,7 @@ public class ResponseHelper { public static byte[] commentsResponse(String videoId) throws Exception { - CommentsInfo info = commentsCache.get(videoId); + CommentsInfo info = CommentsInfo.getInfo("https://www.youtube.com/watch?v=" + videoId); List comments = new ObjectArrayList<>(); @@ -492,9 +484,7 @@ public class ResponseHelper { Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class); - CommentsInfo init = commentsCache.get(videoId); - - InfoItemsPage info = CommentsInfo.getMoreItems(init, prevpage); + InfoItemsPage info = CommentsInfo.getMoreItems(YOUTUBE_SERVICE, "https://www.youtube.com/watch?v=" + videoId, prevpage); List comments = new ObjectArrayList<>(); @@ -519,7 +509,7 @@ public class ResponseHelper { nextpage = Constants.mapper.writeValueAsString(page); } - CommentsPage commentsItem = new CommentsPage(comments, nextpage, init.isCommentsDisabled()); + CommentsPage commentsItem = new CommentsPage(comments, nextpage, false); return Constants.mapper.writeValueAsBytes(commentsItem);