Skip to content
Projets

À propos

Find YouTube trailer URLs for any movie or TV show

Développement web et applicatif

Comment ces chiffres sont mesurés

What you can do

  • Fetch YouTube trailers for any movie or TV show
  • Return one URL or many — videos, IDs, or full URLs
  • Async/await, Promise, and callback API
  • Use anywhere — browser or Node, UMD bundle (browser support)

Progression mesurée des étoiles

in 24h
0
in 7 days
0
in 15 days
0
in 1 month
Historique en cours

Variations nettes sur des périodes qui se chevauchent, pas des totaux quotidiens. Les mesures absentes restent vides. Les étoiles indiquent l’intérêt, pas la qualité.

README.md

Original
movie-trailer

Find YouTube trailer URLs for any movie or TV show ➔ "Up" → https://www.youtube.com/watch?v=…

npm version npm downloads CI License Try on RunKit

movie-trailer demo

[!IMPORTANT] This library is feature-complete and only receives bug-fix updates. Feature requests still welcome — please open an issue.

Features

  • Fetch YouTube trailers for any movie or TV show
  • Return one URL or many — videos, IDs, or full URLs
  • Async/await, Promise, and callback API
  • Use anywhere — browser or Node, UMD bundle (browser support)
  • Works in React + Next.js, client and server, via isomorphic-fetch
  • Bring your own TMDB API key, or use the default

Install

npm install movie-trailer

In the browser:

<!-- movieTrailer as a window global -->
<script src="https://unpkg.com/movie-trailer"></script>

Also available via JSDelivr.

Usage

const movieTrailer = require("movie-trailer");
// or: import movieTrailer from "movie-trailer";

await movieTrailer("Up");
//=> https://www.youtube.com/watch?v=...

TV shows

await movieTrailer("Shameless", { videoType: "tv" });
//=> https://www.youtube.com/watch?v=...

Many trailers — IDs only

await movieTrailer("Oceans Eleven", { id: true, multi: true });
//=> ["XXXXXXXXX", "XXXXXXXXX", ...]

Year disambiguation + multiple URLs

await movieTrailer("Oceans Eleven", { year: "1960", multi: true });
//=> ["https://www.youtube.com/watch?v=...", ...]

Legacy positional year

await movieTrailer("Oceans Eleven", 1960);
//=> https://www.youtube.com/watch?v=...

[!TIP] Try it live — open in RunKit (example output).

API

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

Pass a movie or show title (or null if searching by tmdbId). Returns a Promise that resolves to a YouTube URL — or an array of URLs / IDs depending on options.

Option Type Default Description
apiKey string TMDB default Use your own TMDB key — get one free
id boolean false Return only YouTube video IDs (e.g. "abc123" instead of full URLs)
language string Movie release language code (e.g. "de_DE")
multi boolean false Return an array of results instead of a single result
tmdbId string | number Search by TMDB content ID instead of a title (pass null as the first argument)
year string | number Release-year disambiguator
videoType "movie" | "tv" "movie" Movie or TV search

The third argument may also be a Node-style (err, response) => void callback.

Search by TMDB ID

await movieTrailer(null, { tmdbId: 161 });  // Ocean's Eleven

CLI

npx movie-trailer --help
#  Usage
#    $ npx movie-trailer movie
#
#  Options
#    --api_key, -k   Your own TMDB API key
#    --id,      -i   Return just the YouTube video ID
#    --language,-l   Language code (e.g. 'de_DE')
#    --multi,   -m   Return an array of URLs
#    --tmdb_id, -t   Search by TMDB ID
#    --year,    -y   Release year
#
#  Example
#    $ npx movie-trailer 'Oceans Eleven' -y 1960 -m
#    => https://www.youtube.com/watch?v=...

Related

Part of a small family of media-data utilities:

  • album-art — Fetch album and artist cover art.
  • movie-art — Get the poster art for a movie.
  • movie-info — Get info, images, and ratings about a movie.

Acknowledgments

License

MIT © Lacy Morrow

If movie-trailer saved you time, consider sponsoring on GitHub, supporting on Patreon, or buying a coffee.

Explorer des projets similaires

Chargement…