Deduped code; Using default values...

This commit is contained in:
litetex 2021-05-20 20:22:40 +02:00
parent b934c7ccbb
commit c3b837fe3b
No known key found for this signature in database
GPG key ID: 4E362E77AA7E82DF
4 changed files with 31 additions and 76 deletions

View file

@ -9,6 +9,7 @@ import org.schabi.newpipe.extractor.utils.Utils;
import javax.annotation.Nullable;
public interface CommentsInfoItemExtractor extends InfoItemExtractor {
/**
* The formatted text (e.g. 420, 4K, 4.2M) of the votes
*
@ -21,14 +22,18 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
/**
* The text of the comment
*/
String getCommentText() throws ParsingException;
default String getCommentText() throws ParsingException {
return Utils.EMPTY_STRING;
}
/**
* The upload date given by the service, unmodified
*
* @see StreamExtractor#getTextualUploadDate()
*/
String getTextualUploadDate() throws ParsingException;
default String getTextualUploadDate() throws ParsingException {
return Utils.EMPTY_STRING;
}
/**
* The upload date wrapped with DateWrapper class
@ -36,28 +41,44 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
* @see StreamExtractor#getUploadDate()
*/
@Nullable
DateWrapper getUploadDate() throws ParsingException;
default DateWrapper getUploadDate() throws ParsingException {
return null;
}
String getCommentId() throws ParsingException;
default String getCommentId() throws ParsingException {
return Utils.EMPTY_STRING;
}
String getUploaderUrl() throws ParsingException;
default String getUploaderUrl() throws ParsingException {
return Utils.EMPTY_STRING;
}
String getUploaderName() throws ParsingException;
default String getUploaderName() throws ParsingException {
return Utils.EMPTY_STRING;
}
String getUploaderAvatarUrl() throws ParsingException;
default String getUploaderAvatarUrl() throws ParsingException {
return Utils.EMPTY_STRING;
}
/**
* Whether the comment has been hearted by the uploader
*/
boolean isHeartedByUploader() throws ParsingException;
default boolean isHeartedByUploader() throws ParsingException {
return false;
}
/**
* Whether the comment is pinned
*/
boolean isPinned() throws ParsingException;
default boolean isPinned() throws ParsingException {
return false;
}
/**
* Whether the uploader is verified by the service
*/
boolean isUploaderVerified() throws ParsingException;
default boolean isUploaderVerified() throws ParsingException {
return false;
}
}

View file

@ -3,9 +3,6 @@ package org.schabi.newpipe.extractor.services.bandcamp.extractors;
import org.jsoup.nodes.Element;
import org.schabi.newpipe.extractor.comments.CommentsInfoItemExtractor;
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import javax.annotation.Nullable;
public class BandcampCommentsInfoItemExtractor implements CommentsInfoItemExtractor {
@ -37,29 +34,6 @@ public class BandcampCommentsInfoItemExtractor implements CommentsInfoItemExtrac
return writing.getElementsByClass("text").first().ownText();
}
@Override
public String getTextualUploadDate() {
return "";
}
@Nullable
@Override
public DateWrapper getUploadDate() {
return null;
}
@Override
public String getCommentId() {
return "";
}
@Override
public String getUploaderUrl() {
//return writing.getElementsByClass("name").attr("href");
// Fan links cannot be opened
return "";
}
@Override
public String getUploaderName() throws ParsingException {
return writing.getElementsByClass("name").first().text();
@ -69,19 +43,4 @@ public class BandcampCommentsInfoItemExtractor implements CommentsInfoItemExtrac
public String getUploaderAvatarUrl() {
return writing.getElementsByClass("thumb").attr("src");
}
@Override
public boolean isHeartedByUploader() {
return false;
}
@Override
public boolean isPinned() {
return false;
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
}

View file

@ -84,21 +84,6 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
return baseUrl + value;
}
@Override
public boolean isHeartedByUploader() throws ParsingException {
return false;
}
@Override
public boolean isPinned() throws ParsingException {
return false;
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Override
public String getUploaderName() throws ParsingException {
return JsonUtils.getString(item, "account.name") + "@" + JsonUtils.getString(item, "account.host");

View file

@ -38,16 +38,6 @@ public class SoundcloudCommentsInfoItemExtractor implements CommentsInfoItemExtr
return json.getObject("user").getString("avatar_url");
}
@Override
public boolean isHeartedByUploader() throws ParsingException {
return false;
}
@Override
public boolean isPinned() throws ParsingException {
return false;
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return json.getObject("user").getBoolean("verified");