Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@micmac/youtube

Package Overview
Dependencies
Maintainers
1
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@micmac/youtube - npm Package Compare versions

Comparing version 3.1.1 to 3.2.0

122

main.js

@@ -33,3 +33,3 @@ // fonction searchVideos retourne les 10 dernières videos de la chaine beerus

var getVideoInfo = function (_idVideo,_noVideo) {
var getVideoInfo = function (_idVideo, _noVideo) {
return new Promise (function (resolve, reject) {

@@ -48,3 +48,6 @@ moment.locale ('fr');

{
resolve ({data : response, noVideo: _noVideo});
resolve ({
data: response,
noVideo: _noVideo
});
}

@@ -55,3 +58,3 @@ });

var getVideoComments = function (_idVideo,_noVideo) {
var getVideoComments = function (_idVideo, _noVideo) {
return new Promise (function (resolve, reject) {

@@ -71,3 +74,6 @@ moment.locale ('fr');

{
resolve ({data : response, noVideo: _noVideo});
resolve ({
data: response,
noVideo: _noVideo
});
}

@@ -78,78 +84,60 @@ });

var getAllVideosInfos = function () {
return new Promise (function (resolve, reject) {
var videoFullInfos = {
video: new Array()
};
var promiseInfo = new Array ();
var promiseComment = new Array ();
var nbOfVideo = 0;
var videoFullInfos = {
video: new Array ()
};
var promiseInfo = new Array ();
var promiseComment = new Array ();
var nbOfVideo = 0;
return new Promise (function (resolveAll, reject) {
moment.locale ('fr');
getVideosID ().catch (function (error) {
console.log ('getVideosID ERROR : ' + error);
}).then (function (response) {
nbOfVideo = response.data.items.length;
}).then (function (responseVideosID) {
nbOfVideo = responseVideosID.data.items.length;
console.log ('nombre de videos : ' + nbOfVideo);
response.data.items.forEach (function (p, n) {
promiseInfo[n] = getVideoInfo (p.id.videoId,n).catch (function (error) {
console.log ('getVideoInfo : ' + error);
}).then (function (response) {
let description = splitTxt(response.data.data.items[0].snippet.description, 100);
videoFullInfos.video[response.noVideo] = {
responseVideosID.data.items.forEach (function (p, n) {
promiseInfo[n] = getVideoInfo (p.id.videoId, n).catch (function (errorVideoInfo) {
console.log ('getVideoInfo : ' + errorVideoInfo);
}).then (function (responseVideoInfo) {
let description = splitTxt (responseVideoInfo.data.data.items[0].snippet.description, 100);
videoFullInfos.video[n] = {
id: p.id.videoId,
title: response.data.data.items[0].snippet.title,
date: moment (response.data.data.items[0].snippet.publishedAt).format ('LL'),
description1: response.data.data.items[0].snippet.description,
title: responseVideoInfo.data.data.items[0].snippet.title,
date: moment (responseVideoInfo.data.data.items[0].snippet.publishedAt).format ('LL'),
description1: responseVideoInfo.data.data.items[0].snippet.description,
description2: description.chaine1,
thumbnail: response.data.data.items[0].snippet.thumbnails.standard.url,
tags: response.data.data.items[0].snippet.tags,
comments: new Array()
};
// console.log ('id video : ' + p.id.videoId);
// console.log ('titre de la video : ' + response.data.items[0].snippet.title);
// console.log ('date de publication : ' + moment (response.data.items[0].snippet.publishedAt).format ('LL'));
// console.log ('description : ' + response.data.items[0].snippet.description);
// console.log ('url vignette standard : ');
// console.log (response.data.items[0].snippet.thumbnails.standard.url);
// console.log ('tableau des tags :' + response.data.items[0].snippet.tags);
}).then (function () {
promiseComment[n] = getVideoComments (p.id.videoId,n).catch (function (error) {
console.log ('comment ERROR : ' + error);
}).then (function (response) {
console.log ('nombre de commentaires : ' + response.data.data.pageInfo.totalResults);
if (response.data.data.pageInfo.totalResults > 0) {
response.data.data.items.forEach (function (q, m) {
videoFullInfos.video[response.noVideo].comments[m] = {
author: q.snippet.topLevelComment.snippet.authorDisplayName,
text: q.snippet.topLevelComment.snippet.textOriginal,
avatar: q.snippet.topLevelComment.snippet.authorProfileImageUrl,
date: moment (q.snippet.topLevelComment.snippet.publishedAt).format ('LL')
};
});
// console.log ('id video commentée : ' + q.snippet.videoId);
// console.log ('auteur du commentaire : ' + q.snippet.topLevelComment.snippet.authorDisplayName);
// console.log ('commentaire : ' + q.snippet.topLevelComment.snippet.textOriginal);
// console.log ('url avatar auteur : ' + q.snippet.topLevelComment.snippet.authorProfileImageUrl);
// console.log ('date du commentaire : ' + moment (q.snippet.topLevelComment.snippet.publishedAt).format ('LL'));
}
});
thumbnail: responseVideoInfo.data.data.items[0].snippet.thumbnails.standard.url,
tags: responseVideoInfo.data.data.items[0].snippet.tags,
comments: new Array ()
};
promiseComment[n] = getVideoComments (p.id.videoId, n).catch (function (errorComments) {
console.log ('comment ERROR : ' + errorComments);
}).then (function (responseComments) {
if (responseComments.data.data.items.length > 0)
{
responseComments.data.data.items.forEach (function (q, m) {
console.log ('no de la video : ' + responseComments.noVideo);
videoFullInfos.video[responseComments.noVideo].comments[m] = {
author: q.snippet.topLevelComment.snippet.authorDisplayName,
text: q.snippet.topLevelComment.snippet.textOriginal,
avatar: q.snippet.topLevelComment.snippet.authorProfileImageUrl,
date: moment (q.snippet.topLevelComment.snippet.publishedAt).format ('LL')
};
//console.log('comments : ' + JSON.stringify( videoFullInfos.video[responseComments.noVideo].comments[m]));
});
}
});
});
Promise.all (promiseInfo, promiseComment).then (function () {
resolve(videoFullInfos);
});
var promiseAll = Promise.all (promiseInfo, promiseComment)
.then (function () {
console.log ('FINAL : ' + JSON.stringify (videoFullInfos));
resolveAll (videoFullInfos);
});
});
}, function (error, response) {
if (error)
{
reject (error);
}
if (response)
{
resolve (response);
}
});
};
module.exports = {
getAllVideosInfos: getAllVideosInfos
getAllVideosInfos: getAllVideosInfos
};

@@ -156,0 +144,0 @@ // autres écritures possible :

{
"name": "@micmac/youtube",
"version": "3.1.1",
"version": "3.2.0",
"description": "utilisation api youtube data",

@@ -5,0 +5,0 @@ "main": "main.js",

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