-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathimdb.js
More file actions
44 lines (40 loc) · 1.24 KB
/
imdb.js
File metadata and controls
44 lines (40 loc) · 1.24 KB
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
var http = require('http');
const key = '4647eb5a';
function imdbRequest(query){
const response = http.get(`http://www.omdbapi.com/?t=${query}&y=2012&plot=full&apikey=${key}`, response => {
try{
let body = "";
response.on('data', data => {
body += data.toString();
});
response.on('end', () => {
try {
body = JSON.parse(body);
console.log("==============================================================");
console.log(body.Title);
console.log("-------------------------------------------");
console.log("Year: ", body.Year);
try {
console.log("Internet Movie Database: ", body.Ratings[0].Value);
} catch (error){
};
try {
console.log("Rotten Tomatoes: ", body.Ratings[1].Value);
} catch (error){
};
console.log("Release Year: ", body.Release);
console.log("Actor/s: ", body.Actors);
console.log("Country where it was produced: ", body.Country);
console.log("Language: ", body.Language);
console.log("-------------------------------------------");
console.log("Plot: ", body.Plot);
} catch (error) {
console.error("Seems we", error.message);
}
})
} catch(error){
console.error(error.message);
}
})
}
module.exports.get = imdbRequest;