엄민용

Get song information from Playlist(Genre)

장르와 관련한 재생목록을 추가
힙합, 뉴에이지 피아노곡, 팝송의 재생목록에서 노래의 정보를 가져온다
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: 'PLfVO1GXBPp3s03voaFAWN7AkzEnpsGF1U'
}, 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: 'PLfVO1GXBPp3t4Wp8l-cR9s8wpWI2Fnz4g'
}, 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: 'PLfVO1GXBPp3vXaFB2VtbdQ2h6ljGZOSlj'
}, 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('}');
}
}
})