Skip to content

Commit

Permalink
add getUploaderVerified() in CommentsInfoItemExtractors
Browse files Browse the repository at this point in the history
  • Loading branch information
B0pol committed Jan 22, 2021
1 parent ca40df2 commit 6e13b35
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ public class CommentsInfoItem extends InfoItem {
private String uploaderName;
private String uploaderAvatarUrl;
private String uploaderUrl;
private boolean uploaderVerified;
private String textualUploadDate;
@Nullable
private DateWrapper uploadDate;
Expand Down Expand Up @@ -94,4 +95,12 @@ public void setHeartedByUploader(boolean isHeartedByUploader) {
public boolean getHeartedByUploader() {
return this.heartedByUploader;
}

public void setUploaderVerified(boolean uploaderVerified) {
this.uploaderVerified = uploaderVerified;
}

public boolean getUploaderVerified() {
return uploaderVerified;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {

/**
* Return the like count of the comment, or -1 if it's unavailable
*
* @see StreamExtractor#getLikeCount()
*/
int getLikeCount() throws ParsingException;
Expand All @@ -22,12 +23,14 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {

/**
* The upload date given by the service, unmodified
*
* @see StreamExtractor#getTextualUploadDate()
*/
String getTextualUploadDate() throws ParsingException;

/**
* The upload date wrapped with DateWrapper class
*
* @see StreamExtractor#getUploadDate()
*/
@Nullable
Expand All @@ -45,4 +48,9 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
* Whether the comment has been hearted by the uploader
*/
boolean getHeartedByUploader() throws ParsingException;

/**
* Whether the uploader is verified by the service
*/
boolean getUploaderVerified() throws ParsingException;
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package org.schabi.newpipe.extractor.services.peertube.extractors;

import com.grack.nanojson.JsonObject;

import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;
import org.schabi.newpipe.extractor.ServiceList;
Expand Down Expand Up @@ -93,6 +92,11 @@ public boolean getHeartedByUploader() throws ParsingException {
return false;
}

@Override
public boolean getUploaderVerified() throws ParsingException {
return false;
}

@Override
public String getUploaderName() throws ParsingException {
return JsonUtils.getString(item, "account.name") + "@" + JsonUtils.getString(item, "account.host");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,8 @@
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.services.soundcloud.SoundcloudParsingHelper;

import java.util.Objects;

import javax.annotation.Nullable;
import java.util.Objects;

public class SoundcloudCommentsInfoItemExtractor implements CommentsInfoItemExtractor {
private JsonObject json;
Expand Down Expand Up @@ -44,6 +43,11 @@ public boolean getHeartedByUploader() throws ParsingException {
return false;
}

@Override
public boolean getUploaderVerified() throws ParsingException {
return json.getObject("user").getBoolean("verified");
}

@Override
public String getUploaderUrl() {
return json.getObject("user").getString("permalink_url");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import com.grack.nanojson.JsonArray;
import com.grack.nanojson.JsonObject;

import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.localization.DateWrapper;
Expand Down Expand Up @@ -120,6 +119,12 @@ public boolean getHeartedByUploader() throws ParsingException {
return json.has("creatorHeart");
}

@Override
public boolean getUploaderVerified() throws ParsingException {
// impossible to get this information from the mobile layout
return false;
}

@Override
public String getUploaderName() throws ParsingException {
try {
Expand Down

0 comments on commit 6e13b35

Please sign in to comment.