movie-art
v3.0.2
Published
Fetch art for a movie or tv show: 'Oceans Eleven' ➔ http://path/to/oceans_eleven_poster.jpg
Maintainers
Readme
[!IMPORTANT] This library is feature-complete and only receives bug-fix updates. Feature requests still welcome — please open an issue.
Features
- Use anywhere — browser or Node, UMD bundle (browser support)
- Works in React + Next.js, client and server, via isomorphic-fetch
- Promise and callback API
- Movies and television
- Poster (portrait) or backdrop (landscape) — or both at once
- Multiple poster sizes from TMDB
Install
npm install movie-artIn the browser:
<!-- movieArt as a window global -->
<script src="https://unpkg.com/movie-art"></script>Also available via JSDelivr.
Usage
const movieArt = require("movie-art");
movieArt("Oceans Eleven").then(console.log);
//=> http://path/to/oceans_eleven.jpgCallback form
movieArt("Oceans Eleven", (error, response) => {
console.log(response);
//=> http://path/to/oceans_eleven.jpg
});Year + size options
movieArt("Oceans Eleven", { year: "1960", size: "w92" }).then(console.log);
//=> http://path/to/oceans_eleven_poster_1960_small.jpgBackdrop + poster at once
movieArt("Oceans Eleven", { output: "all" }).then(console.log);
//=> {
// poster: "http://path/to/oceans_eleven_poster.jpg",
// backdrop: "http://path/to/oceans_eleven_backdrop.jpg",
// }Television
movieArt("Star Trek: The Original Series", { type: "tv", output: "all" })
.then(r => console.log(r.poster));
//=> http://path/to/star_trek_the_original_series_poster.jpg[!TIP] Try it live — open in RunKit (here's an example output).
API
movieArt(search [, options] [, callback])
Accepts a movie or TV show title and returns a Promise resolving to a URL string (or an object, with output: "all").
| Option | Type | Default | Description |
|---|---|---|---|
| year | string | | Optional release year disambiguator |
| size | "w92" \| "w154" \| "w185" \| "w342" \| "w500" \| "w780" \| "original" | "original" | Poster size |
| type | "movie" \| "tv" | "movie" | Movie or television search |
| output | "poster" \| "backdrop" \| "all" | "poster" | What to return |
The third argument may also be a Node-style (err, response) => void callback.
CLI
npm install --global movie-art
movie-art --help
# Usage
# $ movie-art <search> [flags]
#
# Flags
# --year, -y Release year
# --size, -s w92 | w154 | w185 | w342 | w500 | w780 | original
# --type, -t tv | movie (default: movie)
# --output, -o poster | backdrop | all (default: poster)
#
# Example
# $ movie-art 'Oceans Eleven' --year 1960 --size w92
# => http://path/to/oceans_eleven_poster_1960_small.jpgRelated
Part of a small family of media-data utilities:
- album-art — Fetch album and artist cover art.
- movie-info — Get info, images, and ratings about a movie.
- movie-trailer — Find the trailer for a movie.
Acknowledgments
- TMDB — image data (subject to the TMDB Terms of Service).
