node-csfd-api
Advanced tools
Comparing version 1.8.3 to 1.9.0
@@ -10,2 +10,3 @@ import { HTMLElement } from 'node-html-parser'; | ||
export declare const getRating: (el: HTMLElement) => number; | ||
export declare const getRatingCount: (el: HTMLElement) => number; | ||
export declare const getYear: (el: HTMLElement) => string | number; | ||
@@ -12,0 +13,0 @@ export declare const getDuration: (el: HTMLElement) => number; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getTitlesOther = exports.getDuration = exports.getYear = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0; | ||
exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getTitlesOther = exports.getDuration = exports.getYear = exports.getRatingCount = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0; | ||
const global_helper_1 = require("./global.helper"); | ||
@@ -15,3 +15,3 @@ const getId = (el) => { | ||
const getGenres = (el) => { | ||
const genresRaw = el.querySelector('.genres').text; | ||
const genresRaw = el.querySelector('.genres').textContent; | ||
return genresRaw.split(' / '); | ||
@@ -21,3 +21,3 @@ }; | ||
const getOrigins = (el) => { | ||
const originsRaw = el.querySelector('.origin').text; | ||
const originsRaw = el.querySelector('.origin').textContent; | ||
const origins = originsRaw.split(',')[0]; | ||
@@ -32,3 +32,3 @@ return origins.split(' / '); | ||
const getRating = (el) => { | ||
const ratingRaw = el.querySelector('.rating-average').text; | ||
const ratingRaw = el.querySelector('.rating-average').textContent; | ||
const rating = +(ratingRaw === null || ratingRaw === void 0 ? void 0 : ratingRaw.replace(/%/g, '').trim()); | ||
@@ -43,2 +43,14 @@ if (Number.isInteger(rating)) { | ||
exports.getRating = getRating; | ||
const getRatingCount = (el) => { | ||
var _a; | ||
const ratingCountRaw = (_a = el.querySelector('.box-rating-container .counter')) === null || _a === void 0 ? void 0 : _a.textContent; | ||
const ratingCount = +(ratingCountRaw === null || ratingCountRaw === void 0 ? void 0 : ratingCountRaw.replace(/[(\s)]/g, '')); | ||
if (Number.isInteger(ratingCount)) { | ||
return ratingCount; | ||
} | ||
else { | ||
return null; | ||
} | ||
}; | ||
exports.getRatingCount = getRatingCount; | ||
const getYear = (el) => { | ||
@@ -69,3 +81,3 @@ return el.querySelector('.origin span').innerText.replace(/[{()}]/g, ''); | ||
const country = el.querySelector('img.flag').attributes.alt; | ||
const title = el.text.trim().split('\n')[0]; | ||
const title = el.textContent.trim().split('\n')[0]; | ||
if (country && title) { | ||
@@ -100,3 +112,3 @@ return { | ||
const plot = (_a = el | ||
.querySelector('.body--plots .plot-preview p')) === null || _a === void 0 ? void 0 : _a.text.trim().replace(/(\r\n|\n|\r|\t)/gm, ''); | ||
.querySelector('.body--plots .plot-preview p')) === null || _a === void 0 ? void 0 : _a.textContent.trim().replace(/(\r\n|\n|\r|\t)/gm, ''); | ||
return plot ? [plot] : []; | ||
@@ -127,3 +139,3 @@ }; | ||
const creators = el.querySelectorAll('.creators h4'); | ||
const element = creators.filter((elem) => elem.text.trim().includes(group))[0]; | ||
const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0]; | ||
if (element === null || element === void 0 ? void 0 : element.parentNode) { | ||
@@ -150,3 +162,3 @@ return (0, exports.parsePeople)(element.parentNode); | ||
return { | ||
title: btn.text.trim(), | ||
title: btn.textContent.trim(), | ||
url: btn.attributes.href | ||
@@ -163,3 +175,3 @@ }; | ||
const headers = el.querySelectorAll('section.box .box-header'); | ||
return (_a = headers.find((header) => header.querySelector('h3').text.trim().includes(box))) === null || _a === void 0 ? void 0 : _a.parentNode; | ||
return (_a = headers.find((header) => header.querySelector('h3').textContent.trim().includes(box))) === null || _a === void 0 ? void 0 : _a.parentNode; | ||
}; | ||
@@ -191,3 +203,3 @@ exports.getBoxContent = getBoxContent; | ||
country: ((_a = premiereNode.querySelector('.flag')) === null || _a === void 0 ? void 0 : _a.attributes.title) || null, | ||
format: premiereNode.querySelector('p').text.trim().split(' od')[0], | ||
format: premiereNode.querySelector('p').textContent.trim().split(' od')[0], | ||
date, | ||
@@ -202,4 +214,4 @@ company: company.join(' ') | ||
const tagsRaw = el.querySelectorAll('.box-content a[href*="/podrobne-vyhledavani/?tag="]'); | ||
return tagsRaw.map((tag) => tag.text); | ||
return tagsRaw.map((tag) => tag.textContent); | ||
}; | ||
exports.getTags = getTags; |
@@ -5,2 +5,3 @@ import { CSFDScreening } from './global'; | ||
poster: string; | ||
ratingCount: number | null; | ||
duration: number | string; | ||
@@ -7,0 +8,0 @@ titlesOther: CSFDTitlesOther[]; |
{ | ||
"name": "node-csfd-api", | ||
"version": "1.8.3", | ||
"version": "1.9.0", | ||
"description": "Simple NPM library for scraping CSFD", | ||
@@ -5,0 +5,0 @@ "main": "./index.js", |
@@ -61,2 +61,3 @@ [![npm version](https://badge.fury.io/js/node-csfd-api.svg)](https://badge.fury.io/js/node-csfd-api) | ||
rating: 73, | ||
ratingCount: 6654, | ||
titlesOther: [ | ||
@@ -63,0 +64,0 @@ { country: 'USA', title: 'Dragged Across Concrete' }, |
@@ -32,2 +32,3 @@ "use strict"; | ||
rating: (0, movie_helper_1.getRating)(asideEl), | ||
ratingCount: (0, movie_helper_1.getRatingCount)(asideEl), | ||
titlesOther: (0, movie_helper_1.getTitlesOther)(el), | ||
@@ -34,0 +35,0 @@ poster: (0, movie_helper_1.getPoster)(el), |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
57453
1041
447