@freetube/yt-comment-scraper
Advanced tools
Comparing version 5.1.0 to 5.2.0
{ | ||
"name": "@freetube/yt-comment-scraper", | ||
"version": "5.1.0", | ||
"version": "5.2.0", | ||
"description": "Scrapes the comments of any YouTube video without YouTube API access. Uses the default YouTube Ajax calls to get the comment data.", | ||
@@ -13,5 +13,2 @@ "main": "index.js", | ||
}, | ||
"publishConfig": { | ||
"access": "public" | ||
}, | ||
"keywords": [ | ||
@@ -18,0 +15,0 @@ "youtube", |
@@ -73,3 +73,6 @@ # YouTube Comment Scraper NodeJS Documentation | ||
numReplies: Number, // The number of replies found for the comment | ||
isOwner: Boolean, // If the video channel made the comment | ||
isHearted: Boolean, // If the video channel hearted the comment | ||
isPinned: Boolean, // If the video channel pinned the comment | ||
hasOwnerReplied: Boolean, // If the video channel replied to the comment | ||
replyToken: String // The continuation token needed for getCommentReplies() | ||
@@ -118,3 +121,6 @@ }], | ||
numReplies: Number, // The number of replies found for the comment | ||
isOwner: Boolean, // If the video channel made the comment | ||
isHearted: Boolean, // If the video channel hearted the comment | ||
isPinned: false, | ||
hasOwnerReplied: false, | ||
replyToken: null | ||
@@ -121,0 +127,0 @@ }], |
@@ -25,3 +25,8 @@ const parser = require('node-html-parser') | ||
const heartBadge = comment.actionButtons.commentActionButtonsRenderer.creatorHeart | ||
const isOwner = comment.authorIsChannelOwner | ||
const isPinned = comment.pinnedCommentBadge ? true : false | ||
const isVerified = ('authorCommentBadge' in comment && comment.authorCommentBadge.authorCommentBadgeRenderer.icon.iconType === "CHECK_CIRCLE_THICK") | ||
const isOfficialArtist = ('authorCommentBadge' in comment && comment.authorCommentBadge.authorCommentBadgeRenderer.icon.iconType === "OFFICIAL_ARTIST_BADGE") | ||
if (typeof heartBadge !== 'undefined') { | ||
@@ -49,6 +54,11 @@ isHearted = heartBadge.creatorHeartRenderer.isHearted | ||
numReplies: numReplies, | ||
isOwner: isOwner, | ||
isHearted: isHearted, | ||
isPinned: isPinned, | ||
hasOwnerReplied: false, | ||
time: publishedText, | ||
edited: isEdited, | ||
replyToken: null | ||
replyToken: null, | ||
isVerified: isVerified, | ||
isOfficialArtist: isOfficialArtist | ||
} | ||
@@ -60,2 +70,7 @@ | ||
object.replyToken = continuation | ||
const replyArrayLength = replyNode.viewReplies.buttonRenderer.text.runs.length | ||
//lengths of: 1 = reply (not from owner), 2 = reply (from owner), 3 = replies (not from owner), 5 = replies (from owmer) | ||
if (replyArrayLength == 5 || replyArrayLength == 2){ | ||
object.hasOwnerReplied = true; | ||
} | ||
} | ||
@@ -62,0 +77,0 @@ |
@@ -9,3 +9,3 @@ const ytcm = require('../index') | ||
const parameters = {videoId: 'oBLQmE-nG60', setCookie: true, sortByNewest: false}; | ||
ytcm.getComments(parameters).then((data) => { | ||
return ytcm.getComments(parameters).then((data) => { | ||
expect(data.comments).toHaveLength(20); | ||
@@ -17,3 +17,3 @@ }); | ||
const parameters = {videoId: 'oBLQmE-nG60', setCookie: true, sortByNewest: true}; | ||
ytcm.getComments(parameters).then((data) => { | ||
return ytcm.getComments(parameters).then((data) => { | ||
expect(data.comments).toHaveLength(20); | ||
@@ -25,3 +25,3 @@ }); | ||
let parameters = {videoId: 'oBLQmE-nG60', setCookie: true, sortByNewest: true, continuation: null}; | ||
ytcm.getComments(parameters).then((data) => { | ||
return ytcm.getComments(parameters).then((data) => { | ||
parameters["continuation"] = data.continuation; | ||
@@ -37,3 +37,3 @@ ytcm.getComments(parameters).then((data) => { | ||
// This test first gets comments of the video with above Id | ||
ytcm.getComments(parameters).then((data) => { | ||
return ytcm.getComments(parameters).then((data) => { | ||
for (let i = 0; i < data.comments.length; i++) { | ||
@@ -43,6 +43,5 @@ // The test searches for a comment which does have at least 1 reply and then ask for the replies | ||
const replyParameters = {videoId: 'oBLQmE-nG60', replyToken: data.comments[i].replyToken, setCookie: true}; | ||
ytcm.getCommentReplies(replyParameters).then((replyData) => { | ||
return ytcm.getCommentReplies(replyParameters).then((replyData) => { | ||
expect(replyData.comments).toHaveLength(10); | ||
}); | ||
break | ||
} | ||
@@ -56,3 +55,3 @@ } | ||
// This test first gets comments of the video with above Id | ||
ytcm.getComments(parameters).then((data) => { | ||
return ytcm.getComments(parameters).then((data) => { | ||
for (let i = 0; i < data.comments.length; i++) { | ||
@@ -62,9 +61,8 @@ // The test searches for a comment which does have at least 1 reply and then ask for the replies | ||
let replyParameters = {videoId: 'oBLQmE-nG60', replyToken: data.comments[i].replyToken, setCookie: true}; | ||
ytcm.getCommentReplies(replyParameters).then((replyData) => { | ||
return ytcm.getCommentReplies(replyParameters).then((replyData) => { | ||
replyParameters.replyToken = replyData.continuation; | ||
ytcm.getCommentReplies(replyParameters).then((replyData) => { | ||
return ytcm.getCommentReplies(replyParameters).then((replyData) => { | ||
expect(replyData.comments).not.toHaveLength(0); | ||
}) | ||
}); | ||
break | ||
} | ||
@@ -77,3 +75,3 @@ } | ||
const parameters = {videoId: 'Bj-3M-KqZsI', setCookie: true, sortByNewest: false}; | ||
ytcm.getComments(parameters).then((data) => { | ||
return ytcm.getComments(parameters).then((data) => { | ||
expect(data.comments).toHaveLength(0); | ||
@@ -80,0 +78,0 @@ }); |
57312
311
130