Skip to content

Commit

Permalink
Add uploader verified by service extraction
Browse files Browse the repository at this point in the history
  • Loading branch information
B0pol committed Feb 18, 2021
1 parent db253e2 commit 1a322ad
Show file tree
Hide file tree
Showing 54 changed files with 474 additions and 91 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,6 @@ public ChannelExtractor(StreamingService service, ListLinkHandler linkHandler) {
public abstract String getParentChannelName() throws ParsingException;
public abstract String getParentChannelUrl() throws ParsingException;
public abstract String getParentChannelAvatarUrl() throws ParsingException;
public abstract boolean isVerified() throws ParsingException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ public class ChannelInfoItem extends InfoItem {
private String description;
private long subscriberCount = -1;
private long streamCount = -1;

private boolean verified = false;

public ChannelInfoItem(int serviceId, String url, String name) {
super(InfoType.CHANNEL, serviceId, url, name);
Expand Down Expand Up @@ -56,4 +56,12 @@ public long getStreamCount() {
public void setStreamCount(long stream_count) {
this.streamCount = stream_count;
}

public boolean isVerified() {
return verified;
}

public void setVerified(boolean verified) {
this.verified = verified;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,8 @@ public interface ChannelInfoItemExtractor extends InfoItemExtractor {
String getDescription() throws ParsingException;

long getSubscriberCount() throws ParsingException;

long getStreamCount() throws ParsingException;

boolean isVerified() throws ParsingException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,12 @@ public ChannelInfoItem extract(ChannelInfoItemExtractor extractor) throws Parsin
} catch (Exception e) {
addError(e);
}
try {
resultItem.setVerified(extractor.isVerified());
} catch (Exception e) {
addError(e);
}

return resultItem;
}
}
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 @@ -103,4 +104,12 @@ public boolean isPinned() {
public void setPinned(boolean pinned) {
this.pinned = pinned;
}

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

public boolean isUploaderVerified() {
return uploaderVerified;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,4 +53,9 @@ public interface CommentsInfoItemExtractor extends InfoItemExtractor {
* Whether the comment is pinned
*/
boolean isPinned() throws ParsingException;

/**
* Whether the uploader is verified by the service
*/
boolean isUploaderVerified() throws ParsingException;
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public PlaylistExtractor(StreamingService service, ListLinkHandler linkHandler)
public abstract String getUploaderUrl() throws ParsingException;
public abstract String getUploaderName() throws ParsingException;
public abstract String getUploaderAvatarUrl() throws ParsingException;
public abstract boolean isUploaderVerified() throws ParsingException;

public abstract long getStreamCount() throws ParsingException;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;

import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.channel.ChannelExtractor;
Expand All @@ -17,9 +16,8 @@
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;

import java.io.IOException;

import javax.annotation.Nonnull;
import java.io.IOException;

public class MediaCCCConferenceExtractor extends ChannelExtractor {
private JsonObject conferenceData;
Expand Down Expand Up @@ -69,6 +67,11 @@ public String getParentChannelAvatarUrl() throws ParsingException {
return "";
}

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

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ public String getUploaderName() throws ParsingException {
return conference.getString("conference");
}

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

@Nonnull
@Override
public String getUploaderAvatarUrl() {
Expand Down Expand Up @@ -180,7 +185,7 @@ public List<AudioStream> getAudioStreams() throws IOException, ExtractionExcepti
for (int s = 0; s < room.getArray("streams").size(); s++) {
final JsonObject stream = room.getArray("streams").getObject(s);
if (stream.getString("type").equals("audio")) {
for (final String type :stream.getObject("urls").keySet()) {
for (final String type : stream.getObject("urls").keySet()) {
final JsonObject url = stream.getObject("urls").getObject(type);
audioStreams.add(new AudioStream(url.getString("url"), MediaFormat.getFromSuffix(type), -1));
}
Expand All @@ -197,7 +202,7 @@ public List<VideoStream> getVideoStreams() throws IOException, ExtractionExcepti
if (stream.getString("type").equals("video")) {
final String resolution = stream.getArray("videoSize").getInt(0) + "x"
+ stream.getArray("videoSize").getInt(1);
for (final String type :stream.getObject("urls").keySet()) {
for (final String type : stream.getObject("urls").keySet()) {
if (!type.equals("hls")) {
final JsonObject url = stream.getObject("urls").getObject(type);
videoStreams.add(new VideoStream(
Expand All @@ -218,7 +223,7 @@ public List<VideoStream> getVideoOnlyStreams() throws IOException, ExtractionExc

@Nonnull
@Override
public List<SubtitlesStream> getSubtitlesDefault(){
public List<SubtitlesStream> getSubtitlesDefault() {
return Collections.emptyList();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,11 @@ public String getUploaderUrl() throws ParsingException {
return "https://media.ccc.de/c/" + conferenceInfo.getString("slug");
}

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

@Nullable
@Override
public String getTextualUploadDate() throws ParsingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ public String getUploaderUrl() throws ParsingException {
.getUrl(); // web URL
}

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

@Nullable
@Override
public String getTextualUploadDate() throws ParsingException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ public long getStreamCount() {
return item.getStreamCount();
}

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

@Override
public String getName() {
return item.getName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;

import org.schabi.newpipe.extractor.MediaFormat;
import org.schabi.newpipe.extractor.MetaInfo;
import org.schabi.newpipe.extractor.StreamingService;
Expand All @@ -13,26 +12,14 @@
import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.linkhandler.LinkHandler;
import org.schabi.newpipe.extractor.localization.DateWrapper;
import org.schabi.newpipe.extractor.stream.AudioStream;
import org.schabi.newpipe.extractor.stream.Description;
import org.schabi.newpipe.extractor.stream.StreamExtractor;
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.stream.StreamSegment;
import org.schabi.newpipe.extractor.stream.StreamType;
import org.schabi.newpipe.extractor.stream.SubtitlesStream;
import org.schabi.newpipe.extractor.stream.VideoStream;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConferenceLinkHandlerFactory;
import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCStreamLinkHandlerFactory;

import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import org.schabi.newpipe.extractor.stream.*;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.io.IOException;
import java.util.*;

public class MediaCCCStreamExtractor extends StreamExtractor {
private JsonObject data;
Expand Down Expand Up @@ -109,6 +96,11 @@ public String getUploaderName() {
.replaceFirst("https://(api\\.)?media\\.ccc\\.de/public/conferences/", "");
}

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

@Nonnull
@Override
public String getUploaderAvatarUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,11 @@ public long getStreamCount() {
return ListExtractor.ITEM_COUNT_UNKNOWN;
}

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

@Override
public String getName() throws ParsingException {
return conference.getString("title");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,11 @@ public String getUploaderUrl() {
return event.getString("conference_url");
}

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

@Nullable
@Override
public String getTextualUploadDate() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,11 @@ public String getParentChannelAvatarUrl() {
return "";
}

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

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,11 @@ public String getParentChannelAvatarUrl() {
return baseUrl + value;
}

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

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ 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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.grack.nanojson.JsonObject;
import com.grack.nanojson.JsonParser;
import com.grack.nanojson.JsonParserException;

import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.StreamingService;
import org.schabi.newpipe.extractor.downloader.Downloader;
Expand All @@ -17,14 +16,10 @@
import org.schabi.newpipe.extractor.stream.StreamInfoItemsCollector;
import org.schabi.newpipe.extractor.utils.Utils;

import java.io.IOException;

import javax.annotation.Nonnull;
import java.io.IOException;

import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.COUNT_KEY;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.ITEMS_PER_PAGE;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.START_KEY;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.collectStreamsFrom;
import static org.schabi.newpipe.extractor.services.peertube.PeertubeParsingHelper.*;
import static org.schabi.newpipe.extractor.utils.Utils.isNullOrEmpty;

public class PeertubePlaylistExtractor extends PlaylistExtractor {
Expand Down Expand Up @@ -59,6 +54,11 @@ public String getUploaderAvatarUrl() throws ParsingException {
return getBaseUrl() + playlistInfo.getObject("ownerAccount").getObject("avatar").getString("path");
}

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

@Override
public long getStreamCount() {
return playlistInfo.getLong("videosLength");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,11 @@ public String getUploaderName() throws ParsingException {
return JsonUtils.getString(json, "account.displayName");
}

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

@Nonnull
@Override
public String getUploaderAvatarUrl() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,11 @@ public String getUploaderUrl() throws ParsingException {
.fromId("accounts/" + name + "@" + host, baseUrl).getUrl();
}

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

@Override
public String getUploaderName() throws ParsingException {
return JsonUtils.getString(item, "account.displayName");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,11 @@ public String getParentChannelAvatarUrl() {
return "";
}

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

@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws ExtractionException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,11 @@ public long getStreamCount() {
return itemObject.getLong("track_count");
}

@Override
public boolean isVerified() {
return itemObject.getBoolean("verified");
}

@Override
public String getDescription() {
return itemObject.getString("description", EMPTY_STRING);
Expand Down
Loading

0 comments on commit 1a322ad

Please sign in to comment.