Add additional details and playlists on search endpoint.

This commit is contained in:
FireMasterK 2021-05-28 17:38:32 +05:30
parent 8c23ec6aba
commit d687446dbf
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58
4 changed files with 87 additions and 7 deletions

View file

@ -19,12 +19,14 @@ import org.schabi.newpipe.extractor.InfoItem;
import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage; import org.schabi.newpipe.extractor.ListExtractor.InfoItemsPage;
import org.schabi.newpipe.extractor.Page; import org.schabi.newpipe.extractor.Page;
import org.schabi.newpipe.extractor.channel.ChannelInfo; import org.schabi.newpipe.extractor.channel.ChannelInfo;
import org.schabi.newpipe.extractor.channel.ChannelInfoItem;
import org.schabi.newpipe.extractor.comments.CommentsInfo; import org.schabi.newpipe.extractor.comments.CommentsInfo;
import org.schabi.newpipe.extractor.comments.CommentsInfoItem; import org.schabi.newpipe.extractor.comments.CommentsInfoItem;
import org.schabi.newpipe.extractor.exceptions.ExtractionException; import org.schabi.newpipe.extractor.exceptions.ExtractionException;
import org.schabi.newpipe.extractor.exceptions.ParsingException; import org.schabi.newpipe.extractor.exceptions.ParsingException;
import org.schabi.newpipe.extractor.kiosk.KioskInfo; import org.schabi.newpipe.extractor.kiosk.KioskInfo;
import org.schabi.newpipe.extractor.playlist.PlaylistInfo; import org.schabi.newpipe.extractor.playlist.PlaylistInfo;
import org.schabi.newpipe.extractor.playlist.PlaylistInfoItem;
import org.schabi.newpipe.extractor.search.SearchInfo; import org.schabi.newpipe.extractor.search.SearchInfo;
import org.schabi.newpipe.extractor.stream.StreamInfo; import org.schabi.newpipe.extractor.stream.StreamInfo;
import org.schabi.newpipe.extractor.stream.StreamInfoItem; import org.schabi.newpipe.extractor.stream.StreamInfoItem;
@ -47,7 +49,9 @@ import me.kavin.piped.utils.obj.StreamItem;
import me.kavin.piped.utils.obj.Streams; import me.kavin.piped.utils.obj.Streams;
import me.kavin.piped.utils.obj.StreamsPage; import me.kavin.piped.utils.obj.StreamsPage;
import me.kavin.piped.utils.obj.Subtitle; import me.kavin.piped.utils.obj.Subtitle;
import me.kavin.piped.utils.obj.search.SearchChannel;
import me.kavin.piped.utils.obj.search.SearchItem; import me.kavin.piped.utils.obj.search.SearchItem;
import me.kavin.piped.utils.obj.search.SearchPlaylist;
import me.kavin.piped.utils.obj.search.SearchStream; import me.kavin.piped.utils.obj.search.SearchStream;
public class ResponseHelper { public class ResponseHelper {
@ -316,11 +320,19 @@ public class ResponseHelper {
StreamInfoItem stream = (StreamInfoItem) item; StreamInfoItem stream = (StreamInfoItem) item;
items.add(new SearchStream(item.getName(), rewriteURL(item.getThumbnailUrl()), items.add(new SearchStream(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), stream.getTextualUploadDate(), stream.getUploaderName(), item.getUrl().substring(23), stream.getTextualUploadDate(), stream.getUploaderName(),
stream.getUploaderUrl().substring(23), stream.getViewCount(), stream.getDuration())); stream.getUploaderUrl().substring(23), stream.getViewCount(), stream.getDuration(),
stream.isUploaderVerified()));
break; break;
case CHANNEL: case CHANNEL:
items.add(new SearchItem(item.getName(), rewriteURL(item.getThumbnailUrl()), ChannelInfoItem channel = (ChannelInfoItem) item;
item.getUrl().substring(23))); items.add(new SearchChannel(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), channel.getDescription(), channel.getSubscriberCount(),
channel.getStreamCount(), channel.isVerified()));
break;
case PLAYLIST:
PlaylistInfoItem playlist = (PlaylistInfoItem) item;
items.add(new SearchPlaylist(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), playlist.getUploaderName(), playlist.getStreamCount()));
break; break;
default: default:
break; break;
@ -349,11 +361,19 @@ public class ResponseHelper {
StreamInfoItem stream = (StreamInfoItem) item; StreamInfoItem stream = (StreamInfoItem) item;
items.add(new SearchStream(item.getName(), rewriteURL(item.getThumbnailUrl()), items.add(new SearchStream(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), stream.getTextualUploadDate(), stream.getUploaderName(), item.getUrl().substring(23), stream.getTextualUploadDate(), stream.getUploaderName(),
stream.getUploaderUrl().substring(23), stream.getViewCount(), stream.getDuration())); stream.getUploaderUrl().substring(23), stream.getViewCount(), stream.getDuration(),
stream.isUploaderVerified()));
break; break;
case CHANNEL: case CHANNEL:
items.add(new SearchItem(item.getName(), rewriteURL(item.getThumbnailUrl()), ChannelInfoItem channel = (ChannelInfoItem) item;
item.getUrl().substring(23))); items.add(new SearchChannel(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), channel.getDescription(), channel.getSubscriberCount(),
channel.getStreamCount(), channel.isVerified()));
break;
case PLAYLIST:
PlaylistInfoItem playlist = (PlaylistInfoItem) item;
items.add(new SearchPlaylist(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), playlist.getUploaderName(), playlist.getStreamCount()));
break; break;
default: default:
break; break;

View file

@ -0,0 +1,33 @@
package me.kavin.piped.utils.obj.search;
public class SearchChannel extends SearchItem {
private String description;
private long subscribers, videos;
private boolean verified;
public SearchChannel(String name, String thumbnail, String url, String description, long subscribers, long videos,
boolean verified) {
super(name, thumbnail, url);
this.description = description;
this.subscribers = subscribers;
this.videos = videos;
this.verified = verified;
}
public String getDescription() {
return description;
}
public long getSubscribers() {
return subscribers;
}
public long getVideos() {
return videos;
}
public boolean isVerified() {
return verified;
}
}

View file

@ -0,0 +1,21 @@
package me.kavin.piped.utils.obj.search;
public class SearchPlaylist extends SearchItem {
private String uploaderName;
private long videos;
public SearchPlaylist(String name, String thumbnail, String url, String uploaderName, long videos) {
super(name, thumbnail, url);
this.uploaderName = uploaderName;
this.videos = videos;
}
public String getUploaderName() {
return uploaderName;
}
public long getVideos() {
return videos;
}
}

View file

@ -4,15 +4,17 @@ public class SearchStream extends SearchItem {
private String uploadDate, uploader, uploaderUrl; private String uploadDate, uploader, uploaderUrl;
private long views, duration; private long views, duration;
private boolean uploaderVerified;
public SearchStream(String name, String thumbnail, String url, String uploadDate, String uploader, public SearchStream(String name, String thumbnail, String url, String uploadDate, String uploader,
String uploaderUrl, long views, long duration) { String uploaderUrl, long views, long duration, boolean uploaderVerified) {
super(name, thumbnail, url); super(name, thumbnail, url);
this.uploadDate = uploadDate; this.uploadDate = uploadDate;
this.uploader = uploader; this.uploader = uploader;
this.uploaderUrl = uploaderUrl; this.uploaderUrl = uploaderUrl;
this.views = views; this.views = views;
this.duration = duration; this.duration = duration;
this.uploaderVerified = uploaderVerified;
} }
public String getUploadDate() { public String getUploadDate() {
@ -34,4 +36,8 @@ public class SearchStream extends SearchItem {
public long getDuration() { public long getDuration() {
return duration; return duration;
} }
public boolean isUploaderVerified() {
return uploaderVerified;
}
} }