Skip to content

Commit

Permalink
Cineworld (#1151)
Browse files Browse the repository at this point in the history
* Cineworld Listings
  • Loading branch information
andrewbolster authored Apr 25, 2024
1 parent c04aa56 commit a1d764d
Show file tree
Hide file tree
Showing 7 changed files with 482 additions and 2 deletions.
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -114,3 +114,8 @@ ENV/

# http_cache
http_cache.sqlite

# JupyterNotebooks
.ipynb_checkpoints/
.virtual_documents/
.juypter
357 changes: 357 additions & 0 deletions notebooks/CineworldCinemaListings.ipynb
Original file line number Diff line number Diff line change
@@ -0,0 +1,357 @@
{
"cells": [
{
"cell_type": "markdown",
"id": "1282777f-6bb2-4e3b-8756-a2c41ef36cf5",
"metadata": {},
"source": [
"# Cineworld Listings\n",
"\n",
"I like Weird movies coming to Imax, I don't like watching newspapers/etc to see Belfast announcing them. \n",
"\n",
"## Basic mode\n",
"\n",
"Yup, turns out cineworld just checks based on user-agent. And overall appears to be even more basic that [what this one looked like](https://github.com/oracal/cineworld)\n",
"\n",
"Easy observations:\n",
"\n",
"* Films are uniquely identified by `id`, which is also persisted in teh rest of the api calls (see `link` attribute)\n",
"* `117` is Belfasts Site code\n",
"* No clue what the 10108 is."
]
},
{
"cell_type": "code",
"execution_count": 92,
"id": "e703ee34-9023-4cda-bd47-fb0a1e37d6a7",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'id': 'ho00011281',\n",
" 'name': 'Ghilli (Re-release) (Tamil)',\n",
" 'length': 164,\n",
" 'posterLink': 'https://regalcdn.azureedge.net/CW/GhilliRereleaseTamil/HO00011281/TV_SmallPosterImage/20240415-120139903.jpg',\n",
" 'videoLink': 'https://youtu.be/4aGEjyn-bPQ?si=CgXZSe1WH5Cc4292',\n",
" 'link': 'https://www.cineworld.co.uk/films/ghilli-re-release-tamil/ho00011281',\n",
" 'weight': 10,\n",
" 'releaseYear': '2024',\n",
" 'attributeIds': ['12a',\n",
" '2d',\n",
" 'action',\n",
" 'drama',\n",
" 'reserved-selected',\n",
" 'subbed']}"
]
},
"execution_count": 92,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"import requests\n",
"from datetime import date\n",
"\n",
"headers = {\n",
" \"User-Agent\":\"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:124.0) Gecko/20100101 Firefox/124.0\",\n",
"}\n",
"\n",
"requests.get(f\"https://www.cineworld.co.uk/uk/data-api-service/v1/quickbook/10108/film-events/in-cinema/117/at-date/{date.today().isoformat()}\", \n",
" headers=headers).json()['body']['films'][0]"
]
},
{
"cell_type": "code",
"execution_count": 93,
"id": "3ba62447-de46-4d81-bf82-3d68724ec9b8",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'Ghilli (Re-release) (Tamil)'"
]
},
"execution_count": 93,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"from datetime import date\n",
"def get_cinema_listing_for(screening_date = None, site_code=117):\n",
" if screening_date is None:\n",
" screening_date = str(date.today())\n",
" elif isinstance(screening_date, date):\n",
" screening_date = str(screening_date)\n",
" else:\n",
" raise ValueError(\"Can only use date-type with screening_date\")\n",
" response = requests.get(f\"https://www.cineworld.co.uk/uk/data-api-service/v1/quickbook/10108/film-events/in-cinema/{site_code}/at-date/{screening_date}\", headers=headers)\n",
" response.raise_for_status()\n",
" return response.json()['body']['films']\n",
" \n",
"listings = get_cinema_listing_for()\n",
"listings[0]['name']"
]
},
{
"cell_type": "code",
"execution_count": 96,
"id": "36cb9b38-bd63-47ba-96e6-8bebd5530071",
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"dict_keys(['id', 'name', 'length', 'posterLink', 'videoLink', 'link', 'weight', 'releaseYear', 'attributeIds', 'date'])"
]
},
"execution_count": 96,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"listings[0].keys()"
]
},
{
"cell_type": "code",
"execution_count": 94,
"id": "44eabb06-0609-431f-86a1-820f00380c54",
"metadata": {},
"outputs": [
{
"data": {
"application/vnd.jupyter.widget-view+json": {
"model_id": "d082902f542a42b2bd60dbaa8c14088f",
"version_major": 2,
"version_minor": 0
},
"text/plain": [
" 0%| | 0/28 [00:00<?, ?it/s]"
]
},
"metadata": {},
"output_type": "display_data"
}
],
"source": [
"import pandas as pd\n",
"from tqdm.auto import tqdm\n",
"\n",
"listings = []\n",
"\n",
"for d in tqdm(pd.date_range('today', freq='D', periods=28)):\n",
" _d = d.date()\n",
" for listing in get_cinema_listing_for(_d):\n",
" listing['date'] = _d\n",
" listings.append(listing) "
]
},
{
"cell_type": "code",
"execution_count": 84,
"id": "639a199b-eed6-42a8-9783-a98d8256e1e4",
"metadata": {},
"outputs": [],
"source": [
"df = pd.DataFrame(listings)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "638408b7-0a70-4e10-b523-facbc69f38ce",
"metadata": {},
"outputs": [],
"source": []
},
{
"cell_type": "code",
"execution_count": 85,
"id": "d8b47fa9-80a6-426a-b3fc-2552be84a35f",
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div>\n",
"<style scoped>\n",
" .dataframe tbody tr th:only-of-type {\n",
" vertical-align: middle;\n",
" }\n",
"\n",
" .dataframe tbody tr th {\n",
" vertical-align: top;\n",
" }\n",
"\n",
" .dataframe thead th {\n",
" text-align: right;\n",
" }\n",
"</style>\n",
"<table border=\"1\" class=\"dataframe\">\n",
" <thead>\n",
" <tr style=\"text-align: right;\">\n",
" <th></th>\n",
" <th>name</th>\n",
" <th>date</th>\n",
" </tr>\n",
" </thead>\n",
" <tbody>\n",
" <tr>\n",
" <th>2</th>\n",
" <td>Civil War</td>\n",
" <td>2024-04-15</td>\n",
" </tr>\n",
" <tr>\n",
" <th>15</th>\n",
" <td>Civil War</td>\n",
" <td>2024-04-16</td>\n",
" </tr>\n",
" <tr>\n",
" <th>27</th>\n",
" <td>Civil War</td>\n",
" <td>2024-04-17</td>\n",
" </tr>\n",
" <tr>\n",
" <th>42</th>\n",
" <td>Civil War</td>\n",
" <td>2024-04-18</td>\n",
" </tr>\n",
" <tr>\n",
" <th>54</th>\n",
" <td>(IMAX) Hunger Games: Ballad Of Songbirds &amp; Snakes</td>\n",
" <td>2024-04-20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>55</th>\n",
" <td>(IMAX) Oppenheimer</td>\n",
" <td>2024-04-20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>56</th>\n",
" <td>(IMAX) Spider-Man: Across The Spider-Verse</td>\n",
" <td>2024-04-20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>57</th>\n",
" <td>(IMAX) The Super Mario Bros. Movie</td>\n",
" <td>2024-04-20</td>\n",
" </tr>\n",
" <tr>\n",
" <th>67</th>\n",
" <td>SPY x FAMILY CODE: White (Subtitled)</td>\n",
" <td>2024-04-27</td>\n",
" </tr>\n",
" <tr>\n",
" <th>70</th>\n",
" <td>SPY x FAMILY CODE: White (Subtitled)</td>\n",
" <td>2024-04-28</td>\n",
" </tr>\n",
" <tr>\n",
" <th>73</th>\n",
" <td>The Fall Guy</td>\n",
" <td>2024-05-02</td>\n",
" </tr>\n",
" <tr>\n",
" <th>75</th>\n",
" <td>The Fall Guy</td>\n",
" <td>2024-05-03</td>\n",
" </tr>\n",
" <tr>\n",
" <th>77</th>\n",
" <td>The Fall Guy</td>\n",
" <td>2024-05-04</td>\n",
" </tr>\n",
" <tr>\n",
" <th>80</th>\n",
" <td>The Fall Guy</td>\n",
" <td>2024-05-05</td>\n",
" </tr>\n",
" <tr>\n",
" <th>81</th>\n",
" <td>The Fall Guy</td>\n",
" <td>2024-05-06</td>\n",
" </tr>\n",
" <tr>\n",
" <th>82</th>\n",
" <td>Kingdom Of The Planet Of The Apes</td>\n",
" <td>2024-05-09</td>\n",
" </tr>\n",
" <tr>\n",
" <th>84</th>\n",
" <td>Kingdom Of The Planet Of The Apes</td>\n",
" <td>2024-05-10</td>\n",
" </tr>\n",
" <tr>\n",
" <th>85</th>\n",
" <td>Kingdom Of The Planet Of The Apes</td>\n",
" <td>2024-05-11</td>\n",
" </tr>\n",
" <tr>\n",
" <th>86</th>\n",
" <td>Kingdom Of The Planet Of The Apes</td>\n",
" <td>2024-05-12</td>\n",
" </tr>\n",
" </tbody>\n",
"</table>\n",
"</div>"
],
"text/plain": [
" name date\n",
"2 Civil War 2024-04-15\n",
"15 Civil War 2024-04-16\n",
"27 Civil War 2024-04-17\n",
"42 Civil War 2024-04-18\n",
"54 (IMAX) Hunger Games: Ballad Of Songbirds & Snakes 2024-04-20\n",
"55 (IMAX) Oppenheimer 2024-04-20\n",
"56 (IMAX) Spider-Man: Across The Spider-Verse 2024-04-20\n",
"57 (IMAX) The Super Mario Bros. Movie 2024-04-20\n",
"67 SPY x FAMILY CODE: White (Subtitled) 2024-04-27\n",
"70 SPY x FAMILY CODE: White (Subtitled) 2024-04-28\n",
"73 The Fall Guy 2024-05-02\n",
"75 The Fall Guy 2024-05-03\n",
"77 The Fall Guy 2024-05-04\n",
"80 The Fall Guy 2024-05-05\n",
"81 The Fall Guy 2024-05-06\n",
"82 Kingdom Of The Planet Of The Apes 2024-05-09\n",
"84 Kingdom Of The Planet Of The Apes 2024-05-10\n",
"85 Kingdom Of The Planet Of The Apes 2024-05-11\n",
"86 Kingdom Of The Planet Of The Apes 2024-05-12"
]
},
"execution_count": 85,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"df[df['attributeIds'].apply(lambda l: 'imax' in l)][['name','date']]"
]
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.11.3"
}
},
"nbformat": 4,
"nbformat_minor": 5
}
21 changes: 20 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit a1d764d

Please sign in to comment.