Update NPE fork and fix comments.

This commit is contained in:
FireMasterK 2021-07-30 00:51:37 +05:30
parent cedb862c20
commit 3bc9d05fc4
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
3 changed files with 14 additions and 10 deletions

View file

@ -16,7 +16,7 @@ dependencies {
implementation 'it.unimi.dsi:fastutil-core:8.5.4' implementation 'it.unimi.dsi:fastutil-core:8.5.4'
implementation 'commons-codec:commons-codec:1.15' implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bouncycastle:bcprov-jdk15on:1.69' implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:b603630729f669a28a43b708520131f66fa45a0f' implementation 'com.github.FireMasterK.NewPipeExtractor:NewPipeExtractor:cd75149f661fb6ae7b7398a149a6661d51afee45'
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751' implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4' implementation 'com.fasterxml.jackson.core:jackson-core:2.12.4'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.4' implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.4'

View file

@ -188,7 +188,7 @@ public class ServerLauncher extends MultithreadedHttpServerLauncher {
})).map(GET, "/nextpage/comments/:videoId", AsyncServlet.ofBlocking(executor, request -> { })).map(GET, "/nextpage/comments/:videoId", AsyncServlet.ofBlocking(executor, request -> {
try { try {
return getJsonResponse(ResponseHelper.commentsPageResponse(request.getPathParameter("videoId"), return getJsonResponse(ResponseHelper.commentsPageResponse(request.getPathParameter("videoId"),
request.getQueryParameter("url")), "public, max-age=3600"); request.getQueryParameter("nextpage")), "public, max-age=3600");
} catch (Exception e) { } catch (Exception e) {
return getErrorResponse(e); return getErrorResponse(e);
} }

View file

@ -482,9 +482,10 @@ public class ResponseHelper {
}); });
String nextpage = null; String nextpage = null;
if (info.hasNextPage()) {
if (info.getNextPage() != null) Page page = info.getNextPage();
nextpage = info.getNextPage().getUrl(); nextpage = Constants.mapper.writeValueAsString(page);
}
CommentsPage commentsItem = new CommentsPage(comments, nextpage); CommentsPage commentsItem = new CommentsPage(comments, nextpage);
@ -492,11 +493,13 @@ public class ResponseHelper {
} }
public static final byte[] commentsPageResponse(String videoId, String url) throws Exception { public static final byte[] commentsPageResponse(String videoId, String prevpageStr) throws Exception {
Page prevpage = Constants.mapper.readValue(prevpageStr, Page.class);
CommentsInfo init = commentsCache.get(videoId); CommentsInfo init = commentsCache.get(videoId);
InfoItemsPage<CommentsInfoItem> info = CommentsInfo.getMoreItems(init, new Page(url)); InfoItemsPage<CommentsInfoItem> info = CommentsInfo.getMoreItems(init, prevpage);
List<Comment> comments = new ObjectArrayList<>(); List<Comment> comments = new ObjectArrayList<>();
@ -508,9 +511,10 @@ public class ResponseHelper {
}); });
String nextpage = null; String nextpage = null;
if (info.hasNextPage()) {
if (info.getNextPage() != null) Page page = info.getNextPage();
nextpage = info.getNextPage().getUrl(); nextpage = Constants.mapper.writeValueAsString(page);
}
CommentsPage commentsItem = new CommentsPage(comments, nextpage); CommentsPage commentsItem = new CommentsPage(comments, nextpage);