-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsearch.js
44 lines (35 loc) · 1.52 KB
/
search.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Helper function to display JavaScript value on HTML page.
function showResponse(response) {
var responseString = JSON.stringify(response, '', 2);
document.getElementById('response').innerHTML += responseString;
//console.log(response.items[0].snippet.thumbnails.medium);
var thumb = response.items[0].snippet.thumbnails.default.url;
document.getElementById('thumbnail').src = thumb;
var vid = response.items[0].id.videoId;
document.getElementById('vid').src = "http://www.youtube.com/embed/" + vid;
}
// Called automatically when JavaScript client library is loaded.
function onClientLoad() {
gapi.client.load('youtube', 'v3', onYouTubeApiLoad);
}
// Called automatically when YouTube API interface is loaded (see line 9).
function onYouTubeApiLoad() {
// See http://goo.gl/PdPA1 to get a key for your own applications.
gapi.client.setApiKey('AIzaSyCR5In4DZaTP6IEZQ0r1JceuvluJRzQNLE');
search();
}
function search() {
// Use the JavaScript client library to create a search.list() API call.
var request = gapi.client.youtube.search.list({
part: 'snippet',
q: 'ProfileProductionsUK'
});
// Send the request to the API server,
// and invoke onSearchRepsonse() with the response.
request.execute(onSearchResponse);
}
// Called automatically with the response of the YouTube API request.
function onSearchResponse(response) {
showResponse(response);
}
http://www.youtube.com/results?nfpr=1&search_query=profileproductionsuk&filters=channel&lclk=channel