@micmac/youtube
Advanced tools
Comparing version 2.9.0 to 2.9.1
100
main.js
@@ -11,4 +11,2 @@ // fonction searchVideos retourne les 10 dernières videos de la chaine beerus | ||
var videoFullInfos = new Object (); | ||
var getVideosID = function () { | ||
@@ -32,4 +30,4 @@ return new Promise (function (resolve, reject) { | ||
} | ||
}) | ||
}) | ||
}); | ||
}); | ||
}; | ||
@@ -53,4 +51,4 @@ | ||
} | ||
}) | ||
}) | ||
}); | ||
}); | ||
}; | ||
@@ -75,40 +73,60 @@ | ||
} | ||
}) | ||
}) | ||
}); | ||
}); | ||
}; | ||
var getAllVideosInfos = function () { | ||
var videoFullInfos = new Object (); | ||
var promiseInfo = new Object (); | ||
var promiseComment = new Object (); | ||
var nbOfVideo = 0; | ||
moment.locale ('fr'); | ||
getVideosID ().then (function (response) { | ||
response.data.items.forEach (function (p, n) { | ||
getVideoInfo (p.id.videoId).then (function (response) { | ||
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); | ||
}).catch (function (error) { | ||
console.log ('getVideoInfo : ' + error); | ||
}); | ||
getVideoComments (p.id.videoId).then (function (response) { | ||
console.log ('nombre de commentaires : ' + response.data.pageInfo.totalResults); | ||
if (response.data.pageInfo.totalResults > 0) | ||
{ | ||
response.data.items.forEach (function (p, n) { | ||
console.log ('id video commentée : ' + p.snippet.videoId); | ||
console.log ('auteur du commentaire : ' + p.snippet.topLevelComment.snippet.authorDisplayName); | ||
console.log ('commentaire : ' + p.snippet.topLevelComment.snippet.textOriginal); | ||
console.log ('url avatar auteur : ' + p.snippet.topLevelComment.snippet.authorProfileImageUrl); | ||
console.log ('date du commentaire : ' + moment (p.snippet.topLevelComment.snippet.publishedAt).format ('LL')); | ||
}) | ||
} | ||
}).catch (function (error) { | ||
console.log ('comment ERROR : ' + error); | ||
}); | ||
}) | ||
}).catch (function (error) { | ||
console.log ('getVideoId ERROR : ' + error); | ||
}) | ||
} | ||
return new Promise (function (resolve, reject) { | ||
getVideosID ().catch (function (error) { | ||
console.log ('getVideosID ERROR : ' + error); | ||
}).then (function (response) { | ||
nbOfVideo = response.data.items.length; | ||
console.log ('nombre de videos : ' + nbOfVideo); | ||
response.data.items.forEach (function (p, n) { | ||
promiseInfo[n] = getVideoInfo (p.id.videoId).catch (function (error) { | ||
console.log ('getVideoInfo : ' + error); | ||
}).then (function (response) { | ||
videoFullInfos[n].video.id = p.id.videoId; | ||
videoFullInfos[n].video.title = response.data.items[0].snippet.title; | ||
videoFullInfos[n].video.date = moment (response.data.items[0].snippet.publishedAt).format ('LL'); | ||
videoFullInfos[n].video.description = response.data.items[0].snippet.description; | ||
videoFullInfos[n].video.thumbnail = response.data.items[0].snippet.thumbnails.standard.url; | ||
videoFullInfos[n].video.tags = response.data.items[0].snippet.tags; | ||
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); | ||
}); | ||
promiseComment[n] = getVideoComments (p.id.videoId).catch (function (error) { | ||
console.log ('comment ERROR : ' + error); | ||
}).then (function (response) { | ||
console.log ('nombre de commentaires : ' + response.data.pageInfo.totalResults); | ||
if (response.data.pageInfo.totalResults > 0) | ||
{ | ||
response.data.items.forEach (function (q, m) { | ||
videoFullInfos[n].comments[m].author = q.snippet.topLevelComment.snippet.authorDisplayName; | ||
videoFullInfos[n].comments[m].text = q.snippet.topLevelComment.snippet.textOriginal; | ||
videoFullInfos[n].comments[m].avatar = q.snippet.topLevelComment.snippet.authorProfileImageUrl; | ||
videoFullInfos[n].comments[m].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')); | ||
}); | ||
} | ||
}); | ||
}); | ||
var allPromise =new Promise(); | ||
allPromise.all(promiseInfo,promiseComment).then(resolve(videoFullInfos)); | ||
}); | ||
}); | ||
}; | ||
var SearchAllVideos = function () { | ||
@@ -115,0 +133,0 @@ this.allVideos = new Object ( ); |
{ | ||
"name": "@micmac/youtube", | ||
"version": "2.9.0", | ||
"version": "2.9.1", | ||
"description": "utilisation api youtube data", | ||
@@ -5,0 +5,0 @@ "main": "main.js", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
10764
247
0