UNPKG

kinoklub-api

Version:

Support library for KinoKlub

51 lines (50 loc) 1.87 kB
import { fetchPage } from "../fetchers/index.js"; import { getTicketParams } from "../helpers/global.helper.js"; import { getButton, getCurrentProjection, getDescription, getDirector, getImage, getInfo, getLanguage, getProjections, getSubtitles, getTags, getTitle, getTitleOriginal, getYoutube, removeIndexesFromArray } from "../helpers/movie.helper.js"; import { movieUrl, ticketsRedirectUrl } from "../vars.js"; import { parse } from "node-html-parser"; //#region src/services/movie.service.ts var MovieScraper = class { async movie(screeningId, lang) { const html = parse(await fetchPage(movieUrl(screeningId, lang))); return this.buildMovie(screeningId, html); } buildMovie(id, el) { const infoRaw = getInfo(el); const { text: titleOriginal, index: titleOriginalIndex } = getTitleOriginal(infoRaw); const { text: director, index: directorIndex } = getDirector(infoRaw); const { text: subtitles, index: subtitlesIndex } = getSubtitles(infoRaw); const { text: language, index: languageIndex } = getLanguage(infoRaw); const info = removeIndexesFromArray(infoRaw, [ titleOriginalIndex, directorIndex, subtitlesIndex, languageIndex ]); const ticketParams = getTicketParams(el); const queryParams = new URLSearchParams(ticketParams).toString(); return { id, title: getTitle(el), titleOriginal, ticketUrl: queryParams ? ticketsRedirectUrl + "?" + queryParams : null, infoRaw, info, description: getDescription(el), director, subtitles, language, tags: getTags(el), csfd: getButton(el, "ČSFD"), imdb: getButton(el, "IMDB"), letterboxd: getButton(el, "Letterboxd"), youtube: getYoutube(el), image: getImage(el), projection: getCurrentProjection(el), projectionsOther: getProjections(el) }; } }; //#endregion export { MovieScraper }; //# sourceMappingURL=movie.service.js.map