Code Monkey home page Code Monkey logo

omdb's People

Contributors

crteal avatar danielfsousa avatar jpriebe avatar linusu avatar misterhat avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

omdb's Issues

api key now required.

The service is now private and requires an api key (minimum $1 donation per month on Patreon.)

https://www.patreon.com/posts/api-is-going-10743518

new url format is http://www.omdbapi.com/?i=tt3896198&apikey=[key]

also works http://www.omdbapi.com/?apikey=[key]&i=tt3896198

I have an api key to test, just can't figure out how to fix otherwise I'd submit a pull request lol.

edit:

So I have a temp fix, dirty code however. I only use queries per imdb id but it should work the same for querying by title.

https://github.com/misterhat/omdb/blob/master/index.js#L91
https://github.com/misterhat/omdb/blob/master/index.js#L153

change var query = {}; to var query = {apikey: 'key'};

tomatoUrl ignored in response

tomato: undefined when the response from OMDB includes:

{
  tomatoFresh: null
  tomatoImage: null
  tomatoMeter: null
  tomatoRating: null
  tomatoReviews: null
  tomatoRotten: null
  tomatoURL: "http://www.rottentomatoes.com/m/10009738-revanche/"
  tomatoUserMeter: null
  tomatoUserRating: null
  tomatoUserReviews: null
}

due to:

... tomato: !movie.tomatoMeter ? undefined : ...

here.

browser support

the website API supports a callback with &callback=name, so let's make the API work seamlessly in the browser with browserify.

Missing Rotten Tomatoes

I pass the "tomatoes: true" parameter in get method but the returned object comes with "tomato: undefined".

Update dependencies

Hey there,
Could you update your dependencies?

Or would you like me to PR?

Crash on Invalid JSON

Hi misterhat,

There are some known cases where OMDb returns invalid JSON. Because the omdb node module doesn't handle these errors, the program crashes. The problem is that Needle will not always return an object, only if it is able to parse the response. Else it will return a string. Object.keys won't work with a string.

/omdb/node_modules/omdb/index.js:167
Object.keys(movie).forEach(function (key) {
^
TypeError: Object.keys called on non-object
at Function.keys (native)
at /omdb/node_modules/omdb/index.js:167:20
at done (/omdb/node_modules/omdb/node_modules/needle/lib/needle.js:234:9)
at PassThrough. (/omdb/node_modules/omdb/node_modules/needle/lib/needle.js:363:11)
at PassThrough.emit (events.js:129:20)
at _stream_readable.js:908:16
at process._tickCallback (node.js:355:11)

Cases of invalid JSON:
First case: An escaped single quote in the movie plot (e.g. tt0477543)
Second case: Unescaped backslash in the movie title (e.g. tt0102445: “Title”: “Miliardi\Millions”)
The thirds case: The plot contains an invalid character \u001F (e.g. tt2091423)

I think it would be nice if your module could account for these exceptions and not crash.

Two suggestions: check for known problems in the returned JSON and try to fix them (remove illegal characters and escape un-escaped stuff). The second suggestions would be to use try catch and return undefined or an error in case the parsing is unsuccessful.

Does that sound like a good idea? Do you have time to implement a solution?

Poster paths in search results

Is there any reason the search results don't have the poster variable returned? Maybe because posters were only added recently I believe.

unexpected token o

Since the new update on the OmdbApi I have started to get the error "unexpected token o" when trying to use omdb.search.

Error when movie does exist but it does not have a poster

Index.js line 250 please add this:

} else if (res.poster == null || res.poster == '') {
            out.emit('error', new Error("Movie found but it does not have a poster")); 
} else {
            req = needle.get(res.poster);

Because of this:

\node_modules\needle\lib\needle.js:81
      throw new TypeError('URL must be a string, not ' + uri);
            ^
TypeError: URL must be a string, not null
    at Object.Needle.request (\node
_modules\omdb\node_modules\needle\lib\needle.js:81:13)
    at Object.exports.(anonymous function) [as get] (\node_modules\omdb\node_modules\needle\lib\needle.js:425:19)
    at \node_modules\omdb\index.js:251:26
    at \node_modules\omdb\index.js:198:13
    at done (\node_modules\omdb\node_modules\needle\lib\needle.js:234:9)
    at PassThrough.<anonymous> (\node_modules\needle\lib\needle.js:363:11)
    at PassThrough.emit (events.js:129:20)
    at _stream_readable.js:908:16
    at process._tickCallback (node.js:355:11)

Example movies:
Bare 2015
Deadman Inferno 2015

Cannot read property 'Response' of null

/Users/mike/Programming/personal/scripts/node_modules/omdb/index.js:224
        if (movie.Response === 'False') {
                 ^

TypeError: Cannot read property 'Response' of null
    at /Users/mike/Programming/personal/scripts/node_modules/omdb/index.js:224:18
    at done (/Users/mike/Programming/personal/scripts/node_modules/omdb/node_modules/needle/lib/needle.js:377:14)
    at PassThrough.<anonymous> (/Users/mike/Programming/personal/scripts/node_modules/omdb/node_modules/needle/lib/needle.js:576:9)
    at emitNone (events.js:72:20)
    at PassThrough.emit (events.js:166:7)
    at endReadableNT (_stream_readable.js:905:12)
    at doNTCallback2 (node.js:441:9)
    at process._tickCallback (node.js:355:17)

Please add country field.

It would be great if you could also parse country from JSON returned by omdbapi.com.

Thanks a lot!

Consuming lists with commas in items

As a specific example:

{  
  "Title":"Captain Phillips",
  "Year":"2013",
  "Rated":"PG-13",
  "Released":"11 Oct 2013",
  "Runtime":"134 min",
  "Genre":"Biography, Drama, Thriller",
  "Director":"Paul Greengrass",
  "Writer":"Billy Ray (screenplay), Richard Phillips (based upon the book \"A Captain's Duty: Somali Pirates,  Navy SEALS,  and Dangerous Days at Sea\" by), Stephan Talty (based upon the book \"A Captain's Duty: Somali Pirates,  Navy SEALS,  and Dangerous Days at Sea\" by)",
  "Actors":"Tom Hanks, Catherine Keener, Barkhad Abdi, Barkhad Abdirahman",
  "Plot":"The true story of Captain Richard Phillips and the 2009 hijacking by Somali pirates of the US-flagged MV Maersk Alabama, the first American cargo ship to be hijacked in two hundred years.",
  "Language":"English, Somali",
  "Country":"USA",
  "Awards":"Nominated for 6 Oscars. Another 16 wins & 128 nominations.",
  "Poster":"http://ia.media-imdb.com/images/M/MV5BMTQzNzExMDg3Ml5BMl5BanBnXkFtZTgwODU1NzEzMDE@._V1_SX300.jpg",
  "Metascore":"83",
  "imdbRating":"7.9",
  "imdbVotes":"298,666",
  "imdbID":"tt1535109",
  "Type":"movie",
  "Response":"True"
}

If you look at Writer you will see it contains a very ugly item (well, 2 really), Richard Phillips (based upon the book \"A Captain's Duty: Somali Pirates, Navy SEALS, and Dangerous Days at Sea\" by) This will be split into 3 items due to the commas in the parenthesises. I am unsure whether this is an issue in omdb or the way the module consumes it?

As a solution I was thinking about rewriting the parsing of list items to a progressive way (as in reading until a token) and ignoring commas between parenthesises ((, [, {) until they are closed but if there is an unclosed tag that would result in an other issue so I am not sure if that would be an actual improvement. Any thoughts?

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.