node-csfd-api 2.14.0 → 2.14.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
- import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from 'interfaces/cinema.interface';
2
1
  import { HTMLElement } from 'node-html-parser';
3
2
  import { CSFDColorRating } from '../interfaces/global';
3
+ import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from './../interfaces/cinema.interface';
4
4
  export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
5
5
  export declare const getCinemaId: (el: HTMLElement | null) => number;
6
6
  export declare const getId: (url: string) => number | null;
@@ -1,14 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getUserUrl = exports.getAvatar = exports.getUserRealName = exports.getUser = void 0;
4
+ const node_html_parser_1 = require("node-html-parser");
4
5
  const global_helper_1 = require("./global.helper");
5
6
  const getUser = (el) => {
6
7
  return el.querySelector('.user-title-name').text;
7
8
  };
8
9
  exports.getUser = getUser;
9
10
  const getUserRealName = (el) => {
10
- var _a;
11
- return ((_a = el.querySelector('.user-real-name')) === null || _a === void 0 ? void 0 : _a.text.trim()) || null;
11
+ const p = el.querySelector('.article-content p');
12
+ if (!p)
13
+ return null;
14
+ const textNodes = p.childNodes.filter(n => n.nodeType === node_html_parser_1.NodeType.TEXT_NODE && n.rawText.trim() !== '');
15
+ const name = textNodes.length ? textNodes[0].rawText.trim() : null;
16
+ return name;
12
17
  };
13
18
  exports.getUserRealName = getUserRealName;
14
19
  const getAvatar = (el) => {
package/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CSFDCinema, CSFDCinemaPeriod } from 'interfaces/cinema.interface';
1
+ import { CSFDCinema, CSFDCinemaPeriod } from './interfaces/cinema.interface';
2
2
  import { CSFDCreator } from './interfaces/creator.interface';
3
3
  import { CSFDMovie } from './interfaces/movie.interface';
4
4
  import { CSFDSearch } from './interfaces/search.interface';
@@ -17,7 +17,7 @@ export interface CSFDMovie extends CSFDScreening {
17
17
  related: CSFDMovieListItem[];
18
18
  similar: CSFDMovieListItem[];
19
19
  }
20
- export type CSFDVodService = 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'iTunes' | 'KVIFF.TV' | 'Edisonline' | 'o2tv' | 'SledovaniTV' | 'Starmax' | 'DAFilms' | 'FILMY ČESKY A ZADARMO' | 'Youtube Česká filmová klasika' | 'VAPET' | 'VOREL FILM' | 'ivysilani' | 'Google Play' | 'Voyo' | 'DVD';
20
+ export type CSFDVodService = 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'iTunes' | 'KVIFF.TV' | 'Edisonline' | 'o2tv' | 'SledovaniTV' | 'Starmax' | 'DAFilms' | 'FILMY ČESKY A ZADARMO' | 'Youtube Česká filmová klasika' | 'VAPET' | 'VOREL FILM' | 'ivysilani' | 'Google Play' | 'Voyo' | 'YouTube Movies' | 'prima+' | 'Lepší.TV' | 'Blu-ray' | 'DVD';
21
21
  export interface CSFDVod {
22
22
  title: CSFDVodService;
23
23
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "2.14.0",
3
+ "version": "2.14.2",
4
4
  "description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
5
5
  "main": "./index.js",
6
6
  "author": "BART! <bart@bartweb.cz>",
@@ -7,7 +7,11 @@ const creator_helper_1 = require("../helpers/creator.helper");
7
7
  const vars_1 = require("../vars");
8
8
  class CreatorScraper {
9
9
  async creator(creatorId) {
10
- const url = (0, vars_1.creatorUrl)(+creatorId);
10
+ const id = Number(creatorId);
11
+ if (isNaN(id)) {
12
+ throw new Error('node-csfd-api: creatorId must be a valid number');
13
+ }
14
+ const url = (0, vars_1.creatorUrl)(id);
11
15
  const response = await (0, fetchers_1.fetchPage)(url);
12
16
  const creatorHtml = (0, node_html_parser_1.parse)(response);
13
17
  const asideNode = creatorHtml.querySelector('.creator-about');
@@ -7,7 +7,11 @@ const movie_helper_1 = require("../helpers/movie.helper");
7
7
  const vars_1 = require("../vars");
8
8
  class MovieScraper {
9
9
  async movie(movieId) {
10
- const url = (0, vars_1.movieUrl)(+movieId);
10
+ const id = Number(movieId);
11
+ if (isNaN(id)) {
12
+ throw new Error('node-csfd-api: movieId must be a valid number');
13
+ }
14
+ const url = (0, vars_1.movieUrl)(id);
11
15
  const response = await (0, fetchers_1.fetchPage)(url);
12
16
  const movieHtml = (0, node_html_parser_1.parse)(response);
13
17
  const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');
package/vars.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { CSFDCinemaPeriod } from 'interfaces/cinema.interface';
1
+ import { CSFDCinemaPeriod } from './interfaces/cinema.interface';
2
2
  export declare const userRatingsUrl: (user: string | number, page?: number) => string;
3
3
  export declare const movieUrl: (movie: number) => string;
4
4
  export declare const creatorUrl: (creator: number | string) => string;