-
-
Notifications
You must be signed in to change notification settings - Fork 235
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ytkids): add
getChannel()
(#292)
- Loading branch information
Showing
8 changed files
with
107 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import Feed from '../../core/Feed'; | ||
import Actions from '../../core/Actions'; | ||
import C4TabbedHeader from '../classes/C4TabbedHeader'; | ||
import ItemSection from '../classes/ItemSection'; | ||
import { ItemSectionContinuation } from '..'; | ||
|
||
class Channel extends Feed { | ||
header?: C4TabbedHeader; | ||
contents?: ItemSection | ItemSectionContinuation; | ||
|
||
constructor(actions: Actions, data: any, already_parsed = false) { | ||
super(actions, data, already_parsed); | ||
this.header = this.page.header?.item().as(C4TabbedHeader); | ||
this.contents = this.memo.getType(ItemSection).first() || this.page.continuation_contents?.as(ItemSectionContinuation); | ||
} | ||
|
||
/** | ||
* Retrieves next batch of videos. | ||
*/ | ||
async getContinuation(): Promise<Channel> { | ||
const response = await this.actions.execute('/browse', { | ||
continuation: this.contents?.continuation, | ||
client: 'YTKIDS' | ||
}); | ||
|
||
return new Channel(this.actions, response.data); | ||
} | ||
|
||
get has_continuation(): boolean { | ||
return !!this.contents?.continuation; | ||
} | ||
} | ||
|
||
export default Channel; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters