Get song information from Playlist(Singer) / Delete unnecessary files
가수와 관련된 재생목록에서 노래의 제목, 동영상 url, 썸네일(url) 정보를 가져온다 ssh 서버에서 oauth2 인증을 구현할 수 없어 oauth2 인증을 통한 구현 포기 oauth2파일을 포함해 불필요한 파일 정리
Showing
13 changed files
with
117 additions
and
739 deletions
Youtube API/.vscode/launch.json
deleted
100644 → 0
| 1 | -{ | ||
| 2 | - // IntelliSense를 사용하여 가능한 특성에 대해 알아보세요. | ||
| 3 | - // 기존 특성에 대한 설명을 보려면 가리킵니다. | ||
| 4 | - // 자세한 내용을 보려면 https://go.microsoft.com/fwlink/?linkid=830387을(를) 방문하세요. | ||
| 5 | - "version": "0.2.0", | ||
| 6 | - "configurations": [ | ||
| 7 | - { | ||
| 8 | - "type": "pwa-node", | ||
| 9 | - "request": "launch", | ||
| 10 | - "name": "Launch Program", | ||
| 11 | - "skipFiles": [ | ||
| 12 | - "<node_internals>/**" | ||
| 13 | - ], | ||
| 14 | - "program": "${workspaceFolder}/video_list_sad.js" | ||
| 15 | - } | ||
| 16 | - ] | ||
| 17 | -} | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 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: 'PLfVO1GXBPp3tgrwk3GDJi3v-E_Hnq3lDO' | ||
| 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: 'PLfVO1GXBPp3ubihJVPi6HSltRIuvSqSI1' | ||
| 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: 'PLfVO1GXBPp3u0ckIfYZkADGlSQ6LQoAIQ' | ||
| 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: 'PLfVO1GXBPp3vo3sivJPfFzREBECRFepVK' | ||
| 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 | +}) |
Youtube API/oauth2.js
deleted
100644 → 0
| 1 | -const { google } = require("googleapis"); | ||
| 2 | -var http = require('http'); | ||
| 3 | -var opn = require('opn'); | ||
| 4 | -var destroyer = require('destroyer'); | ||
| 5 | -var url = require('url'); | ||
| 6 | -var enableDestroy = require('server-destroy'); | ||
| 7 | -const oauth2Client = new google.auth.OAuth2( | ||
| 8 | - "394965702516-q817fn2gj8r8sqoudhp29k1rd71ku42j.apps.googleusercontent.com", | ||
| 9 | - "xgo5tcTwsmg2alNumeY1Drj_", | ||
| 10 | - "http://localhost:3031/api/oauth2callback" | ||
| 11 | -); | ||
| 12 | - | ||
| 13 | -const scopes = [ | ||
| 14 | - 'https://www.googleapis.com/auth/youtube', | ||
| 15 | - 'https://www.googleapis.com/auth/youtube.force-ssl', | ||
| 16 | - 'https://www.googleapis.com/auth/youtube.readonly', | ||
| 17 | - 'https://www.googleapis.com/auth/youtubepartner' | ||
| 18 | -]; | ||
| 19 | - | ||
| 20 | -let refreshToken = ''; | ||
| 21 | - | ||
| 22 | -async function authenticate() { | ||
| 23 | - | ||
| 24 | - return new Promise((resolve, reject) => { | ||
| 25 | - | ||
| 26 | - if (refreshToken !== "") { | ||
| 27 | - oauth2Client.setCredentials({ | ||
| 28 | - refresh_token: refreshToken | ||
| 29 | - }); | ||
| 30 | - | ||
| 31 | - oauth2Client.getAccessToken((err, ttoken) => { | ||
| 32 | - if (err) { | ||
| 33 | - reject(e); | ||
| 34 | - } | ||
| 35 | - resolve(oauth2Client); | ||
| 36 | - }); | ||
| 37 | - } else { | ||
| 38 | - const authorizeUrl = oauth2Client.generateAuthUrl({ | ||
| 39 | - access_type: 'offline', | ||
| 40 | - scope: scopes.join(' '), | ||
| 41 | - }); | ||
| 42 | - const server = http.createServer(async (req, res) => { | ||
| 43 | - try { | ||
| 44 | - if (req.url.indexOf('/api/oauth2callback') > -1) { | ||
| 45 | - const qs = new url.URL(req.url, 'http://localhost:3031').searchParams; | ||
| 46 | - res.end('Completed'); | ||
| 47 | - enableDestroy(server); | ||
| 48 | - server.destroy(); | ||
| 49 | - | ||
| 50 | - const { | ||
| 51 | - tokens | ||
| 52 | - } = await oauth2Client.getToken(qs.get('code')); | ||
| 53 | - | ||
| 54 | - refreshToken = tokens.refresh_token; | ||
| 55 | - oauth2Client.credentials = tokens; | ||
| 56 | - | ||
| 57 | - resolve(oauth2Client); | ||
| 58 | - } | ||
| 59 | - } catch (e) { | ||
| 60 | - reject(e); | ||
| 61 | - } | ||
| 62 | - }).listen(3031, () => { | ||
| 63 | - | ||
| 64 | - opn(authorizeUrl, { | ||
| 65 | - wait: false | ||
| 66 | - }).then(cp => cp.unref()); | ||
| 67 | - }); | ||
| 68 | - | ||
| 69 | - destroyer(server); | ||
| 70 | - } | ||
| 71 | - }); | ||
| 72 | -} | ||
| 73 | - | ||
| 74 | -module.exports.refreshClient=authenticate; | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
Youtube API/playlistbyid.js
deleted
100644 → 0
| 1 | -const { google } = require("googleapis"); | ||
| 2 | -var service = google.youtube('v3'); | ||
| 3 | -const oauth2Service = require('./oauth2'); | ||
| 4 | - | ||
| 5 | -async function getPlaylistItemData(oauth2Client, playlistId) { | ||
| 6 | - const res = await service.playlistItems.list({ | ||
| 7 | - auth: oauth2Client, | ||
| 8 | - part: 'snippet', | ||
| 9 | - fields: 'items(snippet(title))', //제목 정보만 필요함 | ||
| 10 | - maxResults: 50, | ||
| 11 | - playlistId: playlistId | ||
| 12 | - }); | ||
| 13 | - | ||
| 14 | - if (res.data.items == null || res.data.items.length === 0) { | ||
| 15 | - throw new Error("데이터가 존재하지 않습니다."); | ||
| 16 | - } | ||
| 17 | - | ||
| 18 | - return res.data; | ||
| 19 | -} | ||
| 20 | - | ||
| 21 | -oauth2Service.refreshClient() //getPlaylistItemData(client, 재생목록의 주소) 예시로 슬픈노래 재생목록을 가져옴. | ||
| 22 | - .then(client => getPlaylistItemData(client, 'PLJrlhDfEQCMD0SG8WCSbUjztMAYnVyuuY')) | ||
| 23 | - .then(data => { | ||
| 24 | - console.log(JSON.stringify(data.items, null, 4)); | ||
| 25 | - }) | ||
| 26 | - .catch(error => console.error); | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
Youtube API/video_list_Singer_IU.js
deleted
100644 → 0
| 1 | -var {google} =require('googleapis'); | ||
| 2 | - | ||
| 3 | -//1 | ||
| 4 | -var service = google.youtube('v3'); | ||
| 5 | -service.videos.list({ | ||
| 6 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 7 | - part: 'snippet', | ||
| 8 | - id: '8ykMyNHAdKk', // 동영상 Id 팔레트 | ||
| 9 | - fields: 'items(snippet(title))' | ||
| 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 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 21 | - } | ||
| 22 | -}) | ||
| 23 | -//2 | ||
| 24 | -service.videos.list({ | ||
| 25 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 26 | - part: 'snippet', | ||
| 27 | - id: '6744glqD6lk', // 동영상 Id 밤편지 | ||
| 28 | - fields: 'items(snippet(title))' | ||
| 29 | -}, function(err, response) { | ||
| 30 | - if (err) { | ||
| 31 | - console.log('The API returned an error: ',err); | ||
| 32 | - return; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - var video =response.data.items; | ||
| 36 | - if(video.length ==0){ | ||
| 37 | - console.log('검색된 동영상이 없습니다.'); | ||
| 38 | - } else { | ||
| 39 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 40 | - } | ||
| 41 | -}) | ||
| 42 | -//3 | ||
| 43 | -service.videos.list({ | ||
| 44 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 45 | - part: 'snippet', | ||
| 46 | - id: 'he2C4lx63M0', // 동영상 Id 마음 | ||
| 47 | - fields: 'items(snippet(title))' | ||
| 48 | -}, function(err, response) { | ||
| 49 | - if (err) { | ||
| 50 | - console.log('The API returned an error: ',err); | ||
| 51 | - return; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - var video =response.data.items; | ||
| 55 | - if(video.length ==0){ | ||
| 56 | - console.log('검색된 동영상이 없습니다.'); | ||
| 57 | - } else { | ||
| 58 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 59 | - } | ||
| 60 | -}) | ||
| 61 | -//4 | ||
| 62 | -service.videos.list({ | ||
| 63 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 64 | - part: 'snippet', | ||
| 65 | - id: 'xKZ3U8viuIU', // 동영상 Id 금요일에 만나요 | ||
| 66 | - fields: 'items(snippet(title))' | ||
| 67 | -}, function(err, response) { | ||
| 68 | - if (err) { | ||
| 69 | - console.log('The API returned an error: ',err); | ||
| 70 | - return; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - var video =response.data.items; | ||
| 74 | - if(video.length ==0){ | ||
| 75 | - console.log('검색된 동영상이 없습니다.'); | ||
| 76 | - } else { | ||
| 77 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 78 | - } | ||
| 79 | -}) | ||
| 80 | -//5 | ||
| 81 | -service.videos.list({ | ||
| 82 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 83 | - part: 'snippet', | ||
| 84 | - id: 'seFr4qWykgY', // 동영상 Id 너랑나 | ||
| 85 | - fields: 'items(snippet(title))' | ||
| 86 | -}, function(err, response) { | ||
| 87 | - if (err) { | ||
| 88 | - console.log('The API returned an error: ',err); | ||
| 89 | - return; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - var video =response.data.items; | ||
| 93 | - if(video.length ==0){ | ||
| 94 | - console.log('검색된 동영상이 없습니다.'); | ||
| 95 | - } else { | ||
| 96 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 97 | - } | ||
| 98 | -}) | ||
| 99 | -//6 | ||
| 100 | -service.videos.list({ | ||
| 101 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 102 | - part: 'snippet', | ||
| 103 | - id: 'r_-GQjN9Tpc', // 동영상 Id 내 손을 잡아 | ||
| 104 | - fields: 'items(snippet(title))' | ||
| 105 | -}, function(err, response) { | ||
| 106 | - if (err) { | ||
| 107 | - console.log('The API returned an error: ',err); | ||
| 108 | - return; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - var video =response.data.items; | ||
| 112 | - if(video.length ==0){ | ||
| 113 | - console.log('검색된 동영상이 없습니다.'); | ||
| 114 | - } else { | ||
| 115 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 116 | - } | ||
| 117 | -}) | ||
| 118 | -//7 | ||
| 119 | -service.videos.list({ | ||
| 120 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 121 | - part: 'snippet', | ||
| 122 | - id: 'OIHlzvEKncQ', // 동영상 Id 좋은날 | ||
| 123 | - fields: 'items(snippet(title))' | ||
| 124 | -}, function(err, response) { | ||
| 125 | - if (err) { | ||
| 126 | - console.log('The API returned an error: ',err); | ||
| 127 | - return; | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - var video =response.data.items; | ||
| 131 | - if(video.length ==0){ | ||
| 132 | - console.log('검색된 동영상이 없습니다.'); | ||
| 133 | - } else { | ||
| 134 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 135 | - } | ||
| 136 | -}) | ||
| 137 | -//8 | ||
| 138 | -service.videos.list({ | ||
| 139 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 140 | - part: 'snippet', | ||
| 141 | - id: '04tYkKUPPv4', // 동영상 Id 라일락 | ||
| 142 | - fields: 'items(snippet(title))' | ||
| 143 | -}, function(err, response) { | ||
| 144 | - if (err) { | ||
| 145 | - console.log('The API returned an error: ',err); | ||
| 146 | - return; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - var video =response.data.items; | ||
| 150 | - if(video.length ==0){ | ||
| 151 | - console.log('검색된 동영상이 없습니다.'); | ||
| 152 | - } else { | ||
| 153 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 154 | - } | ||
| 155 | -}) | ||
| 156 | -//9 | ||
| 157 | -service.videos.list({ | ||
| 158 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 159 | - part: 'snippet', | ||
| 160 | - id: '0ldJaGupC1o', // 동영상 Id 사랑이 잘 | ||
| 161 | - fields: 'items(snippet(title))' | ||
| 162 | -}, function(err, response) { | ||
| 163 | - if (err) { | ||
| 164 | - console.log('The API returned an error: ',err); | ||
| 165 | - return; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - var video =response.data.items; | ||
| 169 | - if(video.length ==0){ | ||
| 170 | - console.log('검색된 동영상이 없습니다.'); | ||
| 171 | - } else { | ||
| 172 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 173 | - } | ||
| 174 | -}) | ||
| 175 | -//10 | ||
| 176 | -service.videos.list({ | ||
| 177 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 178 | - part: 'snippet', | ||
| 179 | - id: 'l0rcWimJmQ8', // 동영상 Id 봄 사랑, 벛꽃 말고 | ||
| 180 | - fields: 'items(snippet(title))' | ||
| 181 | -}, function(err, response) { | ||
| 182 | - if (err) { | ||
| 183 | - console.log('The API returned an error: ',err); | ||
| 184 | - return; | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - var video =response.data.items; | ||
| 188 | - if(video.length ==0){ | ||
| 189 | - console.log('검색된 동영상이 없습니다.'); | ||
| 190 | - } else { | ||
| 191 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 192 | - } | ||
| 193 | -}) |
Youtube API/video_list_exciting.js
deleted
100644 → 0
| 1 | -var {google} =require('googleapis'); | ||
| 2 | - | ||
| 3 | -//1 | ||
| 4 | -var service = google.youtube('v3'); | ||
| 5 | -service.videos.list({ | ||
| 6 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 7 | - part: 'snippet', | ||
| 8 | - id: 'j-seAiANLG8', // 동영상 Id | ||
| 9 | - fields: 'items(snippet(title))' | ||
| 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 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 21 | - } | ||
| 22 | -}) | ||
| 23 | -//2 | ||
| 24 | -service.videos.list({ | ||
| 25 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 26 | - part: 'snippet', | ||
| 27 | - id: 'F8c8f2nK82w', // 동영상 Id | ||
| 28 | - fields: 'items(snippet(title))' | ||
| 29 | -}, function(err, response) { | ||
| 30 | - if (err) { | ||
| 31 | - console.log('The API returned an error: ',err); | ||
| 32 | - return; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - var video =response.data.items; | ||
| 36 | - if(video.length ==0){ | ||
| 37 | - console.log('검색된 동영상이 없습니다.'); | ||
| 38 | - } else { | ||
| 39 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 40 | - } | ||
| 41 | -}) | ||
| 42 | -//3 | ||
| 43 | -service.videos.list({ | ||
| 44 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 45 | - part: 'snippet', | ||
| 46 | - id: 'IfemyZEhfpY', // 동영상 Id | ||
| 47 | - fields: 'items(snippet(title))' | ||
| 48 | -}, function(err, response) { | ||
| 49 | - if (err) { | ||
| 50 | - console.log('The API returned an error: ',err); | ||
| 51 | - return; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - var video =response.data.items; | ||
| 55 | - if(video.length ==0){ | ||
| 56 | - console.log('검색된 동영상이 없습니다.'); | ||
| 57 | - } else { | ||
| 58 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 59 | - } | ||
| 60 | -}) | ||
| 61 | -//4 | ||
| 62 | -service.videos.list({ | ||
| 63 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 64 | - part: 'snippet', | ||
| 65 | - id: '86suvlS1pGM', // 동영상 Id | ||
| 66 | - fields: 'items(snippet(title))' | ||
| 67 | -}, function(err, response) { | ||
| 68 | - if (err) { | ||
| 69 | - console.log('The API returned an error: ',err); | ||
| 70 | - return; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - var video =response.data.items; | ||
| 74 | - if(video.length ==0){ | ||
| 75 | - console.log('검색된 동영상이 없습니다.'); | ||
| 76 | - } else { | ||
| 77 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 78 | - } | ||
| 79 | -}) | ||
| 80 | -//5 | ||
| 81 | -service.videos.list({ | ||
| 82 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 83 | - part: 'snippet', | ||
| 84 | - id: 'ztmOmJrTF5c', // 동영상 Id | ||
| 85 | - fields: 'items(snippet(title))' | ||
| 86 | -}, function(err, response) { | ||
| 87 | - if (err) { | ||
| 88 | - console.log('The API returned an error: ',err); | ||
| 89 | - return; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - var video =response.data.items; | ||
| 93 | - if(video.length ==0){ | ||
| 94 | - console.log('검색된 동영상이 없습니다.'); | ||
| 95 | - } else { | ||
| 96 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 97 | - } | ||
| 98 | -}) | ||
| 99 | -//6 | ||
| 100 | -service.videos.list({ | ||
| 101 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 102 | - part: 'snippet', | ||
| 103 | - id: '6jAHysZVtwI', // 동영상 Id | ||
| 104 | - fields: 'items(snippet(title))' | ||
| 105 | -}, function(err, response) { | ||
| 106 | - if (err) { | ||
| 107 | - console.log('The API returned an error: ',err); | ||
| 108 | - return; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - var video =response.data.items; | ||
| 112 | - if(video.length ==0){ | ||
| 113 | - console.log('검색된 동영상이 없습니다.'); | ||
| 114 | - } else { | ||
| 115 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 116 | - } | ||
| 117 | -}) | ||
| 118 | -//7 | ||
| 119 | -service.videos.list({ | ||
| 120 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 121 | - part: 'snippet', | ||
| 122 | - id: 'fFZ1__X-kKs', // 동영상 Id | ||
| 123 | - fields: 'items(snippet(title))' | ||
| 124 | -}, function(err, response) { | ||
| 125 | - if (err) { | ||
| 126 | - console.log('The API returned an error: ',err); | ||
| 127 | - return; | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - var video =response.data.items; | ||
| 131 | - if(video.length ==0){ | ||
| 132 | - console.log('검색된 동영상이 없습니다.'); | ||
| 133 | - } else { | ||
| 134 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 135 | - } | ||
| 136 | -}) | ||
| 137 | -//8 | ||
| 138 | -service.videos.list({ | ||
| 139 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 140 | - part: 'snippet', | ||
| 141 | - id: 'ei0k_1Uro-U', // 동영상 Id | ||
| 142 | - fields: 'items(snippet(title))' | ||
| 143 | -}, function(err, response) { | ||
| 144 | - if (err) { | ||
| 145 | - console.log('The API returned an error: ',err); | ||
| 146 | - return; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - var video =response.data.items; | ||
| 150 | - if(video.length ==0){ | ||
| 151 | - console.log('검색된 동영상이 없습니다.'); | ||
| 152 | - } else { | ||
| 153 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 154 | - } | ||
| 155 | -}) | ||
| 156 | -//9 | ||
| 157 | -service.videos.list({ | ||
| 158 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 159 | - part: 'snippet', | ||
| 160 | - id: 'mCtVrf2x5BQ', // 동영상 Id | ||
| 161 | - fields: 'items(snippet(title))' | ||
| 162 | -}, function(err, response) { | ||
| 163 | - if (err) { | ||
| 164 | - console.log('The API returned an error: ',err); | ||
| 165 | - return; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - var video =response.data.items; | ||
| 169 | - if(video.length ==0){ | ||
| 170 | - console.log('검색된 동영상이 없습니다.'); | ||
| 171 | - } else { | ||
| 172 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 173 | - } | ||
| 174 | -}) | ||
| 175 | -//10 | ||
| 176 | -service.videos.list({ | ||
| 177 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 178 | - part: 'snippet', | ||
| 179 | - id: 'FV003QMWhNM', // 동영상 Id | ||
| 180 | - fields: 'items(snippet(title))' | ||
| 181 | -}, function(err, response) { | ||
| 182 | - if (err) { | ||
| 183 | - console.log('The API returned an error: ',err); | ||
| 184 | - return; | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - var video =response.data.items; | ||
| 188 | - if(video.length ==0){ | ||
| 189 | - console.log('검색된 동영상이 없습니다.'); | ||
| 190 | - } else { | ||
| 191 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 192 | - } | ||
| 193 | -}) |
Youtube API/video_list_sad.js
deleted
100644 → 0
| 1 | -var {google} =require('googleapis'); | ||
| 2 | - | ||
| 3 | -//1 | ||
| 4 | -var service = google.youtube('v3'); | ||
| 5 | -service.videos.list({ | ||
| 6 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 7 | - part: 'snippet', | ||
| 8 | - id: 'p5iu1V30myk', // 동영상 Id | ||
| 9 | - fields: 'items(snippet(title))' | ||
| 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 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 21 | - } | ||
| 22 | -}) | ||
| 23 | -//2 | ||
| 24 | -service.videos.list({ | ||
| 25 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 26 | - part: 'snippet', | ||
| 27 | - id: 'i-SBnhaZSSU', // 동영상 Id | ||
| 28 | - fields: 'items(snippet(title))' | ||
| 29 | -}, function(err, response) { | ||
| 30 | - if (err) { | ||
| 31 | - console.log('The API returned an error: ',err); | ||
| 32 | - return; | ||
| 33 | - } | ||
| 34 | - | ||
| 35 | - var video =response.data.items; | ||
| 36 | - if(video.length ==0){ | ||
| 37 | - console.log('검색된 동영상이 없습니다.'); | ||
| 38 | - } else { | ||
| 39 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 40 | - } | ||
| 41 | -}) | ||
| 42 | -//3 | ||
| 43 | -service.videos.list({ | ||
| 44 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 45 | - part: 'snippet', | ||
| 46 | - id: 'Etfgb6A7hSI', // 동영상 Id | ||
| 47 | - fields: 'items(snippet(title))' | ||
| 48 | -}, function(err, response) { | ||
| 49 | - if (err) { | ||
| 50 | - console.log('The API returned an error: ',err); | ||
| 51 | - return; | ||
| 52 | - } | ||
| 53 | - | ||
| 54 | - var video =response.data.items; | ||
| 55 | - if(video.length ==0){ | ||
| 56 | - console.log('검색된 동영상이 없습니다.'); | ||
| 57 | - } else { | ||
| 58 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 59 | - } | ||
| 60 | -}) | ||
| 61 | -//4 | ||
| 62 | -service.videos.list({ | ||
| 63 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 64 | - part: 'snippet', | ||
| 65 | - id: 'IN2mml9xs_s', // 동영상 Id | ||
| 66 | - fields: 'items(snippet(title))' | ||
| 67 | -}, function(err, response) { | ||
| 68 | - if (err) { | ||
| 69 | - console.log('The API returned an error: ',err); | ||
| 70 | - return; | ||
| 71 | - } | ||
| 72 | - | ||
| 73 | - var video =response.data.items; | ||
| 74 | - if(video.length ==0){ | ||
| 75 | - console.log('검색된 동영상이 없습니다.'); | ||
| 76 | - } else { | ||
| 77 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 78 | - } | ||
| 79 | -}) | ||
| 80 | -//5 | ||
| 81 | -service.videos.list({ | ||
| 82 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 83 | - part: 'snippet', | ||
| 84 | - id: 'tp1uoFAfgHE', // 동영상 Id | ||
| 85 | - fields: 'items(snippet(title))' | ||
| 86 | -}, function(err, response) { | ||
| 87 | - if (err) { | ||
| 88 | - console.log('The API returned an error: ',err); | ||
| 89 | - return; | ||
| 90 | - } | ||
| 91 | - | ||
| 92 | - var video =response.data.items; | ||
| 93 | - if(video.length ==0){ | ||
| 94 | - console.log('검색된 동영상이 없습니다.'); | ||
| 95 | - } else { | ||
| 96 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 97 | - } | ||
| 98 | -}) | ||
| 99 | -//6 | ||
| 100 | -service.videos.list({ | ||
| 101 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 102 | - part: 'snippet', | ||
| 103 | - id: 'Qx22TnVVIfU', // 동영상 Id | ||
| 104 | - fields: 'items(snippet(title))' | ||
| 105 | -}, function(err, response) { | ||
| 106 | - if (err) { | ||
| 107 | - console.log('The API returned an error: ',err); | ||
| 108 | - return; | ||
| 109 | - } | ||
| 110 | - | ||
| 111 | - var video =response.data.items; | ||
| 112 | - if(video.length ==0){ | ||
| 113 | - console.log('검색된 동영상이 없습니다.'); | ||
| 114 | - } else { | ||
| 115 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 116 | - } | ||
| 117 | -}) | ||
| 118 | -//7 | ||
| 119 | -service.videos.list({ | ||
| 120 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 121 | - part: 'snippet', | ||
| 122 | - id: '3y1QIqR115A', // 동영상 Id | ||
| 123 | - fields: 'items(snippet(title))' | ||
| 124 | -}, function(err, response) { | ||
| 125 | - if (err) { | ||
| 126 | - console.log('The API returned an error: ',err); | ||
| 127 | - return; | ||
| 128 | - } | ||
| 129 | - | ||
| 130 | - var video =response.data.items; | ||
| 131 | - if(video.length ==0){ | ||
| 132 | - console.log('검색된 동영상이 없습니다.'); | ||
| 133 | - } else { | ||
| 134 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 135 | - } | ||
| 136 | -}) | ||
| 137 | -//8 | ||
| 138 | -service.videos.list({ | ||
| 139 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 140 | - part: 'snippet', | ||
| 141 | - id: 'VXBI1wt8XII', // 동영상 Id | ||
| 142 | - fields: 'items(snippet(title))' | ||
| 143 | -}, function(err, response) { | ||
| 144 | - if (err) { | ||
| 145 | - console.log('The API returned an error: ',err); | ||
| 146 | - return; | ||
| 147 | - } | ||
| 148 | - | ||
| 149 | - var video =response.data.items; | ||
| 150 | - if(video.length ==0){ | ||
| 151 | - console.log('검색된 동영상이 없습니다.'); | ||
| 152 | - } else { | ||
| 153 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 154 | - } | ||
| 155 | -}) | ||
| 156 | -//9 | ||
| 157 | -service.videos.list({ | ||
| 158 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 159 | - part: 'snippet', | ||
| 160 | - id: 'aWMBn2--E0Q', // 동영상 Id | ||
| 161 | - fields: 'items(snippet(title))' | ||
| 162 | -}, function(err, response) { | ||
| 163 | - if (err) { | ||
| 164 | - console.log('The API returned an error: ',err); | ||
| 165 | - return; | ||
| 166 | - } | ||
| 167 | - | ||
| 168 | - var video =response.data.items; | ||
| 169 | - if(video.length ==0){ | ||
| 170 | - console.log('검색된 동영상이 없습니다.'); | ||
| 171 | - } else { | ||
| 172 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 173 | - } | ||
| 174 | -}) | ||
| 175 | -//10 | ||
| 176 | -service.videos.list({ | ||
| 177 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 178 | - part: 'snippet', | ||
| 179 | - id: 'HyTbgBlnLCo', // 동영상 Id | ||
| 180 | - fields: 'items(snippet(title))' | ||
| 181 | -}, function(err, response) { | ||
| 182 | - if (err) { | ||
| 183 | - console.log('The API returned an error: ',err); | ||
| 184 | - return; | ||
| 185 | - } | ||
| 186 | - | ||
| 187 | - var video =response.data.items; | ||
| 188 | - if(video.length ==0){ | ||
| 189 | - console.log('검색된 동영상이 없습니다.'); | ||
| 190 | - } else { | ||
| 191 | - console.log(JSON.stringify(response.data.items[0],null,4)); | ||
| 192 | - } | ||
| 193 | -}) |
Youtube API/video_lists.js
deleted
100644 → 0
| 1 | -var {google} =require('googleapis'); | ||
| 2 | - | ||
| 3 | -var service = google.youtube('v3'); | ||
| 4 | -service.videos.list({ | ||
| 5 | - key: 'AIzaSyBInggOtXxPFYIRee0Xs3vb5iZ9YE9_518', | ||
| 6 | - part: 'snippet', | ||
| 7 | - id: 'p5iu1V30myk', // 동영상 Id | ||
| 8 | - fields: 'items(snippet(title))' | ||
| 9 | -}, function(err, response) { | ||
| 10 | - if (err) { | ||
| 11 | - console.log('The API returned an error: ',err); | ||
| 12 | - return; | ||
| 13 | - } | ||
| 14 | - | ||
| 15 | - var video =response.data.items; | ||
| 16 | - if(video.length ==0){ | ||
| 17 | - console.log('검색된 동영상이 없습니다.'); | ||
| 18 | - } else { | ||
| 19 | - console.log(JSON.stringify(response.data.items[0],null,4)); // 콘솔에 출력 | ||
| 20 | - } | ||
| 21 | -}) | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
Youtube API/구현 예정.txt
deleted
100644 → 0
| 1 | -oauth2.js 실행할 필요 없이 playlistbyid.js 만 실행하셔도 될 것 같습니다. | ||
| 2 | - | ||
| 3 | -실행하기 이전에, 제가 package 파일을 다루는걸 몰라서 | ||
| 4 | - | ||
| 5 | -아직은 수동으로 npm install 을 진행해주셔야 할 것 같습니다. | ||
| 6 | - | ||
| 7 | -oauth2.js 와 playlistbyid.js 에 있는 require 항목들을 모두 install 해주시고 진행해주시면 됩니다. | ||
| 8 | - | ||
| 9 | -playlistbyid.js를 실행하시면 브라우저 창에서 구글 아이디를 통해 유튜브 api를 이용할 수 있도록 인증하는 절차를 거치게 됩니다. | ||
| 10 | - | ||
| 11 | -확인되지 않은 앱이라고 뜨시면 고급으로 이동하여 안전하지 않은 페이지로 이동하시면 됩니다. | ||
| 12 | - | ||
| 13 | -모든 인증이 끝나면 Completed 라는 메시지가 뜹니다. | ||
| 14 | - | ||
| 15 | -재생목록의 주소를 입력하면 재생목록의 영상 제목을 출력하도록 하였습니다. | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file |
| 1 | +수동으로 googleapis 를 npm install 해야합니다. | ||
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or login to post a comment