Unverified Commit 9c1a7f7d authored by bopol's avatar bopol Committed by GitHub
Browse files

Merge pull request #521 from B0pol/verified

Add uploader verified by service extraction
parents db253e20 1a322ad8
......@@ -40,4 +40,6 @@ public abstract class ChannelExtractor extends ListExtractor<StreamInfoItem> {
public abstract String getParentChannelName() throws ParsingException;
public abstract String getParentChannelUrl() throws ParsingException;
public abstract String getParentChannelAvatarUrl() throws ParsingException;
public abstract boolean isVerified() throws ParsingException;
}
......@@ -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);
......@@ -56,4 +56,12 @@ public class ChannelInfoItem extends InfoItem {
public void setStreamCount(long stream_count) {
this.streamCount = stream_count;
}
public boolean isVerified() {
return verified;
}
public void setVerified(boolean verified) {
this.verified = verified;
}
}
......@@ -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;
}
......@@ -59,6 +59,12 @@ public class ChannelInfoItemsCollector extends InfoItemsCollector<ChannelInfoIte
} catch (Exception e) {
addError(e);
}
try {
resultItem.setVerified(extractor.isVerified());
} catch (Exception e) {
addError(e);
}
return resultItem;
}
}
......@@ -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;
......@@ -103,4 +104,12 @@ public class CommentsInfoItem extends InfoItem {
public void setPinned(boolean pinned) {
this.pinned = pinned;
}
public void setUploaderVerified(boolean uploaderVerified) {
this.uploaderVerified = uploaderVerified;
}
public boolean isUploaderVerified() {
return uploaderVerified;
}
}
......@@ -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;
}
......@@ -20,6 +20,7 @@ public abstract class PlaylistExtractor extends ListExtractor<StreamInfoItem> {
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;
......
......@@ -4,7 +4,6 @@ import com.grack.nanojson.JsonArray;
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;
......@@ -17,9 +16,8 @@ import org.schabi.newpipe.extractor.services.media_ccc.linkHandler.MediaCCCConfe
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;
......@@ -69,6 +67,11 @@ public class MediaCCCConferenceExtractor extends ChannelExtractor {
return "";
}
@Override
public boolean isVerified() throws ParsingException {
return false;
}
@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() {
......
......@@ -126,6 +126,11 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
return conference.getString("conference");
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Nonnull
@Override
public String getUploaderAvatarUrl() {
......@@ -180,7 +185,7 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
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));
}
......@@ -197,7 +202,7 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
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(
......@@ -218,7 +223,7 @@ public class MediaCCCLiveStreamExtractor extends StreamExtractor {
@Nonnull
@Override
public List<SubtitlesStream> getSubtitlesDefault(){
public List<SubtitlesStream> getSubtitlesDefault() {
return Collections.emptyList();
}
......
......@@ -73,6 +73,11 @@ public class MediaCCCLiveStreamKioskExtractor implements StreamInfoItemExtractor
return "https://media.ccc.de/c/" + conferenceInfo.getString("slug");
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Nullable
@Override
public String getTextualUploadDate() throws ParsingException {
......
......@@ -68,6 +68,11 @@ public class MediaCCCRecentKioskExtractor implements StreamInfoItemExtractor {
.getUrl(); // web URL
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Nullable
@Override
public String getTextualUploadDate() throws ParsingException {
......
......@@ -142,6 +142,11 @@ public class MediaCCCSearchExtractor extends SearchExtractor {
return item.getStreamCount();
}
@Override
public boolean isVerified() throws ParsingException {
return false;
}
@Override
public String getName() {
return item.getName();
......
......@@ -4,7 +4,6 @@ import com.grack.nanojson.JsonArray;
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;
......@@ -13,26 +12,14 @@ import org.schabi.newpipe.extractor.exceptions.ExtractionException;
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;
......@@ -109,6 +96,11 @@ public class MediaCCCStreamExtractor extends StreamExtractor {
.replaceFirst("https://(api\\.)?media\\.ccc\\.de/public/conferences/", "");
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Nonnull
@Override
public String getUploaderAvatarUrl() {
......
......@@ -28,6 +28,11 @@ public class MediaCCCConferenceInfoItemExtractor implements ChannelInfoItemExtra
return ListExtractor.ITEM_COUNT_UNKNOWN;
}
@Override
public boolean isVerified() throws ParsingException {
return false;
}
@Override
public String getName() throws ParsingException {
return conference.getString("title");
......
......@@ -46,6 +46,11 @@ public class MediaCCCStreamInfoItemExtractor implements StreamInfoItemExtractor
return event.getString("conference_url");
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Nullable
@Override
public String getTextualUploadDate() {
......
......@@ -83,6 +83,11 @@ public class PeertubeAccountExtractor extends ChannelExtractor {
return "";
}
@Override
public boolean isVerified() throws ParsingException {
return false;
}
@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
......
......@@ -90,6 +90,11 @@ public class PeertubeChannelExtractor extends ChannelExtractor {
return baseUrl + value;
}
@Override
public boolean isVerified() throws ParsingException {
return false;
}
@Nonnull
@Override
public InfoItemsPage<StreamInfoItem> getInitialPage() throws IOException, ExtractionException {
......
......@@ -99,6 +99,11 @@ public class PeertubeCommentsInfoItemExtractor implements CommentsInfoItemExtrac
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");
......
......@@ -3,7 +3,6 @@ package org.schabi.newpipe.extractor.services.peertube.extractors;
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;
......@@ -17,14 +16,10 @@ import org.schabi.newpipe.extractor.stream.StreamInfoItem;
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 {
......@@ -59,6 +54,11 @@ public class PeertubePlaylistExtractor extends PlaylistExtractor {
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");
......
......@@ -148,6 +148,11 @@ public class PeertubeStreamExtractor extends StreamExtractor {
return JsonUtils.getString(json, "account.displayName");
}
@Override
public boolean isUploaderVerified() throws ParsingException {
return false;
}
@Nonnull
@Override
public String getUploaderAvatarUrl() {
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment