엄민용

Get song information from Playlist(Mood)

감정상태와 관련한 재생목록을 추가
슬픈 노래, 신나는 노래의 재생목록에서 노래의 정보를 가져온다
const { google } = require("googleapis");
var service = google.youtube('v3');
service.playlistItems.list({
key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
part: 'snippet',
fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
maxResults: 10,
playlistId: 'PLfVO1GXBPp3tdasvQuIu_BmSNm4GVwnNj'
}, function (err, response) {
if (err) {
console.log('The API returned an error: ', err);
return;
}
var video = response.data.items;
if (video.length == 0) {
console.log('검색된 동영상이 없습니다.');
} else {
for (var i = 0; i < 10; i++) {
console.log('{');
console.log(JSON.stringify(response.data.items[i].snippet.title).replace(/\"/gi, ""));
var a = JSON.stringify(response.data.items[i].snippet.resourceId.videoId);
console.log('https://www.youtube.com/watch?v=' + a.replace(/\"/gi, "")); //JSON stringify 큰따옴표 제거후 URL로 전환
console.log(JSON.stringify(response.data.items[i].snippet.thumbnails.high.url).replace(/\"/gi, ""));
console.log('}');
}
}
})
const { google } = require("googleapis");
var service = google.youtube('v3');
service.playlistItems.list({
key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
part: 'snippet',
fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
maxResults: 10,
playlistId: 'PLfVO1GXBPp3vrR3ZcQFlCEC6oNdo_MQ_R'
}, function (err, response) {
if (err) {
console.log('The API returned an error: ', err);
return;
}
var video = response.data.items;
if (video.length == 0) {
console.log('검색된 동영상이 없습니다.');
} else {
for (var i = 0; i < 10; i++) {
console.log('{');
console.log(JSON.stringify(response.data.items[i].snippet.title).replace(/\"/gi, ""));
var a = JSON.stringify(response.data.items[i].snippet.resourceId.videoId);
console.log('https://www.youtube.com/watch?v=' + a.replace(/\"/gi, "")); //JSON stringify 큰따옴표 제거후 URL로 전환
console.log(JSON.stringify(response.data.items[i].snippet.thumbnails.high.url).replace(/\"/gi, ""));
console.log('}');
}
}
})