A wrapper on omdb module to easy select correct wanted item with all info
Use ES6 Promise for search and get a title info.
with npm:
$ npm install --save imdb-search
or with yarn:
$ yarn add imdb-search
const imdb = require('imdb-search');
// Search for a Movie, result is an array of movies
imdb.search('Doctor Strange')
.then(result => {
for (let movie of result) {
console.log(`${movie.id}: ${movie.title} - ${movie.year}`);
}
})
.catch(err => {
console.log(err);
});
// We can pass year and type as optional args to get right result
// Because of omdb dependency movies can have this types: `series, movie, episode`
imdb.search('Doctor Strange', 2016, 'movie')
.then(result => {
for (let movie of result) {
console.log(`${movie.id}: ${movie.title} - ${movie.year}`);
}
})
.catch(err => {
console.log(err);
});
// We can select item number in returned result
imdb.search('Doctor Strange', 2016, 'movie')
.then(result => {
return imdb.get(0); // Select first movie on the list
})
.then(movie => {
console.log(`${movie.title} - ${movie.year}`);
})
.catch(err => {
console.log(err);
});
// Get a movie with imdb id
imdb.get('tt1211837')
.then((movie) => {
console.log(`${movie.title} - ${movie.year}`);
})
.catch((err) => {
console.log(err);
});
Use this method to search on imdb with name, you can pass year and type as optional arguments.
Search method return an array of movies.
Note: Each item of search array have one field namedid
(internal id), use this id to get more info.
Use this method to get a movie from the list of movies on the last search
Note: id
value can be an internal id or imdb specific id.