node-csfd-api 3.0.0-next.1 → 3.0.0-next.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.
@@ -37,13 +37,24 @@ const getOrigins = (el) => {
37
37
  };
38
38
  exports.getOrigins = getOrigins;
39
39
  const parsePeople = (el, type) => {
40
- const people = el.querySelectorAll(`.article-content .${type} a`);
41
- return people.map((person) => {
42
- return {
43
- id: (0, global_helper_1.parseIdFromUrl)(person.attributes.href),
44
- name: person.innerText.trim(),
45
- url: `https://www.csfd.cz${person.attributes.href}`
46
- };
47
- });
40
+ let who;
41
+ if (type === 'directors')
42
+ who = 'Režie:';
43
+ if (type === 'actors')
44
+ who = 'Hrají:';
45
+ const peopleNode = Array.from(el && el.querySelectorAll('.article-content p')).find((el) => el.textContent.includes(who));
46
+ if (peopleNode) {
47
+ const people = Array.from(peopleNode.querySelectorAll('a'));
48
+ return people.map((person) => {
49
+ return {
50
+ id: (0, global_helper_1.parseIdFromUrl)(person.attributes.href),
51
+ name: person.innerText.trim(),
52
+ url: `https://www.csfd.cz${person.attributes.href}`
53
+ };
54
+ });
55
+ }
56
+ else {
57
+ return [];
58
+ }
48
59
  };
49
60
  exports.parsePeople = parsePeople;
@@ -42,7 +42,7 @@ class SearchScraper {
42
42
  poster: (0, search_helper_1.getPoster)(m),
43
43
  origins: (0, search_helper_1.getOrigins)(m),
44
44
  creators: {
45
- directors: (0, search_helper_1.parsePeople)(m, 'director'),
45
+ directors: (0, search_helper_1.parsePeople)(m, 'directors'),
46
46
  actors: (0, search_helper_1.parsePeople)(m, 'actors')
47
47
  }
48
48
  };
@@ -27,12 +27,23 @@ export const getOrigins = (el) => {
27
27
  return originsAll === null || originsAll === void 0 ? void 0 : originsAll.split('/').map((country) => country.trim());
28
28
  };
29
29
  export const parsePeople = (el, type) => {
30
- const people = el.querySelectorAll(`.article-content .${type} a`);
31
- return people.map((person) => {
32
- return {
33
- id: parseIdFromUrl(person.attributes.href),
34
- name: person.innerText.trim(),
35
- url: `https://www.csfd.cz${person.attributes.href}`
36
- };
37
- });
30
+ let who;
31
+ if (type === 'directors')
32
+ who = 'Režie:';
33
+ if (type === 'actors')
34
+ who = 'Hrají:';
35
+ const peopleNode = Array.from(el && el.querySelectorAll('.article-content p')).find((el) => el.textContent.includes(who));
36
+ if (peopleNode) {
37
+ const people = Array.from(peopleNode.querySelectorAll('a'));
38
+ return people.map((person) => {
39
+ return {
40
+ id: parseIdFromUrl(person.attributes.href),
41
+ name: person.innerText.trim(),
42
+ url: `https://www.csfd.cz${person.attributes.href}`
43
+ };
44
+ });
45
+ }
46
+ else {
47
+ return [];
48
+ }
38
49
  };
@@ -39,7 +39,7 @@ export class SearchScraper {
39
39
  poster: getPoster(m),
40
40
  origins: getOrigins(m),
41
41
  creators: {
42
- directors: parsePeople(m, 'director'),
42
+ directors: parsePeople(m, 'directors'),
43
43
  actors: parsePeople(m, 'actors')
44
44
  }
45
45
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "3.0.0-next.1",
3
+ "version": "3.0.0-next.2",
4
4
  "description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
5
5
  "main": "./cjs/index.js",
6
6
  "author": "BART! <bart@bartweb.cz>",
@@ -24,8 +24,7 @@
24
24
  "release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
25
25
  },
26
26
  "dependencies": {
27
- "cross-fetch": "^3.1.5",
28
- "node-html-parser": "^6.1.1"
27
+ "node-html-parser": "^6.1.4"
29
28
  },
30
29
  "repository": {
31
30
  "url": "git+https://github.com/bartholomej/node-csfd-api.git",
@@ -3,15 +3,15 @@ import { CSFDCreatorScreening } from '../interfaces/creator.interface';
3
3
  import { CSFDColorRating } from '../interfaces/global';
4
4
  export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
5
5
  export declare const getId: (url: string) => number;
6
- export declare const getName: (el: HTMLElement) => string;
7
- export declare const getBirthdayInfo: (el: HTMLElement) => {
6
+ export declare const getName: (el: HTMLElement | null) => string;
7
+ export declare const getBirthdayInfo: (el: HTMLElement | null) => {
8
8
  birthday: string;
9
9
  age: number;
10
10
  birthPlace: string;
11
11
  };
12
- export declare const getBio: (el: HTMLElement) => string;
13
- export declare const getPhoto: (el: HTMLElement) => string;
12
+ export declare const getBio: (el: HTMLElement | null) => string;
13
+ export declare const getPhoto: (el: HTMLElement | null) => string;
14
14
  export declare const parseBirthday: (text: string) => any;
15
15
  export declare const parseAge: (text: string) => any;
16
16
  export declare const parseBirthPlace: (text: string) => any;
17
- export declare const getFilms: (el: HTMLElement) => CSFDCreatorScreening[];
17
+ export declare const getFilms: (el: HTMLElement | null) => CSFDCreatorScreening[];
@@ -11,14 +11,14 @@ export declare const getRatingCount: (el: HTMLElement) => number;
11
11
  export declare const getYear: (el: string) => number;
12
12
  export declare const getDuration: (jsonLdRaw: string, el: HTMLElement) => number;
13
13
  export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
14
- export declare const getPoster: (el: HTMLElement) => string;
15
- export declare const getRandomPhoto: (el: HTMLElement) => string;
16
- export declare const getTrivia: (el: HTMLElement) => string[];
14
+ export declare const getPoster: (el: HTMLElement | null) => string;
15
+ export declare const getRandomPhoto: (el: HTMLElement | null) => string;
16
+ export declare const getTrivia: (el: HTMLElement | null) => string[];
17
17
  export declare const getDescriptions: (el: HTMLElement) => string[];
18
18
  export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
19
19
  export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
20
20
  export declare const getType: (el: HTMLElement) => string;
21
- export declare const getVods: (el: HTMLElement) => CSFDVod[];
21
+ export declare const getVods: (el: HTMLElement | null) => CSFDVod[];
22
22
  export declare const getBoxContent: (el: HTMLElement, box: string) => HTMLElement;
23
23
  export declare const getBoxMovies: (el: HTMLElement, boxName: CSFDBoxContent) => CSFDMovieListItem[];
24
24
  export declare const getPremieres: (el: HTMLElement) => CSFDPremiere[];
@@ -8,4 +8,4 @@ export declare const getUrl: (el: HTMLElement) => string;
8
8
  export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
9
9
  export declare const getPoster: (el: HTMLElement) => string;
10
10
  export declare const getOrigins: (el: HTMLElement) => string[];
11
- export declare const parsePeople: (el: HTMLElement, type: 'director' | 'actors') => CSFDCreator[];
11
+ export declare const parsePeople: (el: HTMLElement, type: 'directors' | 'actors') => CSFDCreator[];
@@ -9,4 +9,4 @@ export interface CSFDCreator {
9
9
  bio: string;
10
10
  films: CSFDCreatorScreening[];
11
11
  }
12
- export declare type CSFDCreatorScreening = Omit<CSFDScreening, 'url' | 'type'>;
12
+ export type CSFDCreatorScreening = Omit<CSFDScreening, 'url' | 'type'>;
@@ -17,6 +17,6 @@ export interface CSFDScreening {
17
17
  */
18
18
  colorRating: CSFDColorRating;
19
19
  }
20
- export declare type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown';
21
- export declare type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5;
22
- export declare type CSFDFilmTypes = 'film' | 'TV film' | 'pořad' | 'seriál' | 'divadelní záznam' | 'koncert' | 'série' | 'studentský film' | 'amatérský film' | 'hudební videoklip' | 'epizoda';
20
+ export type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown';
21
+ export type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5;
22
+ export type CSFDFilmTypes = 'film' | 'TV film' | 'pořad' | 'seriál' | 'divadelní záznam' | 'koncert' | 'série' | 'studentský film' | 'amatérský film' | 'hudební videoklip' | 'epizoda';
@@ -17,8 +17,9 @@ 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
21
  export interface CSFDVod {
21
- title: 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'iTunes' | 'Aerovod' | 'Edisonline' | 'o2tv' | 'SledovaniTV' | 'Starmax' | 'DAFilms' | 'FILMY ČESKY A ZADARMO' | 'Youtube Česká filmová klasika' | 'VAPET' | 'VOREL FILM' | 'ivysilani' | 'Google Play' | 'Voyo' | string;
22
+ title: CSFDVodService;
22
23
  url: string;
23
24
  }
24
25
  export interface CSFDCreators {
@@ -54,12 +55,12 @@ export interface CSFDMovieListItem {
54
55
  title: string;
55
56
  url: string;
56
57
  }
57
- export declare type CSFDGenres = 'Akční' | 'Animovaný' | 'Dobrodružný' | 'Dokumentární' | 'Drama' | 'Experimentální' | 'Fantasy' | 'Film-Noir' | 'Historický' | 'Horor' | 'Hudební' | 'IMAX' | 'Katastrofický' | 'Komedie' | 'Krátkometrážní' | 'Krimi' | 'Loutkový' | 'Muzikál' | 'Mysteriózní' | 'Naučný' | 'Podobenství' | 'Poetický' | 'Pohádka' | 'Povídkový' | 'Psychologický' | 'Publicistický' | 'Reality-TV' | 'Road movie' | 'Rodinný' | 'Romantický' | 'Sci-Fi' | 'Soutěžní' | 'Sportovní' | 'Stand-up' | 'Talk-show' | 'Taneční' | 'Telenovela' | 'Thriller' | 'Válečný' | 'Western' | 'Zábavný' | 'Životopisný';
58
- export declare type CSFDCreatorGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Produkce' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
58
+ export type CSFDGenres = 'Akční' | 'Animovaný' | 'Dobrodružný' | 'Dokumentární' | 'Drama' | 'Experimentální' | 'Fantasy' | 'Film-Noir' | 'Historický' | 'Horor' | 'Hudební' | 'IMAX' | 'Katastrofický' | 'Komedie' | 'Krátkometrážní' | 'Krimi' | 'Loutkový' | 'Muzikál' | 'Mysteriózní' | 'Naučný' | 'Podobenství' | 'Poetický' | 'Pohádka' | 'Povídkový' | 'Psychologický' | 'Publicistický' | 'Reality-TV' | 'Road movie' | 'Rodinný' | 'Romantický' | 'Sci-Fi' | 'Soutěžní' | 'Sportovní' | 'Stand-up' | 'Talk-show' | 'Taneční' | 'Telenovela' | 'Thriller' | 'Válečný' | 'Western' | 'Zábavný' | 'Životopisný';
59
+ export type CSFDCreatorGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Produkce' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
59
60
  export interface CSFDPremiere {
60
61
  country: string;
61
62
  format: string;
62
63
  date: string;
63
64
  company: string;
64
65
  }
65
- export declare type CSFDBoxContent = 'Související' | 'Podobné';
66
+ export type CSFDBoxContent = 'Související' | 'Podobné';
@@ -15,4 +15,4 @@ export interface CSFDUserRatingConfig {
15
15
  */
16
16
  allPagesDelay?: number;
17
17
  }
18
- export declare type Colors = 'lightgrey' | 'blue' | 'red' | 'grey';
18
+ export type Colors = 'lightgrey' | 'blue' | 'red' | 'grey';