mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-06-16 11:02:10 +00:00
* feat: add core comments section classes * chore: update type declarations * chore: fix linter warnings * style: fix linter * chore: update tests * chore(tests): fix typo * chore(tests): fix typo x2 * fix(tests): `getReplies()` method is only present in `CommentThread` and not `Comment` * chore(tests): fix comment id path * chore(tests): remove outdated code * chore(tests): fix results path * chore: enforce code style * chore: update type declarations * docs: add examples and documentation * chore(docs): fix paths * chore(docs): fix more paths * chore(docs): fix `Comments.js` path * chore(docs): fix typo * chore(docs): mention example file * chore(examples): fix imports * chore(examples): fix typo
33 lines
872 B
JavaScript
33 lines
872 B
JavaScript
import Innertube from 'youtubei.js';
|
|
|
|
const session = await new Innertube();
|
|
|
|
const comments = await session.getComments('a-rqu-hjobc');
|
|
|
|
console.info(`This video has ${comments.header.comments_count.toString()} comments.`);
|
|
|
|
for (const thread of comments.contents) {
|
|
const comment = thread.comment;
|
|
|
|
console.info(
|
|
`${comment.author.name} • ${comment.published}\n`,
|
|
`${comment.content.toString()}`, '\n',
|
|
`Likes: ${comment.vote_count.short_text}`, '\n'
|
|
);
|
|
|
|
if (comment.reply_count > 0) {
|
|
console.info('Replies:', '\n');
|
|
|
|
const comment_thread = await thread.getReplies();
|
|
|
|
for (const reply of comment_thread.replies) {
|
|
console.info(
|
|
`> ${reply.author.name} • ${reply.published}\n`,
|
|
`${reply.content.toString()}`, '\n',
|
|
`Likes: ${reply.vote_count.short_text}`, '\n'
|
|
);
|
|
}
|
|
}
|
|
|
|
console.log('\n');
|
|
} |