diff options
| author | Andrew Lee <alee14498@gmail.com> | 2019-11-09 15:45:48 -0500 |
|---|---|---|
| committer | Andrew Lee <alee14498@gmail.com> | 2019-11-09 15:45:48 -0500 |
| commit | e92bad1fca8a2b6290af5dc73746f1acc72cfaf0 (patch) | |
| tree | 216e4b3756ff4cf74c1c3b69c7246447c1b512a7 /assets/js/yt-list-videos.js | |
| parent | 7e6bb45d42517833be78a058dfd803f90cc7bd19 (diff) | |
| download | alp-website-e92bad1fca8a2b6290af5dc73746f1acc72cfaf0.tar.gz alp-website-e92bad1fca8a2b6290af5dc73746f1acc72cfaf0.tar.bz2 alp-website-e92bad1fca8a2b6290af5dc73746f1acc72cfaf0.zip | |
Porting the website to jekyll....
Diffstat (limited to 'assets/js/yt-list-videos.js')
| -rw-r--r-- | assets/js/yt-list-videos.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/assets/js/yt-list-videos.js b/assets/js/yt-list-videos.js new file mode 100644 index 0000000..8e0f395 --- /dev/null +++ b/assets/js/yt-list-videos.js @@ -0,0 +1,44 @@ + + +let channelID = 'UCNRn4YDPCCWSEl3CT7eWorA'; +let apiKey = "nope"; // Note to self: Rewrite the authentication part +let vidHeight = 400; +let vidWidth = 500; +let vidMaxResult = 5; + +$(document).ready(function () { + $.get("https://www.googleapis.com/youtube/v3/channels", { + part: 'contentDetails', + id: channelID, + key: apiKey //Browser API Key + }, + function (data) { + $.each(data.items, function (i, item) { + console.log(item); // See in Browser Console + pid = item.contentDetails.relatedPlaylists.uploads; + getVideos(pid); + }) + } + ); + function getVideos(pid) + { + $.get("https://www.googleapis.com/youtube/v3/playlistItems", { + part: 'snippet', + maxResults: vidMaxResult, + playlistId: pid, + key: apiKey //Browser API Key + }, + function (data) { + let outputVideo; + $.each(data.items, function (i, item) { + console.log(item); // See in Browser Console + vidId = item.snippet.resourceId.videoId; + outputVideo = '<li class="yt-vid-list"><iframe height="' + vidHeight + '" width="' + vidWidth + '" src=\"//www.youtube.com/embed/' + vidId + '"> </iframe></li>'; + + //Append to result list + $('#yt-results').append(outputVideo); + }) + } + ); + } +});
\ No newline at end of file |
