Giter Site home page Giter Site logo

showtimes's Introduction

Showtimes · a movie showtimes API

NPM Travis CI js-standard-style

Installation

npm install showtimes --save

Usage

const Showtimes = require('showtimes');
const api = new Showtimes(10001, {});

api.getTheaters((error, theaters) => {
  if (error) {
    throw error
  }

  console.log(theaters);
});

Result

[ { id: '4c9f211a0800ff36',
    name: 'AMC Loews 34th Street 14',
    address: '312 W. 34th St., New York, NY',
    phoneNumber: '(888) 262-4386',
    movies:
     [ { id: 'cfbfd1f634e7638a',
         name: 'Star Wars: The Force Awakens 3D',
         runtime: '2hr 16min',
         rating: 'PG-13',
         genre: ['Scifi', 'Fantasy'],
         imdb: 'http://www.youtube.com/watch?v=tt08BH9COsI',
         trailer: 'http://www.imdb.com/title/tt2488496/',
         showtimes: [ '9:30am', '1:00pm', '4:30pm', '8:00pm' ] },
       { id: '89d9737d67580511',
         name: 'Star Wars: The Force Awakens',
         runtime: '2hr 16min',
         rating: 'PG-13',
         genre: ['Scifi', 'Fantasy'],
         imdb: 'http://www.youtube.com/watch?v=tt08BH9COsI',
         trailer: 'http://www.imdb.com/title/tt2488496/',
         showtimes: [ '10:00am', '1:30pm', '5:00pm', '8:30pm' ] } ] },
  { id: '7a9fd407207f4951',
    name: 'Bow Tie Chelsea Cinemas',
    address: '260 West 23rd Street, New York, NY',
    phoneNumber: '(212) 691-4744',
    movies:
     [ { id: 'cfbfd1f634e7638a',
         name: 'Star Wars: The Force Awakens 3D',
         runtime: '2hr 16min',
         rating: 'PG-13',
         genre: ['Scifi', 'Fantasy'],
         imdb: 'http://www.youtube.com/watch?v=tt08BH9COsI',
         trailer: 'http://www.imdb.com/title/tt2488496/',
         showtimes:
          [ '5:20am',
            '10:00am',
            '10:30am',
            '1:05pm',
            '1:35pm',
            '4:10pm',
            '4:40pm',
            '7:20pm',
            '7:50pm',
            '10:30pm',
            '11:00pm' ] }] }
  ...
]

Documentation

API

showtimes(location, options)

  • location — The location you want to pull showtimes for. This can be either a zipcode, latitude and Longitude, or a full address.
  • options
    • date — Number of days in the future you want to pull showtimes for. (ex. on june 9, 2014, pulling showtimes for july 29 you'd pass in "50")
    • lang — Language of the response, this will localize the movie names, times, etc. (ex. "en" (default) or "tr" for Turkish data)
    • pageLimit — Page limit for request. By default, this returns allm (999) pages.

showtimes.getTheaters(callback)

  • callback — Callback function to run after generating a standardized response of theaters.
    • error — Any error messages that were found when doing a query. Null if all is good.
    • theaters — Standardized response of theaters.

showtimes.getTheater(theaterId, callback)

  • theaterId — Theater ID for the theater you want to query. You can get this from a getTheaters()orgetMovies()` response.
  • callback — Callback function to run after generating a standardized theater response.
    • error — Any error messages that were found when doing a query. Null if all is good.
    • theater — Standardized response for the theater.

showtimes.getMovies(callback)

  • callback — Callback function to run after generating a standardized response of movies.
    • error — Any error messages that were found when doing a query. Null if all is good.
    • movies — Standardized response of movies.

showtimes.getMovie(movieId, callback)

  • movieId — Movie ID for the movie you want to query. You can get this from a getTheaters() or getMovies() response.
  • callback — Callback function to run after generating a standardized movie response.
    • error — Any error messages that were found when doing a query. Null if all is good.
    • movie — Standardized response for the movie.

Standardized Responses

Theater

{
  id: '4c9f211a0800ff36',
  name: 'AMC Loews 34th Street 14',
  address: '312 W. 34th St., New York, NY',
  phoneNumber: '(888) 262-4386',
  movies: [<movies>],
  showtimes: ['9:30am', '1:00pm', '4:30pm', '8:00pm']
}
  • id is represented as false if no theater ID could be obtained (usually only happens on some boutique theaters).
  • phoneNumber and movies are only available on getTheaters().
  • showtimes is only available through getMovies() or getMovie().
  • address and phoneNumber are all optional, and not always present for every theater.

Movie

{
  id: 'cfbfd1f634e7638a',
  name: 'Star Wars: The Force Awakens 3D',
  runtime: '2hr 16min',
  rating: 'PG-13',
  genre: ['Scifi', 'Fantasy'],
  imdb: 'http://www.youtube.com/watch?v=tt08BH9COsI',
  trailer: 'http://www.imdb.com/title/tt2488496/',
  director: 'J.J. Abrams',
  cast: [<cast>]
  description: 'In this continuation of the "Star Wars" saga, ... the former Rebel Alliance.',
  theaters: [<theaters>],
  showtimes: ['12:20pm', '3:40pm', '6:30pm', '7:00pm', '9:50pm', '10:20pm']
}
  • director, cast, description, and theaters are only available from getMovies and getMovie()
  • showtimes is only available from getTheaters().
  • genre, rating, runtime, imdb, and trailer are all optional, and not always present on every movie.

Upgrading to v2

With v2, I've moved the entire library over to be written in ES6 so components can be easily reused with having the library internals be a proper class. Unfortunately, this has made v2 incompatibe with v1, but thankfully only a few minor things have changed with the API.

  1. Instead of calling the library as s = Showtimes(location), you must now instantiate the class with s = new Showtimes(location).
  2. The genre response that comes back from API calls is now represented as an array instead of a compounded string.

showtimes's People

Contributors

amilajack avatar berkaytheunicorn avatar chrux avatar enwin avatar erunion avatar iuriaranda avatar jclgoodwin avatar jmathai avatar jstart avatar wes-nz 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  avatar  avatar  avatar

Watchers

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

showtimes's Issues

.getMovie()

Should be able to pass in a movie ID, like `c30e28c6168184d9 for Maleficent, and get back an array of theaters in the configured location and day that are showing it and their cooresponding showtimes.

var Showtimes = require('showtimes');
var s = new Showtimes(94118, {});
s.getMovie('c30e28c6168184d9', function (theaters) {
  /*[ { id: '1441318e8d47fc1b',
      name: 'Vogue Theatre',
      address: '3290 Sacramento Street, San Francisco, CA',
      phone_number: '(415) 346-2228',
      showtimes: [ '‎2:45‎pm', '‎7:15pm‎'] },
    { id: '87f533be471c287d',
      name: '4-Star Theatre',
      address: '2200 Clement Street, San Francisco, CA',
      phone_number: '(415) 666-3488',
      showtimes:[ '‎1:15‎pm', '‎3:40‎pm', '‎6:10‎pm', '‎8:35pm‎'] }]*/
});

Configurable API services

It would be awesome to not have to rely on scraping Google Movies and instead be able to configure what movie showtime service to utilize. I'm not sure if this would require having to install a plugin like showtimes-google-movies, or if you'd just pass in service: 'google-movies' into the options object.

If an API service, like Tribune Media Services required an API key, that could also just be passed into the options object I suppose.

Don't submit ES6 source to npm - compile first, and only publish ES5 code

Put this in your package.json which will auto-compile/transpile your code before publishing to NPM:

"scripts": {
    "compile": "babel -d lib/ src/",
    "prepublish": "npm run compile"
},

This way, I don't need to transpile your module to use it in my project. You would just publish as normal:

npm publish ./

Callback wouldn't fire

Hi!

There is no response at all, I did not get anything back from the callback. Is it just me?

Ps.: trying with latlong, 's' object looks okay.

Thanks!

.getTheater()

Need to be able to pass in a movie theater ID, like 1441318e8d47fc1b for the Vogue Theatre, in and get back an array of movies and showtimes for the configured day.

var Showtimes = require('showtimes');
var s = new Showtimes(94118, {});
s.getTheater('1441318e8d47fc1b', function (movies) {
  /*[ { id: 'c30e28c6168184d9',
         name: 'Maleficent',
         runtime: '‎1hr 37min‎‎',
         rating: 'PG‎‎',
         genre: 'Action/Adventure‎',
         imdb: 'http://www.imdb.com/title/tt1587310/',
         trailer: 'http://www.youtube.com/watch?v=CelenfcEszk',
         showtimes: [ '‎2:45‎pm', '‎7:15pm‎'] },
       { id: 'd64ac30103cb0ea6',
         name: 'Maleficent 3D',
         runtime: '‎1hr 37min‎‎',
         rating: 'PG‎‎',
         genre: 'Action/Adventure‎',
         imdb: 'http://www.imdb.com/title/tt1587310/',
         trailer: 'http://www.youtube.com/watch?v=CelenfcEszk',
         showtimes: [ '‎5:00pm‎'] }]*/
});

Keeping v1.x alive

Hi @erunion,

What do you think about keeping version 1.x alive in a separate branch? I am willing to work on that

Best

Failing unit tests.

https://travis-ci.org/jonursenbach/showtimes/builds/47564386

> [email protected] test /home/travis/build/jonursenbach/showtimes
> tap test/
TypeError: Cannot read property 'length' of undefined
    at /home/travis/build/jonursenbach/showtimes/test/index.js:25:21
    at Request._callback (/home/travis/build/jonursenbach/showtimes/index.js:86:7)
    at Request.self.callback (/home/travis/build/jonursenbach/showtimes/node_modules/request/request.js:373:22)
    at Request.emit (events.js:98:17)
    at Request.<anonymous> (/home/travis/build/jonursenbach/showtimes/node_modules/request/request.js:1318:14)
    at Request.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/home/travis/build/jonursenbach/showtimes/node_modules/request/request.js:1266:12)
    at IncomingMessage.emit (events.js:117:20)
    at _stream_readable.js:944:16
    at process._tickCallback (node.js:442:13)
not ok test/index.js .................................... 1/2
    Command: "/home/travis/.nvm/v0.10.35/bin/node index.js"
    TAP version 13
    ok 1 type is string
    not ok 2 test/index.js
      ---
        exit:    8
        stderr:  |
          TypeError: Cannot read property 'length' of undefined
              at /home/travis/build/jonursenbach/showtimes/test/index.js:25:21
              at Request._callback (/home/travis/build/jonursenbach/showtimes/index.js:86:7)
              at Request.self.callback (/home/travis/build/jonursenbach/showtimes/node_modules/request/request.js:373:22)
              at Request.emit (events.js:98:17)
              at Request.<anonymous> (/home/travis/build/jonursenbach/showtimes/node_modules/request/request.js:1318:14)
              at Request.emit (events.js:117:20)
              at IncomingMessage.<anonymous> (/home/travis/build/jonursenbach/showtimes/node_modules/request/request.js:1266:12)
              at IncomingMessage.emit (events.js:117:20)
              at _stream_readable.js:944:16
              at process._tickCallback (node.js:442:13)
        command: "/home/travis/.nvm/v0.10.35/bin/node index.js"
      ...

    1..2
    # tests 2
    # pass  1
    # fail  1

total ................................................... 1/2
not ok
npm ERR! Test failed.  See above for more details.
npm ERR! not ok code 0
The command "npm test" exited with 1.

<U+200E> encodings hidden in theater JSON output.

{ id: '1441318e8d47fc1b',
  name: 'Vogue Theatre',
  address: '3290 Sacramento Street, San Francisco, CA',
  phone_number: '(415) 346-2228',
  movies:
    [ { id: 'c30e28c6168184d9',
      name: 'Maleficent',
      runtime: '<U+200E>1hr 37min<U+200E><U+200E>',
      rating: 'PG<U+200E><U+200E>',
      genre: 'Action/Adventure<U+200E>',
      imdb: 'http://www.imdb.com/title/tt1587310/',
      trailer: 'http://www.youtube.com/watch?v=CelenfcEszk',
      showtimes: [ '<U+200E>2:45<U+200E>pm', '<U+200E>7:15pm<U+200E>'] },
    { id: 'd64ac30103cb0ea6',
      name: 'Maleficent 3D',
      runtime: '<U+200E>1hr 37min<U+200E><U+200E>',
      rating: 'PG<U+200E><U+200E>',
      genre: 'Action/Adventure<U+200E>',
      imdb: 'http://www.imdb.com/title/tt1587310/',
      trailer: 'http://www.youtube.com/watch?v=CelenfcEszk',
      showtimes: [ '<U+200E>5:00pm<U+200E>'] }

24-hour clock

Google sometimes displays times like "11:00‎ ‎12:45‎ ‎16:10‎ ‎20:40‎" and we end up with [ '11:00false', '12:45false', '16:10false', '20:40false' ] because meridiem = false.

Proper error handling

Instead of outputting errors to the console, the library should pull them back to the callback, preferably as the first argument of that callback.

Google Showtimes is closed

"Google Showtimes was discontinued on November 1, 2016. You can now discover showtimes on the search results page by searching for the name of the movie you want to see or try searching for the word “movies” to discover what’s in theaters."

The api is no longer working.

Parsing issues with German locations.

http://google.com/movies?near=Goebelstr.+11%2C+64293+Darmstadt%2C+Germany+-+06151+8705868

Maleficent - Die dunkle Fee info= [ '‎1hr 36min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Das Schicksal ist ein mieser Verr�ter info= [ '‎2hr 6min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Tinkerbell und die Piratenfee info= [ '‎1hr 18min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
A Million Ways to Die in the West info= [ '‎1hr 56min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
X-Men: Zukunft ist Vergangenheit info= [ '‎2hr 12min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Das magische Haus info= [ '‎1hr 25min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
About Last Night info= [ '‎1hr 40min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Die Monster Uni info= [ '‎1hr 44min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
WM 2014: Italien - Costa Rica info= [ '‎‎' ]
WM 2014: Schweiz - Frankreich info= [ '‎‎' ]
Maleficent - Die dunkle Fee info= [ '‎1hr 36min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Maleficent - Die dunkle Fee info= [ '‎1hr 36min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Tinkerbell und die Piratenfee info= [ '‎1hr 18min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Das magische Haus info= [ '‎1hr 25min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Bad Neighbors info= [ '‎1hr 37min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Edge of Tomorrow info= [ '‎1hr 53min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Einmal Hans mit scharfer So�e info= [ '‎1hr 36min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Die Schadenfreundinnen info= [ '‎1hr 49min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Cuban Fury info= [ '‎1hr 38min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Nix wie weg - vom Planeten Erde info= [ '‎1hr 29min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Die zwei Gesichter des Januars info= [ '‎1hr 37min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Bibi & Tina - Der Film info= [ '‎1hr 41min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Grace of Monaco info= [ '‎1hr 42min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Muppets Most Wanted info= [ '‎1hr 48min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Free Birds info= [ '‎1hr 32min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Transcendence info= [ '‎2hr 0min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Maleficent - Die dunkle Fee info= [ '‎1hr 36min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Tinkerbell und die Piratenfee info= [ '‎1hr 18min‎‎', 'Rated Ohne Altersbeschr�nkung‎' ]
Edge of Tomorrow info= [ '‎1hr 53min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Boyhood info= [ '‎2hr 46min‎‎', 'Rated Freigegeben ab 6 Jahren‎' ]
Zoran - Mein Neffe, der Idiot info= [ '‎1hr 53min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Maman und ich info= [ '‎1hr 27min‎‎', 'Rated Freigegeben ab 12 Jahren‎' ]
Die unersch�tterliche Liebe der Suzanne info= [ '‎1hr 34min‎' ]

TypeError: Cannot call method 'match' of undefined
    at Object.<anonymous> (/Users/erunion/code/showtimes/index.js:124:23)
    at exports.each (/Users/erunion/code/showtimes/node_modules/cheerio/lib/api/traversing.js:267:24)
    at Object.<anonymous> (/Users/erunion/code/showtimes/index.js:109:41)
    at exports.each (/Users/erunion/code/showtimes/node_modules/cheerio/lib/api/traversing.js:267:24)
    at Request._callback (/Users/erunion/code/showtimes/index.js:93:19)
    at Request.self.callback (/Users/erunion/code/showtimes/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Users/erunion/code/showtimes/node_modules/request/request.js:985:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/erunion/code/showtimes/node_modules/request/request.js:936:12)

With this, apparently it's possible for a movie entry to not have an info datapoint.

Not all movie theaters have IDs.

http://google.com/movies?near=48374&start=10

TypeError: Parameter 'url' must be a string, not undefined
    at Url.parse (url.js:107:11)
    at Object.urlParse [as parse] (url.js:101:5)
    at Object.<anonymous> (/Users/erunion/code/showtimes/index.js:94:32)
    at exports.each (/Users/erunion/code/showtimes/node_modules/cheerio/lib/api/traversing.js:267:24)
    at Request._callback (/Users/erunion/code/showtimes/index.js:90:19)
    at Request.self.callback (/Users/erunion/code/showtimes/node_modules/request/request.js:121:22)
    at Request.EventEmitter.emit (events.js:98:17)
    at Request.<anonymous> (/Users/erunion/code/showtimes/node_modules/request/request.js:985:14)
    at Request.EventEmitter.emit (events.js:117:20)
    at IncomingMessage.<anonymous> (/Users/erunion/code/showtimes/node_modules/request/request.js:936:12)

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.