Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(parser): Add Quiz #437

Merged
merged 1 commit into from
Jul 14, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions src/parser/classes/Quiz.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { YTNode } from '../helpers.js';
import type { RawNode } from '../index.js';
import Text from './misc/Text.js';

export default class Quiz extends YTNode {
static type = 'Quiz';

choices: {
text: Text;
is_correct: boolean;
}[];

total_votes: Text;

constructor(data: RawNode) {
super();

this.choices = data.choices.map((choice: RawNode) => ({
text: new Text(choice.text),
is_correct: choice.isCorrect
}));

this.total_votes = new Text(data.totalVotes);
}
}
1 change: 1 addition & 0 deletions src/parser/nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -265,6 +265,7 @@ export { default as ProfileColumn } from './classes/ProfileColumn.js';
export { default as ProfileColumnStats } from './classes/ProfileColumnStats.js';
export { default as ProfileColumnStatsEntry } from './classes/ProfileColumnStatsEntry.js';
export { default as ProfileColumnUserInfo } from './classes/ProfileColumnUserInfo.js';
export { default as Quiz } from './classes/Quiz.js';
export { default as RecognitionShelf } from './classes/RecognitionShelf.js';
export { default as ReelItem } from './classes/ReelItem.js';
export { default as ReelShelf } from './classes/ReelShelf.js';
Expand Down