refactor(kids/Channel): Use new endpoint parsers for continuation requests

This commit is contained in:
Luan
2024-11-22 04:45:39 -03:00
parent 4e9d64404e
commit 2c7f0ca155

View File

@@ -2,6 +2,7 @@ import Feed from '../../core/mixins/Feed.js';
import C4TabbedHeader from '../classes/C4TabbedHeader.js';
import ItemSection from '../classes/ItemSection.js';
import { ItemSectionContinuation } from '../index.js';
import NavigationEndpoint from '../classes/NavigationEndpoint.js';
import type { IBrowseResponse } from '../types/index.js';
import type { ApiResponse, Actions } from '../../core/index.js';
@@ -17,15 +18,22 @@ export default class Channel extends Feed<IBrowseResponse> {
}
/**
* Retrieves next batch of videos.
* Retrieves next batch of content.
*/
async getContinuation(): Promise<Channel> {
const response = await this.actions.execute('/browse', {
continuation: this.contents?.continuation,
client: 'YTKIDS'
if (!this.contents)
throw new Error('No continuation available.');
const continuation_request = new NavigationEndpoint({
continuationCommand: {
token: this.contents.continuation,
request: 'CONTINUATION_REQUEST_TYPE_BROWSE'
}
});
const continuation_response = await continuation_request.call(this.actions, { client: 'YTKIDS' });
return new Channel(this.actions, response);
return new Channel(this.actions, continuation_response);
}
get has_continuation(): boolean {