UNPKG

kinoklub-api

Version:

Support library for KinoKlub

35 lines (34 loc) 1.48 kB
import { KinoklubHallLucernaChoices, KinoklubHallOkoChoices, KinoklubHallSvetozorChoices } from "./interfaces/global.js"; //#region src/vars.ts const programUrl = (lang, cinemas, options = {}) => { const cinemaArr = cinemas && cinemas.length > 0 ? cinemas : [ 1, 2, 3 ]; const cinemaParams = cinemaArr.map((c) => `cinema%5B%5D=${c}`).join("&"); const isAllDays = options.allDays; let halls = []; for (const cinema of cinemaArr) switch (cinema) { case 3: halls.push(...Object.values(KinoklubHallSvetozorChoices).filter((value) => typeof value === "number")); break; case 9: halls.push(...Object.values(KinoklubHallLucernaChoices).filter((value) => typeof value === "number")); break; case 2: halls.push(...Object.values(KinoklubHallOkoChoices).filter((value) => typeof value === "number")); break; default: break; } halls = Array.from(new Set(halls)).sort((a, b) => a - b); const hallParams = halls.map((h) => `hall%5B%5D=${h}`).join("&"); const url = `https://www.kinoaero.cz/api_program?${cinemaParams}${hallParams ? "&" + hallParams : ""}&ef=0&m=&wp=0&arch=0&ao=0&d=${isAllDays ? "2" : "0"}&_locale=${lang}`; console.log(url); return url; }; const movieUrl = (movieId, lang) => `https://www.kinoaero.cz/api_film/?pr=${movieId}&_locale=${lang}`; const ticketsRedirectUrl = "https://kinoklub-tickets-redirect.bart-acf.workers.dev"; //#endregion export { movieUrl, programUrl, ticketsRedirectUrl }; //# sourceMappingURL=vars.js.map