UNPKG

node-csfd-api-racintom

Version:

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

33 lines (32 loc) 1.58 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreatorScraper = void 0; const node_html_parser_1 = require("node-html-parser"); const fetchers_1 = require("../fetchers"); const creator_helper_1 = require("../helpers/creator.helper"); const vars_1 = require("../vars"); class CreatorScraper { async creator(creatorId) { const url = (0, vars_1.creatorUrl)(+creatorId); const response = await (0, fetchers_1.fetchPage)(url); const creatorHtml = (0, node_html_parser_1.parse)(response); const asideNode = creatorHtml.querySelector('.creator-about'); const filmsNode = creatorHtml.querySelector('.creator-filmography'); this.buildCreator(+creatorId, asideNode, filmsNode); return this.person; } buildCreator(id, asideEl, filmsNode) { var _a, _b, _c; this.person = { id, name: (0, creator_helper_1.getName)(asideEl), birthday: (_a = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday, birthplace: (_b = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace, photo: (0, creator_helper_1.getPhoto)(asideEl), age: ((_c = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null, bio: (0, creator_helper_1.getBio)(asideEl), films: (0, creator_helper_1.getFilms)(filmsNode) }; } } exports.CreatorScraper = CreatorScraper;