AMC Calendar
- 6 Devlogs
- 9 Total hours
A web scraper-based calendar for AMC Theatres' movie showtimes because I hate the existing UI.
A web scraper-based calendar for AMC Theatres' movie showtimes because I hate the existing UI.
A quick recap of what my project structure will be like, and what GraphQL does, since I don’t think I stated that too clearly…
This is a web scraper that gets movie showtimes over different days from https://amctheatres.com/ and renders them as a calendar. But before you can even get the showtimes, you need the theater to get showtimes from (duh). Thankfully, I don’t have to rebuild this from scratch since I found AMC’s graphQL endpoint and their query for fetching theater locations by search term. (If I didn’t find this I would have likely given up on the project.)
Since the query is already pretty much built for me, I can recreate a theater lookup modal, similar to AMC’s, so the user can choose a nearby theater. Using the theater’s backend information returned in the query,
I can then construct a URL for that theater’s showtimes page, then scrape it.
Currently I’m just making the backend, I’ll move to the UI after I’m finished with making the backend components.
So I decided to make the query handling process object-oriented because I didn’t want a bunch of variables holding long strings laying around. Before I explain how the query handler works, I need to explain how the query itself works (I’ll make this quick I promise).
It basically takes a search query (search term) and looks up matching locations. It returns a list of locations (which can be cities or theaters), the length of which is indicated by a resultCount parameter, with each location also returning a list of theaters around it. The search query and result count are given in a separate variables json. The query structure basically looks like this (simplified version):
query QueryName($query: String, $resultCount: Int = 10) {
locations(query: $query, first: $resultCount) {
[here you put in attributes you want returned. ex:]
title
latitude
longitude
theatres { [this is you requesting each location's theatres and their info]
[here is where you put the THEATRES' attributes you want. ex:]
name
theatreId
city
attributes(type: FILTERS, first: 4) { [and this is if you want the list of theatres' features, like available formats, type of seating, etc.]
name [just asking for the attributes' names]
}
}
}
}
As you can see, all of this is incredibly painful. So I made a class that will take lists of attributes you want (location_fields, theatre_fields, attributes_fields) and construct a query, also with a method to send a request with a search term. All of this is shown in the video.
Now it’s time to build the url constructor and web scraper 😩 wish me luck guys
after snooping around in the “network” tab of Inspect I found AMC’s graphQL endpoint. after a bit of pain and not knowing how graphQL works, I finally was able to reproduce the request and get it to give me output. this is so that I can hopefully recreate AMC’s “select a theatre” UI from scratch, instead of having the user put in their theatre.
help
I looked a bit into the amctheatres.com’s request URLs and described their basic structure
I set up Poetry for python package and env management (including Jupyter notebooks) and started experimenting with fetching AMC’s showtime pages. Here’s what I found:
Wrote out a development plan for my project with all the packages I will need. phew, this is gonna be a long ride.