Nameless Package Manager
Unleash awesomeness. Private packages, team management tools, and powerful integrations. Get started with npm Orgs »

movie-trailer

2.0.3 • Public • Published

movie-trailer npm version Build Status Try movie-trailer on RunKit

Fetch movie trailer url(s): "Oceans Eleven" ➔ http://path/to/trailer

movie-trailer

Try it on RunKit (Output)

Features

  • Fetch Youtube trailers for any movie
  • Return one or many trailer URLs
  • Use anywhere, browser or Node - UMD (Browser Support)
  • Promise and Callback API

Install

Using NPM:

npm install --global movie-trailer

In the browser:

<!-- movieTrailer window global -->
<script type="text/javascript" src="https://unpkg.com/movie-trailer"></script>

(via Unpkg, or via JSDelivr)

Usage

const movieTrailer = require('movie-trailer');
 
movieTrailer('Crash').then(console.log)
 
//=> https://www.youtube.com/watch?v=durNwe9pL0E
Search using release date year
movieTrailer('Oceans Eleven', 1960)
  .then( response => console.log( response ) )
 
//=> http://path/to/trailer
Return an array of URLs
movieTrailer('Oceans Eleven', true)
  .then( response => console.log( response ) )
  
//=> [ ... ]
Both
movieTrailer( 'Oceans Eleven', {year: '1960', multi: true} )
  .then( response => console.log( response ) )
 
//=> [ ... ]
Callback
movieTrailer( 'Oceans Eleven', ( error, response ) => {
    console.log( response ); 
    //=> http://path/to/trailer
} )
 

API

movieTrailer(movie [, options ] [, callback])

  • #### movie

    Required

    Type: string

    Movie to search for.

  • #### options

    Type: object

    • ##### year

      Type: string || number

      Optional movie year.

      Use -y or --year on the CLI

    • ##### multi

      Type: boolean

      Optionally return array of urls instead of a single url.

      Use -m or --multi on the CLI

    You may specify either option or an object containing multi and year properties

  • #### callback(error, response)

    Callback function.

From the command line

$ movie-trailer --help
 
Usage
  $ movie-trailer movie [year] [multi]
 
Example
  $ movie-trailer 'Oceans Eleven' 1960
  //=> http://path/to/trailer

Related

License

This package uses data from TMDB. You may consult TMDB terms of service for usage rights.

MIT © Lacy Morrow

install

npm i movie-trailer

Downloadsweekly downloads

21

version

2.0.3

license

MIT

homepage

github.com

repository

Gitgithub

last publish

collaborators

  • avatar
Report a vulnerability