엄민용

Get song information from Playlist(Genre)

장르와 관련한 재생목록을 추가
힙합, 뉴에이지 피아노곡, 팝송의 재생목록에서 노래의 정보를 가져온다
1 +const { google } = require("googleapis");
2 +var service = google.youtube('v3');
3 +
4 +service.playlistItems.list({
5 + key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
6 + part: 'snippet',
7 + fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
8 + maxResults: 10,
9 + playlistId: 'PLfVO1GXBPp3s03voaFAWN7AkzEnpsGF1U'
10 +}, function (err, response) {
11 + if (err) {
12 + console.log('The API returned an error: ', err);
13 + return;
14 + }
15 +
16 + var video = response.data.items;
17 + if (video.length == 0) {
18 + console.log('검색된 동영상이 없습니다.');
19 + } else {
20 + for (var i = 0; i < 10; i++) {
21 + console.log('{');
22 + console.log(JSON.stringify(response.data.items[i].snippet.title).replace(/\"/gi, ""));
23 + var a = JSON.stringify(response.data.items[i].snippet.resourceId.videoId);
24 + console.log('https://www.youtube.com/watch?v=' + a.replace(/\"/gi, "")); //JSON stringify 큰따옴표 제거후 URL로 전환
25 + console.log(JSON.stringify(response.data.items[i].snippet.thumbnails.high.url).replace(/\"/gi, ""));
26 + console.log('}');
27 + }
28 + }
29 +})
1 +const { google } = require("googleapis");
2 +var service = google.youtube('v3');
3 +
4 +service.playlistItems.list({
5 + key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
6 + part: 'snippet',
7 + fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
8 + maxResults: 10,
9 + playlistId: 'PLfVO1GXBPp3t4Wp8l-cR9s8wpWI2Fnz4g'
10 +}, function (err, response) {
11 + if (err) {
12 + console.log('The API returned an error: ', err);
13 + return;
14 + }
15 +
16 + var video = response.data.items;
17 + if (video.length == 0) {
18 + console.log('검색된 동영상이 없습니다.');
19 + } else {
20 + for (var i = 0; i < 10; i++) {
21 + console.log('{');
22 + console.log(JSON.stringify(response.data.items[i].snippet.title).replace(/\"/gi, ""));
23 + var a = JSON.stringify(response.data.items[i].snippet.resourceId.videoId);
24 + console.log('https://www.youtube.com/watch?v=' + a.replace(/\"/gi, "")); //JSON stringify 큰따옴표 제거후 URL로 전환
25 + console.log(JSON.stringify(response.data.items[i].snippet.thumbnails.high.url).replace(/\"/gi, ""));
26 + console.log('}');
27 + }
28 + }
29 +})
1 +const { google } = require("googleapis");
2 +var service = google.youtube('v3');
3 +
4 +service.playlistItems.list({
5 + key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518',
6 + part: 'snippet',
7 + fields: 'items(snippet(title,resourceId,thumbnails(high(url))))', //제목, VideoId, Thumbnail 이미지 정보.
8 + maxResults: 10,
9 + playlistId: 'PLfVO1GXBPp3vXaFB2VtbdQ2h6ljGZOSlj'
10 +}, function (err, response) {
11 + if (err) {
12 + console.log('The API returned an error: ', err);
13 + return;
14 + }
15 +
16 + var video = response.data.items;
17 + if (video.length == 0) {
18 + console.log('검색된 동영상이 없습니다.');
19 + } else {
20 + for (var i = 0; i < 10; i++) {
21 + console.log('{');
22 + console.log(JSON.stringify(response.data.items[i].snippet.title).replace(/\"/gi, ""));
23 + var a = JSON.stringify(response.data.items[i].snippet.resourceId.videoId);
24 + console.log('https://www.youtube.com/watch?v=' + a.replace(/\"/gi, "")); //JSON stringify 큰따옴표 제거후 URL로 전환
25 + console.log(JSON.stringify(response.data.items[i].snippet.thumbnails.high.url).replace(/\"/gi, ""));
26 + console.log('}');
27 + }
28 + }
29 +})