misterhat / omdb Goto Github PK
View Code? Open in Web Editor NEWA module to access OMDb API.
License: MIT License
A module to access OMDb API.
License: MIT License
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'};
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.
The 'Year' for tt3069212 is '2014-' not '2014', so omdb module returns 'NaN'. I think this field can be trimmed before parse to a number. Thanks.
the website API supports a callback with &callback=name
, so let's make the API work seamlessly in the browser with browserify.
I pass the "tomatoes: true" parameter in get method but the returned object comes with "tomato: undefined".
Hey there,
Could you update your dependencies?
Or would you like me to PR?
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?
Is there any reason the search results don't have the poster
variable returned? Maybe because posters were only added recently I believe.
Is it possible to add the "type" parameter to the omdb.get method? It is available here: http://www.omdbapi.com/
I know it is in the search method, but it would be much better if it were available to the get method as well. Thanks.
Since the new update on the OmdbApi I have started to get the error "unexpected token o" when trying to use omdb.search.
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
Get that error when running .search()
/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)
this would make it easy to use any existing settings the user has entered for the initial requst (such as proxies), and is more convenient than having a separate method.
It would be great if you could also parse country from JSON returned by omdbapi.com.
Thanks a lot!
don't think it's needed anymore
Why isn't there enough good movies?
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?
Is there a way to pass in your API key? How many requests can this library take before it temporarily maxes out?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.