node-csfd-api
Version:
ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)
29 lines (27 loc) • 1.49 kB
JavaScript
//#region src/vars.ts
const LANGUAGE_DOMAIN_MAP = {
cs: "https://www.csfd.cz",
en: "https://www.csfd.cz/en",
sk: "https://www.csfd.cz/sk"
};
let BASE_URL = LANGUAGE_DOMAIN_MAP.cs;
const getUrlByLanguage = (language) => {
if (language && language in LANGUAGE_DOMAIN_MAP) return LANGUAGE_DOMAIN_MAP[language];
return BASE_URL;
};
const userUrl = (user, options) => `${getUrlByLanguage(options?.language)}/uzivatel/${encodeURIComponent(user)}`;
const userRatingsUrl = (user, page, options = {}) => `${userUrl(user, options)}/hodnoceni/${page ? "?page=" + page : ""}`;
const userReviewsUrl = (user, page, options = {}) => `${userUrl(user, options)}/recenze/${page ? "?page=" + page : ""}`;
const movieUrl = (movie, options) => `${getUrlByLanguage(options?.language)}/film/${encodeURIComponent(movie)}/prehled/`;
const creatorUrl = (creator, options) => `${getUrlByLanguage(options?.language)}/tvurce/${encodeURIComponent(creator)}`;
const cinemasUrl = (district, period, options) => `${getUrlByLanguage(options?.language)}/kino/?period=${period}&district=${district}`;
const searchUrl = (text, options) => `${getUrlByLanguage(options?.language)}/hledat/?q=${encodeURIComponent(text)}`;
//#endregion
exports.cinemasUrl = cinemasUrl;
exports.creatorUrl = creatorUrl;
exports.getUrlByLanguage = getUrlByLanguage;
exports.movieUrl = movieUrl;
exports.searchUrl = searchUrl;
exports.userRatingsUrl = userRatingsUrl;
exports.userReviewsUrl = userReviewsUrl;
//# sourceMappingURL=vars.js.map