-
Notifications
You must be signed in to change notification settings - Fork 0
/
fns.js
54 lines (46 loc) · 1.49 KB
/
fns.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
45
46
47
48
49
50
51
52
53
var movieSearch = function(movie){
var hello = [];
var url = 'http://api.themoviedb.org/3/',
mode = 'search/movie?query=',
input = movie,
key = '&api_key=e0c6c7bded5055b146501304684b8f94';
$.get(url + mode + input + key, function(response) {
hello = movieCredits(response.results[0].id,response.results[0].original_title)
})
debugger
};
var tvSearch = function(tv){
var url = 'http://api.themoviedb.org/3/',
mode = 'search/tv?query=',
input = tv,
key = '&api_key=e0c6c7bded5055b146501304684b8f94';
return $.get(url + mode + input + key).then(function(response){
tvCredits(response.results[0].id,response.results[0].name);
})
}
var movieCredits = function(id,title){
var meep = title;
var url = 'http://api.themoviedb.org/3/',
mode = 'movie/' +id+ '/credits?query=',
input = "hello",
key = '&api_key=e0c6c7bded5055b146501304684b8f94';
return $.get(url + mode + key).then(function(response){
var cast = [];
response.cast.forEach(function(element){
cast.push(element.character, element.name);
});
});
return cast
};
var tvCredits = function(id,title){
var url = 'http://api.themoviedb.org/3/',
mode = "tv/" + id + "/credits?query=",
key = '&api_key=e0c6c7bded5055b146501304684b8f94';
var cast = [title]
return $.get(url + mode + key).then(function(response){
response.cast.forEach(function(element){
cast.push(element.character, element.name)
});
return(cast)
})
}