Skip to content

Commit

Permalink
Shippable v2.0.2 ✈️✈️✈️
Browse files Browse the repository at this point in the history
  • Loading branch information
lacymorrow committed Feb 16, 2018
1 parent ee81c85 commit fd252ab
Show file tree
Hide file tree
Showing 3 changed files with 51 additions and 16 deletions.
55 changes: 45 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,33 @@
[![movie-info](https://github.com/lacymorrow/movie-info/raw/master/demo.svg?sanitize=true)](https://github.com/lacymorrow/movie-info)

#### [Demo on RunKit](https://runkit.com/lacymorrow/movie-info) ([_Output_](https://movie-info-kdbpuifpuxt8.runkit.sh/?name=Oceans+Eleven))
#### [Try it on RunKit](https://runkit.com/lacymorrow/movie-info) ([_Output_](https://movie-info-kdbpuifpuxt8.runkit.sh/?name=Oceans+Eleven))


## Features
* Use anywhere, browser or Node - UMD ([CanIUse](https://caniuse.com/#feat=fetch))
* Promise and Callback API
* Finds:
* Title
* Release Date
* Poster and backdrop images
* IMDB rating + vote count
* Recent popularity rating
* Adult film (boolean)


## Install

```bash
// From the command line
$ npm install -g movie-info
```

```html
// Globally in the browser (Cloudflare CDN)
<script type="text/javascript" src="https://unpkg.com/movie-info" />
```
#### From the command line
Expand All @@ -40,17 +58,21 @@ $ npm install --save movie-info
const movieInfo = require('movie-info')
var movie = movieInfo('Avatar', function (err, res){
// Callbacks
movieInfo('Avatar', function (err, res){
if (err) return err;
console.log(res)
//=> { ... }
})
// Promises
movieInfo('Avatar').then(console.log)
// or, search with year and handle output
movieInfo('Oceans Eleven', '1960').then(
function (data) {
function (res) {
// success
console.log(data)
console.log(res)
//=> { ... }
},
function (err) {
Expand Down Expand Up @@ -78,14 +100,24 @@ movieInfo('Avatar').catch(error => {
popularity: 3.30511799781063,
title: 'Crash',
vote_average: 6.9,
vote_count: 271
vote_count: 271,
image_base: 'http://image.tmdb.org/t/p/original'
}
```
##### Images
Combine the `image_base` with the desired path to create a complete image URL.
```js
var imageUrl = response.image_base + response.poster_path
//=> http://image.tmdb.org/t/p/original/pG8LL4LYMCr5uikhx9rewrW8352.jpg
```
## API
### movieInfo(movie [, year ])
### movieInfo(movie [, year ] [, callback])
Returns a Promise which resolves to a movie object.
Expand All @@ -94,16 +126,19 @@ Returns a Promise which resolves to a movie object.
*Required*
Type: `string`
Movie to search for.
Movie title to search for.
#### year
#### year
Type: `string`
Type: `string`
Movie release year to search for. _(optional)_
Optional movie year.
#### callback (error, result)
type: `function`
Callback function. _(optional)_
## Related
Expand Down
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
var search = {
key: "9d2bff12ed955c7f1f74b83187f188ae",
base: "https://api.themoviedb.org",
image_base: "http://image.tmdb.org/t/p/original/",
image_base: "http://image.tmdb.org/t/p/original",
year: null,
movie: movie
};
Expand Down Expand Up @@ -75,12 +75,12 @@
return error;
});

// Callback or return Promise
// Callback and return Promise
if (cb) {
response.then(cb);
} else {
return response;
return response.then(cb.bind(null, null), cb);
}

return response;
}

// exposed public method
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "movie-info",
"version": "1.1.1",
"version": "2.0.2",
"description": "Get information, images, rating, description, etc. about a movie.",
"license": "MIT",
"repository": "lacymorrow/movie-info",
Expand Down

0 comments on commit fd252ab

Please sign in to comment.