UNPKG

node-csfd-api

Version:

ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)

41 lines (39 loc) 1.7 kB
const require_global_helper = require('./global.helper.js'); //#region src/helpers/user-ratings.helper.ts const getUserRatingId = (el) => { const url = el.querySelector("td.name .film-title-name").attributes.href; return require_global_helper.parseIdFromUrl(url); }; const getUserRating = (el) => { const ratingText = el.querySelector("td.star-rating-only .stars").classNames.split(" ").pop(); return ratingText.includes("stars-") ? +ratingText.split("-").pop() : 0; }; const getUserRatingType = (el) => { const typeText = el.querySelectorAll("td.name .film-title-info .info"); return typeText.length > 1 ? typeText[1].text.slice(1, -1) : "film"; }; const getUserRatingTitle = (el) => { return el.querySelector("td.name .film-title-name").text; }; const getUserRatingYear = (el) => { return +el.querySelectorAll("td.name .film-title-info .info")[0]?.text.slice(1, -1) || null; }; const getUserRatingColorRating = (el) => { return require_global_helper.parseColor(el.querySelector("td.name .icon").classNames.split(" ").pop()); }; const getUserRatingDate = (el) => { return el.querySelector("td.date-only").text.trim(); }; const getUserRatingUrl = (el) => { return `https://www.csfd.cz${el.querySelector("td.name .film-title-name").attributes.href}`; }; //#endregion exports.getUserRating = getUserRating; exports.getUserRatingColorRating = getUserRatingColorRating; exports.getUserRatingDate = getUserRatingDate; exports.getUserRatingId = getUserRatingId; exports.getUserRatingTitle = getUserRatingTitle; exports.getUserRatingType = getUserRatingType; exports.getUserRatingUrl = getUserRatingUrl; exports.getUserRatingYear = getUserRatingYear; //# sourceMappingURL=user-ratings.helper.js.map