Git Product home page Git Product logo

name-to-imdb's Introduction

name-to-imdb

Map names of movies/series to IMDB IDs

npm install name-to-imdb

Usage: nameToImdb(args, callback)

args - string of the name or object with name/year/type - { name: "The Devil Bat", year: 1940, type: "movie" }

args.providers - an array of providers to search in; possible options are metadata and imdbFind; default is ["metadata", "imdbFind"]

callback - A function that is called with either an error or the IMDB ID and match info. If no callback is provided, a Promise is returned instead.

Examples

imdbFind provider

var nameToImdb = require("name-to-imdb");
nameToImdb("south park", function(err, res, inf) { 
  console.log(res); // "tt0121955"
  // inf contains info on where we matched that name - e.g. metadata, or on imdb
  // and the meta object with all the available data
  console.log(inf);
})
// console.log(inf.meta)
{
  id: 'tt0121955',
  name: 'South Park',
  year: 1997,
  type: 'TV series',
  yearRange: '1997-',
  image: {
    src: 'https://m.media-amazon.com/images/M/MV5BOGE2YWUzMDItNTg2Ny00NTUzLTlmZGYtNWMyNzVjMjQ3MThkXkEyXkFqcGdeQXVyNTA4NzY1MzY@._V1_.jpg',
    width: 680,
    height: 1000
  },
  starring: 'Trey Parker, Matt Stone',
  similarity: 1
}
var nameToImdb = require("name-to-imdb");
nameToImdb("south park")
  .then(function ({res,inf}) {
    console.log(res); // "tt0121955"
    console.log(inf); // {match: 'metadata', isCached: false, meta: {...}}
  })
  .catch(function (error) {
    console.error(error);
  });
var nameToImdb = require("name-to-imdb");

async function search() {
  try {
    var result = await nameToImdb({ name: "The Matrix", year: 1999 });
    console.log(result.res); // "tt0133093"
    console.log(result.inf); // {match: 'metadata', isCached: false, meta: {...}}
  } catch (error) {
    console.error(error);
  }
}

search();

metadata provider

var nameToImdb = require("name-to-imdb");
nameToImdb({ name: "south park", type: 'series', providers: ['metadata'] }, function (err, res, inf) {
  console.log(res); // "tt0121955"
  // inf contains info on where we matched that name - e.g. metadata, or on imdb
  // and the meta object with all the available data
  console.log(inf); // inf: { match, meta }
})
// console.log(inf.meta)
{
  id: 'tt0121955',
  name: 'South Park',
  year: 1997,
  type: 'series',
  yearRange: undefined, // imdbFind only
  image: undefined,     // imdbFind only
  starring: undefined,  // imdbFind only
  similarity: undefined // imdbFind only
}

Note: while using "metadata" provider, you must specify the media type and the name must be in english

name-to-imdb's People

Contributors

ivshti avatar jaruba avatar duckyb avatar dexter21767-dev avatar dependabot[bot] avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.