Unify video/StreamInfoItem in Search Results.

This commit is contained in:
FireMasterK 2021-09-04 01:02:51 +05:30
parent 1524085577
commit 0fe215ea67
No known key found for this signature in database
GPG key ID: 49451E4482CC5BCD
2 changed files with 12 additions and 13 deletions

View file

@ -83,9 +83,7 @@ import me.kavin.piped.utils.obj.db.PubSub;
import me.kavin.piped.utils.obj.db.User;
import me.kavin.piped.utils.obj.db.Video;
import me.kavin.piped.utils.obj.search.SearchChannel;
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.resp.AcceptedResponse;
import me.kavin.piped.utils.resp.AlreadyRegisteredResponse;
import me.kavin.piped.utils.resp.AuthenticationFailureResponse;
@ -417,15 +415,16 @@ public class ResponseHelper {
final SearchInfo info = SearchInfo.getInfo(Constants.YOUTUBE_SERVICE,
Constants.YOUTUBE_SERVICE.getSearchQHFactory().fromQuery(q, Collections.singletonList(filter), null));
ObjectArrayList<SearchItem> items = new ObjectArrayList<>();
ObjectArrayList<Object> items = new ObjectArrayList<>();
info.getRelatedItems().forEach(item -> {
switch (item.getInfoType()) {
case STREAM:
StreamInfoItem stream = (StreamInfoItem) item;
items.add(new SearchStream(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), stream.getTextualUploadDate(), stream.getUploaderName(),
optionalSubstring(stream.getUploaderUrl(), 23), stream.getViewCount(), stream.getDuration(),
items.add(new StreamItem(stream.getUrl().substring(23), stream.getName(),
rewriteURL(stream.getThumbnailUrl()), stream.getUploaderName(),
stream.getUploaderUrl().substring(23), rewriteURL(stream.getUploaderAvatarUrl()),
stream.getTextualUploadDate(), stream.getDuration(), stream.getViewCount(),
stream.isUploaderVerified()));
break;
case CHANNEL:
@ -460,15 +459,16 @@ public class ResponseHelper {
Constants.YOUTUBE_SERVICE.getSearchQHFactory().fromQuery(q, Collections.singletonList(filter), null),
prevpage);
ObjectArrayList<SearchItem> items = new ObjectArrayList<>();
ObjectArrayList<Object> items = new ObjectArrayList<>();
pages.getItems().forEach(item -> {
switch (item.getInfoType()) {
case STREAM:
StreamInfoItem stream = (StreamInfoItem) item;
items.add(new SearchStream(item.getName(), rewriteURL(item.getThumbnailUrl()),
item.getUrl().substring(23), stream.getTextualUploadDate(), stream.getUploaderName(),
optionalSubstring(stream.getUploaderUrl(), 23), stream.getViewCount(), stream.getDuration(),
items.add(new StreamItem(stream.getUrl().substring(23), stream.getName(),
rewriteURL(stream.getThumbnailUrl()), stream.getUploaderName(),
stream.getUploaderUrl().substring(23), rewriteURL(stream.getUploaderAvatarUrl()),
stream.getTextualUploadDate(), stream.getDuration(), stream.getViewCount(),
stream.isUploaderVerified()));
break;
case CHANNEL:

View file

@ -1,14 +1,13 @@
package me.kavin.piped.utils.obj;
import it.unimi.dsi.fastutil.objects.ObjectArrayList;
import me.kavin.piped.utils.obj.search.SearchItem;
public class SearchResults {
public ObjectArrayList<SearchItem> items;
public ObjectArrayList<Object> items;
public String nextpage;
public SearchResults(ObjectArrayList<SearchItem> items, String nextpage) {
public SearchResults(ObjectArrayList<Object> items, String nextpage) {
this.nextpage = nextpage;
this.items = items;
}