Get song information from Playlist(Mood)
감정상태와 관련한 재생목록을 추가 슬픈 노래, 신나는 노래의 재생목록에서 노래의 정보를 가져온다
Showing
2 changed files
with
58 additions
and
0 deletions
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: 'PLfVO1GXBPp3tdasvQuIu_BmSNm4GVwnNj' | ||
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: 'PLfVO1GXBPp3vrR3ZcQFlCEC6oNdo_MQ_R' | ||
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 | +}) |
-
Please register or login to post a comment