Merge pull request #401 from TeamPiped/channel-tab-nextpage

Fix channel tab nextpage.
This commit is contained in:
Kavin 2022-10-27 12:15:54 +01:00 committed by GitHub
commit 1157d5dfaa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 10 additions and 4 deletions

View File

@ -351,20 +351,26 @@ public class ResponseHelper {
return mapper.writeValueAsBytes(new ChannelTabData(nextpage, items));
}
public static byte[] channelTabPageResponse(String data, String nextpage) throws Exception {
public static byte[] channelTabPageResponse(String data, String prevPageStr) throws Exception {
if (StringUtils.isEmpty(data))
return mapper.writeValueAsBytes(new InvalidRequestResponse());
YouTubeChannelTabHandler tabHandler = mapper.readValue(data, YouTubeChannelTabHandlerMixin.class);
Page nextPage = mapper.readValue(nextpage, Page.class);
Page prevPage = mapper.readValue(prevPageStr, Page.class);
var info = ChannelTabInfo.getMoreItems(YOUTUBE_SERVICE, tabHandler, nextPage);
var info = ChannelTabInfo.getMoreItems(YOUTUBE_SERVICE, tabHandler, prevPage);
String nextpage = null;
if (info.hasNextPage()) {
Page page = info.getNextPage();
nextpage = mapper.writeValueAsString(page);
}
List<ContentItem> items = collectRelatedItems(info.getItems());
return mapper.writeValueAsBytes(new ChannelTabData(null, items));
return mapper.writeValueAsBytes(new ChannelTabData(nextpage, items));
}
public static byte[] trendingResponse(String region)