Add support for extracting replies and update NPE.

This commit is contained in:
FireMasterK 2021-09-22 15:18:24 +01:00
parent 40caec2809
commit 29fb9b02a2
No known key found for this signature in database
GPG Key ID: 49451E4482CC5BCD
3 changed files with 22 additions and 11 deletions

View File

@ -16,7 +16,7 @@ dependencies {
implementation 'it.unimi.dsi:fastutil-core:8.5.6'
implementation 'commons-codec:commons-codec:1.15'
implementation 'org.bouncycastle:bcprov-jdk15on:1.69'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:62b87552f51022be76804f3bed65447aeb9fce9b'
implementation 'com.github.TeamNewPipe:NewPipeExtractor:a9d214478df831ff2d97ea7046102d716822e4ea'
implementation 'com.github.TeamNewPipe:nanojson:1d9e1aea9049fc9f85e68b43ba39fe7be1c1f751'
implementation 'com.fasterxml.jackson.core:jackson-core:2.12.5'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.12.5'

View File

@ -459,10 +459,15 @@ public class ResponseHelper {
List<Comment> comments = new ObjectArrayList<>();
info.getRelatedItems().forEach(comment -> {
comments.add(new Comment(comment.getUploaderName(), rewriteURL(comment.getUploaderAvatarUrl()),
comment.getCommentId(), comment.getCommentText(), comment.getTextualUploadDate(),
substringYouTube(comment.getUploaderUrl()), comment.getLikeCount(), comment.isHeartedByUploader(),
comment.isPinned(), comment.isUploaderVerified()));
try {
comments.add(new Comment(comment.getUploaderName(), rewriteURL(comment.getUploaderAvatarUrl()),
comment.getCommentId(), comment.getCommentText(), comment.getTextualUploadDate(),
substringYouTube(comment.getUploaderUrl()),
Constants.mapper.writeValueAsString(comment.getReplies()), comment.getLikeCount(),
comment.isHeartedByUploader(), comment.isPinned(), comment.isUploaderVerified()));
} catch (JsonProcessingException e) {
ExceptionHandler.handle(e);
}
});
String nextpage = null;
@ -488,10 +493,15 @@ public class ResponseHelper {
List<Comment> comments = new ObjectArrayList<>();
info.getItems().forEach(comment -> {
comments.add(new Comment(comment.getUploaderName(), rewriteURL(comment.getUploaderAvatarUrl()),
comment.getCommentId(), comment.getCommentText(), comment.getTextualUploadDate(),
substringYouTube(comment.getUploaderUrl()), comment.getLikeCount(), comment.isHeartedByUploader(),
comment.isPinned(), comment.isUploaderVerified()));
try {
comments.add(new Comment(comment.getUploaderName(), rewriteURL(comment.getUploaderAvatarUrl()),
comment.getCommentId(), comment.getCommentText(), comment.getTextualUploadDate(),
substringYouTube(comment.getUploaderUrl()),
Constants.mapper.writeValueAsString(comment.getReplies()), comment.getLikeCount(),
comment.isHeartedByUploader(), comment.isPinned(), comment.isUploaderVerified()));
} catch (JsonProcessingException e) {
ExceptionHandler.handle(e);
}
});
String nextpage = null;

View File

@ -2,18 +2,19 @@ package me.kavin.piped.utils.obj;
public class Comment {
public String author, thumbnail, commentId, commentText, commentedTime, commentorUrl;
public String author, thumbnail, commentId, commentText, commentedTime, commentorUrl, repliesPage;
public int likeCount;
public boolean hearted, pinned, verified;
public Comment(String author, String thumbnail, String commentId, String commentText, String commentedTime,
String commentorUrl, int likeCount, boolean hearted, boolean pinned, boolean verified) {
String commentorUrl, String repliesPage, int likeCount, boolean hearted, boolean pinned, boolean verified) {
this.author = author;
this.thumbnail = thumbnail;
this.commentId = commentId;
this.commentText = commentText;
this.commentedTime = commentedTime;
this.commentorUrl = commentorUrl;
this.repliesPage = repliesPage;
this.likeCount = likeCount;
this.hearted = hearted;
this.pinned = pinned;