Created
October 14, 2012 21:17
-
-
Save jeena/3889837 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<head> | |
<title>YouTube Meta Data</title> | |
<script> | |
function $(id) { | |
return document.getElementById(id); | |
} | |
function callback(meta) { | |
var data = meta["data"]; | |
$("title").innerHTML = data["title"]; | |
$("thumbnail").src = data["thumbnail"]["hqDefault"]; | |
$("description").innerHTML = data["description"]; | |
var date = new Date(data["uploaded"]); | |
var published = "Published on " + date.getDate() + "/" + date.getMonth() + "/" + date.getFullYear() | |
+ " by " + data["uploader"]; | |
$("published").innerHTML = published; | |
} | |
function get(id) { | |
var link = "http://gdata.youtube.com/feeds/api/videos/" + id + "?v=2&alt=jsonc&callback=callback&prettyprint=true"; | |
var script = document.createElement("script"); | |
script.src = link; | |
document.getElementsByTagName("head")[0].appendChild(script); | |
} | |
</script> | |
</head> | |
<body> | |
<form onsubmit="get(this.vid.value); return false;"> | |
<input name="vid" value="rLmHedIEbus"> <input type="submit" value="Go"> | |
</form> | |
<article> | |
<h2 id="title"></h2> | |
<img id="thumbnail" alt=""> | |
<p id="description"></p> | |
<p id="published"></p> | |
</article> | |
</body> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment