Advertisement
szdc

cinema capacity

May 28th, 2021
1,441
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (() => {
  2.   fetch("https://www.hoyts.com.au/api/movie/tiles?cinemaIds=SHOWGR&startTime=2021-05-28", {
  3.   "headers": {
  4.     "accept": "application/json, text/plain, */*",
  5.     "accept-language": "en-GB,en;q=0.9",
  6.     "cache-control": "no-cache",
  7.     "pragma": "no-cache",
  8.     "sec-ch-ua": "\" Not A;Brand\";v=\"99\", \"Chromium\";v=\"90\", \"Google Chrome\";v=\"90\"",
  9.     "sec-ch-ua-mobile": "?0",
  10.     "sec-fetch-dest": "empty",
  11.     "sec-fetch-mode": "cors",
  12.     "sec-fetch-site": "same-origin",
  13.   },
  14.   "referrer": "https://www.hoyts.com.au/movies?selectedDate=2021-05-28&view=list",
  15.   "referrerPolicy": "strict-origin-when-cross-origin",
  16.   "body": null,
  17.   "method": "GET",
  18.   "mode": "cors",
  19.   "credentials": "omit"
  20.   })
  21.     .then(res => res.json())
  22.     .then(list => list.filter(item => item.componentType === 'MovieTileComponent'))
  23.     .then(list => list.flatMap(item => item.sessions))
  24.     .then(list => list.map(session => ({ cinemaId: session.screenName, capacity: session.sessionCapacity.availableSeats })))
  25.     .then(sessions => sessions.reduce((cinemaMap, session) => {
  26.       if (!cinemaMap[session.cinemaId] || cinemaMap[session.cinemaId] < session.capacity) {
  27.         cinemaMap[session.cinemaId] = session.capacity;
  28.       }
  29.       return cinemaMap;
  30.     }, {}))
  31.     .then(console.log);
  32. })()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement