-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathlatestEp.js
More file actions
23 lines (20 loc) · 1.09 KB
/
latestEp.js
File metadata and controls
23 lines (20 loc) · 1.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$(document).ready(
function(){
const url = "https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&maxResults=1&playlistId=PLn2nfuATkZsQzaTPcar9B0vPVO2a59hf5&fields=items(snippet(publishedAt%2CresourceId%2FvideoId%2Ctitle))&key=AIzaSyADw-SqvIFmdXzhrSGv67fzBDRx-dNT0us"
var xmlhttp = new XMLHttpRequest();
xmlhttp.onreadystatechange = function() {
if(this.status == 403) {
$('#latestLTV').append(`<p>We are having some trouble reaching YouTube. Please try again later.</p>`)
} else
if(this.readyState == 4 && this.status == 200) {
var myObj = JSON.parse(this.responseText)
let videoId = myObj.items[0].snippet.resourceId.videoId;
let srcFrame = `<iframe width="968" height="544" src="https://www.youtube.com/embed/${videoId}" style="margin-top: 1cm" frameborder="0"></iframe>`
//console.log(body)
$('#latestLTV').append(srcFrame)
}
};
xmlhttp.open("GET", url, true);
xmlhttp.send();
}
)