CLI Movie Times Data Gem

In this post, I want to walk you through how to use my CLI data gem. I built this gem to satisfy the requirements of the first assessment in the Learn Verified Full Stack Web Developer course. I’ve been really enjoying the course so far.

I’ve included a couple of videos to show you how you can get this project set up locally if you’d like to use this yourself.

The first video covers the process of what you’ll need to do if you want to use this project with live data from the Gracenote OnConnect movie showtimes database. The second video is a walkthrough of how you can use the Command Line Interface to explore Movie Showtimes. If you’d prefer to read, I’ll cover the steps in the post below as well.

Part 1 will walk you through setting up the Command Line Interface with your own API key, and Part 2 will show you how to explore the Interface with test data that you can get running right out of the box.

Part 1: Getting Started with your own API Key

The first thing you’ll need to do if you want to use this yourself is to go to the gracenote on connect website and create an account in order to register for an API key. A free account will allow you to make 50 calls per day to the gracenote database to retrieve movie times.

You should get a response shortly from gracenote with your API key. Once you get that information you’ll want to fork and clone the github repository and cd into the root of the project folder. Once there, you’ll want to enter the following command:

sudo nano .env

then enter

API_KEY=paste_your_api_key_here

type `Ctrl+O` and then `return` to save the file and `Ctrl+X` to close.

Once you’ve done that, you’ll be able to run the following command to start up the Command Line Interface:

ruby bin/nowshowing

The next few paragraphs will walk you throughis going to walk you through some prompts so that you can get a feel for what it’s like to use the interface once you have an API key, but if you’d just like to explore the interface and save the setup for later, you can skip to the next section and come back later.

After you enter `ruby bin/nowshowing`, you’ll be prompted to enter three pieces of information that will determine which movie data you get from the gracenote database. Respond to each of the following prompts and then press return:

  1. Zipcode
Please enter the zip code you’d like to search for movie showtimes.

2. Search Radius

The default search radius for movie showtimes is 5 miles. Press Enter if this is okay, or enter a number between 1 and 100 if you’d like to change the search radius.

3. Date

The default showing date is today. Press enter if this is okay, or enter a future date in the following format: 2016–06–05

After entering your responses to these three prompts, the program will fetch the movie data and, after it’s finished, you’ll see the following output:

We’re getting the movie data now.
All right! Welcome to the DlmNowShowing Movie Showings Command Line Interface!
The following commands are available:
movies lists movies with nearby showtimes
movie lists the nearby showtimes of a particular movie
genres lists the genres of movies playing nearby
genre lists the nearby showtimes of a particular genre
theatres lists the theatres with showtimes nearby
theatre lists the showtimes of movies at a particular theatre
home returns to the home prompt where all commands are available
exit quits the program
What would you like to do? (type ‘help’ for a list of commands or ‘exit’ to quit)

Great, so now we’re in the thick of it. In the next section, I’ll show you how we can navigate the interface using test data that is provided right out of the box.

Part 2: Exploring the Interface with Test Data

After you’ve forked and cloned the github repository, you’ll want to cd into the project directory and enter the following command:

ruby bin/nowshowingtest

When you run this command, the program will load movie data for showtimes within 5 miles of Zipcode 90066 on June 4th, 2016. After entering this command, you should see the same prompt as the one from the end of the previous section:

We’re getting the movie data now.
All right! Welcome to the DlmNowShowing Movie Showings Command Line Interface!
The following commands are available:
movies lists movies with nearby showtimes
movie lists the nearby showtimes of a particular movie
genres lists the genres of movies playing nearby
genre lists the nearby showtimes of a particular genre
theatres lists the theatres with showtimes nearby
theatre lists the showtimes of movies at a particular theatre
home returns to the home prompt where all commands are available
exit quits the program
What would you like to do? (type ‘help’ for a list of commands or ‘exit’ to quit)

Movies

If we choose the first option, movies, we’ll see a list of movies that are playing nearby:

1. The Angry Birds Movie
2. Teenage Mutant Ninja Turtles: Out of the Shadows
3. X-Men: Apocalypse
4. Love & Friendship
5. The Lobster
6. Me Before You
7. The Angry Birds Movie 3D
8. Teenage Mutant Ninja Turtles: Out of the Shadows 3D
9. X-Men: Apocalypse 3D
10. Captain America: Civil War
11. Popstar: Never Stop Never Stopping
12. Neighbors 2: Sorority Rising
13. The Nice Guys
14. Alice Through the Looking Glass
15. Alice Through the Looking Glass 3D
16. The Jungle Book
17. Money Monster
18. The Jungle Book 3D
19. A Aa
20. Housefull 3
21. Maggie’s Plan
22. Weiner
23. Chevalier
24. The Rocky Horror Picture Show
25. The Fallen Idol
26. Approaching the Unknown
27. Time to Choose
28. Captain America: Civil War 3D
29. The Meddler
30. Passage to Mars
31. Eva Hesse
32. The Idol
33. Holy Hell
34. A Bigger Splash
35. The Man Who Knew Infinity
36. The Wailing
37. Teenage Mutant Ninja Turtles: Out of the Shadows — An IMAX 3D Experience
38. Scarface
39. The Room
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

Now we can select a movie by number and we’ll get a list of all of its showtimes at nearby theatres. Let’s say we want to see Me Before You. Type in 6 and hit return and you’ll see the following output:

Me Before You is playing at:
AMC Marina Marketplace 6
1:00 4:00 7:00 10:00
AMC Dine-in Theatres Marina 6
11:45AM 3:00 6:00 9:00
Cinemark 18 & XD
11:35AM 2:20 5:05 7:50 10:35
ArcLight Culver City
09:40AM 12:05PM 2:30 4:55 7:10 9:25 11:40
The Landmark
11:30AM 12:00PM 2:05 2:35 4:35 5:10 7:20 7:50 9:55 10:20
ArcLight Santa Monica
10:15AM 12:30PM 2:40 5:20 7:45 9:30 11:25
AMC Century City 15
10:45AM 1:50 3:00 4:30 7:30 9:15
iPic Theaters Westwood
1:00 4:30 7:45 11:00
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

You’ll notice by the last line of the prompt above that we still have access to that numbered list of movies. So, if we want to see the showtimes for Neighbors 2, we can type in 12 and we’ll get the showtimes for that movie:

Neighbors 2: Sorority Rising is playing at:
AMC Dine-in Theatres Marina 6
1:15 4:00 7:30 10:05
Cinemark 18 & XD
12:40PM 3:10 5:40 8:10 10:40
AMC Santa Monica 7
10:50AM 1:20 3:50 6:30 9:00
AMC Century City 15
11:30AM 2:05 5:50 7:10 10:20
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

Now if we want to go back to the main prompt and look at our other browsing options, we can type ‘home’ and then ‘help’ to see a list of the available commands:

The following commands are available:
movies lists movies with nearby showtimes
movie lists the nearby showtimes of a particular movie
genres lists the genres of movies playing nearby
genre lists the nearby showtimes of a particular genre
theatres lists the theatres with showtimes nearby
theatre lists the showtimes of movies at a particular theatre
home returns to the home prompt where all commands are available
exit quits the program
What would you like to do? (type ‘help’ for a list of commands or ‘exit’ to quit)

Movie

So let’s try out the movie command. This one is a good choice if you already have a movie in mind that you want to see. After typing the ‘movie’ command and pressing ‘return’, you should see the following prompt:

Which movie would you like to see? Enter the title here:

Let’s say we want to see The Nice Guys. We type in ‘nice guys’ and press ‘return’ and we’ll get the following response:

Which movie would you like to see? Enter the title here: nice guys
1. The Nice Guys
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

This will gives us a list of all of the movies that have ‘nice guys’ in their title. In this case, there’s only one, so we can type in ‘1’ and hit return and we’ll see the following response:

The Nice Guys is playing at:
Cinemark Playa Vista and XD
11:20AM 2:10 5:05 8:00 10:50
Cinemark 18 & XD
11:10AM 2:05 5:00 7:55 10:50
ArcLight Culver City
10:50AM 1:15 3:40 6:05 8:30 9:55 11:50
The Landmark
11:30AM 2:10 4:50 7:30 10:05
AMC Broadway 4
1:50 5:00 7:45 10:30
AMC Santa Monica 7
10:30AM 1:15 4:00 6:45 9:30
AMC Century City 15
10:15AM 1:10 4:10 7:05 9:55
iPic Theaters Westwood
11:45AM 3:15 6:45 9:45
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

You’ll notice again from the last line that we still have access to the list of movies that matched our search. Since we only found one movie matching our search, this isn’t too useful, but what if we had searched for ‘alice’? In that case, we would have had two results (one for the regular version and one for the 3D) and we could use the interface to easily compare showtimes.

Genres

All right, let’s say we’re not sure what we want to see but we’d like to look through our options by genre. Type in ‘home’ to return to the main prompt and then ‘genres.’ You’ll see the following response:

1. Comedy
2. Adventure
3. Animated
4. Children
5. Action
6. Fantasy
7. Science fiction
8. Romantic comedy
9. Romance
10. Drama
11. Music
12. Mystery
13. Thriller
14. Documentary
15. Musical comedy
16. Comedy drama
17. Biography
18. Historical drama
19. Crime drama
Choose a genre (by number) to list movies playing nearby:

Okay, I’m in an adventurous mood, so let’s type 2!

The following movies of the Adventure genre are playing nearby:
1. The Angry Birds Movie
2. Teenage Mutant Ninja Turtles: Out of the Shadows
3. X-Men: Apocalypse
4. The Angry Birds Movie 3D
5. Teenage Mutant Ninja Turtles: Out of the Shadows 3D
6. X-Men: Apocalypse 3D
7. Captain America: Civil War
8. Alice Through the Looking Glass
9. Alice Through the Looking Glass 3D
10. The Jungle Book
11. The Jungle Book 3D
12. Captain America: Civil War 3D
13. Passage to Mars
14. Teenage Mutant Ninja Turtles: Out of the Shadows — An IMAX 3D Experience
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

Okay, I really want to see Captain America: Civil War, so let’s check out the showtimes by entering ‘7’:

Captain America: Civil War is playing at:
AMC Dine-in Theatres Marina 6
11:00AM 2:25 6:20 9:40
Cinemark 18 & XD
12:30PM 4:00 7:25 10:50
The Landmark
10:00AM 1:10 4:20 7:30 10:35
AMC Broadway 4
11:20AM 2:40 6:00 9:20
AMC Santa Monica 7
12:20PM 7:00 10:20
AMC Century City 15
12:00PM 3:25 6:50 10:15
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

Genre

Okay, so let’s say we’d like to search for movies of a specific genre. In the mood for a thriller? Type ‘home’ + enter + ‘genre’ + enter + ‘thriller’ + enter. You’ll see the following output in your terminal:

What would you like to do? (type ‘help’ for a list of commands or ‘exit’ to quit)
genre
Which genre of movie would you like to watch?
thriller
1. Money Monster
2. The Fallen Idol
3. Approaching the Unknown
4. A Bigger Splash
5. The Wailing
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

Theatres

So I like this one because it’s actually a lot like we used to look at showtimes in the newspaper, except without all of the turning pages and hunting for the ones in our area. If you type in theatres, you’ll see a list of all of the theatres near 90066 that had showtimes on June 4th, 2016:

theatres
1. AMC Marina Marketplace 6
2. Cinemark 18 & XD
3. ArcLight Santa Monica
4. AMC Century City 15
5. AMC Dine-in Theatres Marina 6
6. Cinemark Playa Vista and XD
7. ArcLight Culver City
8. AMC Broadway 4
9. AMC Santa Monica 7
10. The Landmark
11. iPic Theaters Westwood
12. Regency Village — Westwood Village
13. Laemmle Monica Film Center
14. Regency Bruin — Westwood Village
15. Nuart Theatre
16. Laemmle’s Royal Theatre
17. Regent Theatre
18. American Cinematheque at the Aero Theatre
Choose a theatre (by number) to list its movies and showtimes:

Okay, so I’m in the mood to sit in those cushy seats and have some food delivered to me, so let’s pick the dine-in theatre, number 5.

The following movies are playing at AMC Dine-in Theatres Marina 6
1. Teenage Mutant Ninja Turtles: Out of the Shadows
10:45AM 1:50 5:00 8:00 11:00
2. X-Men: Apocalypse
12:00PM 3:30 7:00 10:40
3. Me Before You
11:45AM 3:00 6:00 9:00
4. Captain America: Civil War
11:00AM 2:25 6:20 9:40
5. Popstar: Never Stop Never Stopping
12:20PM 2:45 5:30 8:30 11:15
6. Neighbors 2: Sorority Rising
1:15 4:00 7:30 10:05
If you see a movie you like here but can’t make it:
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

So if we get some inspiration, and see a movie we really want to see but we can’t make the showtime listed, we can choose the number of the movie and it will show us showtimes at other nearby theatres for the same movie. Let’s say I really want to go to Captain America: Civil War, but I can’t make the 6:20 showing. Let’s type in ‘4’ to see where else it’s playing:

Captain America: Civil War is playing at:
AMC Dine-in Theatres Marina 6
11:00AM 2:25 6:20 9:40
Cinemark 18 & XD
12:30PM 4:00 7:25 10:50
The Landmark
10:00AM 1:10 4:20 7:30 10:35
AMC Broadway 4
11:20AM 2:40 6:00 9:20
AMC Santa Monica 7
12:20PM 7:00 10:20
AMC Century City 15
12:00PM 3:25 6:50 10:15
Choose a movie (by number) to list nearby showtimes (type ‘home’ to go back to main prompt):

Ah, perfect! I love that Cinemark! I’ll have just enough time to make that 7:25 showing.

Theatre

The ‘theatre’ command works very similarly to the ‘movie’ and ‘genre’ commands, searching for theatres that match the name you enter.

What’s Next?

I hope you’ve enjoyed reading about my CLI project. In the next post I’ll be discussing the development process of the gem.