New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

youtube-comment-api

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

youtube-comment-api - npm Package Compare versions

Comparing version 2.0.1 to 2.0.2

38

lib/video-info.js

@@ -1,10 +0,5 @@

var cheerio = require('cheerio');
var Promise = require('native-promise-only');
var debug = require('debug')('video-info');
var _ = require('lodash');
var request = require('./request');
var fetchYoutubeVideoInfo = require('youtube-info');
var config = require('./config');
var YT_COMMENTS_URL = 'https://www.youtube.com/all_comments?v=';
var cache = {};

@@ -17,34 +12,17 @@

} else {
debug('Fetching video info');
return request.get(YT_COMMENTS_URL + videoID).then(function (responseText) {
if(!responseText) {
throw new Error('Fetching video info failed. Emtpy response.');
return fetchYoutubeVideoInfo(videoID).then(function (youtubeVideoInfo) {
var info = {
videoCommentCount: youtubeVideoInfo.commentCount,
videoTitle: youtubeVideoInfo.title,
videoThumbnail: youtubeVideoInfo.thumbnailUrl
}
var $ = cheerio.load(responseText.trim());
var videoTitle = $('.yt > a').text();
videoTitle = videoTitle ? videoTitle.trim() : null;
debug('Fetched video title %s', videoTitle);
var commentCount = 0;
var m = /\(([\d,]+)\)$/gi.exec($('.all-comments').text().trim());
if (m && m[1]) {
commentCount = parseInt(m[1].replace(',', ''), 10);
}
debug('Fetched comment count %d', commentCount);
var videoInfo = {
videoCommentCount: commentCount,
videoTitle: videoTitle,
videoThumbnail: 'http://img.youtube.com/vi/' + videoID + '/0.jpg'
}
// cache the video info
debug('Caching video info for %d seconds', config().cacheDuration);
cache[videoID] = {
videoInfo: videoInfo,
videoInfo: info,
expires: Date.now() + (config().cacheDuration * 1000)
};
return videoInfo;
return info;
});

@@ -51,0 +29,0 @@ }

{
"name": "youtube-comment-api",
"version": "2.0.1",
"version": "2.0.2",
"description": "Youtube comment API",

@@ -34,3 +34,4 @@ "main": "index.js",

"native-promise-only": "^0.8.1",
"request-promise": "^0.4.3"
"request-promise": "^0.4.3",
"youtube-info": "^1.1.0"
},

@@ -37,0 +38,0 @@ "devDependencies": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc