Fix channel continuation.

This commit is contained in:
FireMasterK 2021-03-30 14:52:36 +05:30
parent efc28a8994
commit 8e9547ef8d
No known key found for this signature in database
GPG key ID: 8DFF5DD33E93DB58
2 changed files with 12 additions and 6 deletions

View file

@ -188,21 +188,26 @@ public class ResponseHelper {
public static final byte[] channelPageResponse(String channelId, String url, String id)
throws IOException, ExtractionException, InterruptedException {
InfoItemsPage<StreamInfoItem> page = ChannelInfo.getMoreItems(Constants.YOUTUBE_SERVICE,
InfoItemsPage<StreamInfoItem> info = ChannelInfo.getMoreItems(Constants.YOUTUBE_SERVICE,
"https://youtube.com/channel/" + channelId, new Page(url, id));
final List<StreamItem> relatedStreams = new ObjectArrayList<>();
page.getItems().forEach(o -> {
info.getItems().forEach(o -> {
StreamInfoItem item = o;
relatedStreams.add(new StreamItem(item.getUrl().substring(23), item.getName(),
rewriteURL(item.getThumbnailUrl()), item.getUploaderName(), item.getUploaderUrl().substring(23),
item.getTextualUploadDate(), item.getDuration(), item.getViewCount()));
});
String nextpage = page.hasNextPage() ? page.getNextPage().getUrl() : null;
String nextpage = null, next_id = null;
if (info.hasNextPage()) {
Page page = info.getNextPage();
nextpage = page.getUrl();
id = info.getNextPage().getId();
}
final StreamsPage streamspage = new StreamsPage(nextpage, relatedStreams);
final StreamsPage streamspage = new StreamsPage(nextpage, next_id, relatedStreams);
return Constants.mapper.writeValueAsBytes(streamspage);

View file

@ -4,11 +4,12 @@ import java.util.List;
public class StreamsPage {
public String nextpage;
public String nextpage, nextid;
public List<StreamItem> relatedStreams;
public StreamsPage(String nextpage, List<StreamItem> relatedStreams) {
public StreamsPage(String nextpage, String nextid, List<StreamItem> relatedStreams) {
this.nextpage = nextpage;
this.nextid = nextid;
this.relatedStreams = relatedStreams;
}
}