node-csfd-api 3.0.0-next.20 → 3.0.0-next.22

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.
Files changed (83) hide show
  1. package/README.md +41 -3
  2. package/esm/fetchers/index.js +4 -13
  3. package/esm/helpers/cinema.helper.js +22 -10
  4. package/esm/helpers/creator.helper.js +12 -11
  5. package/esm/helpers/search.helper.js +5 -3
  6. package/esm/helpers/user-ratings.helper.js +2 -1
  7. package/esm/index.js +10 -29
  8. package/esm/services/cinema.service.js +11 -22
  9. package/esm/services/creator.service.js +8 -19
  10. package/esm/services/movie.service.js +10 -21
  11. package/esm/services/search.service.js +11 -22
  12. package/esm/services/user-ratings.service.js +25 -36
  13. package/{types → esm/types}/helpers/cinema.helper.d.ts +2 -3
  14. package/{types → esm/types}/helpers/search.helper.d.ts +1 -1
  15. package/{types → esm/types}/index.d.ts +1 -1
  16. package/fetchers/fetch.polyfill.d.ts +1 -0
  17. package/fetchers/index.d.ts +1 -0
  18. package/{cjs/fetchers → fetchers}/index.js +4 -13
  19. package/helpers/cinema.helper.d.ts +18 -0
  20. package/{cjs/helpers → helpers}/cinema.helper.js +23 -12
  21. package/helpers/creator.helper.d.ts +17 -0
  22. package/{cjs/helpers → helpers}/creator.helper.js +12 -11
  23. package/helpers/global.helper.d.ts +17 -0
  24. package/helpers/movie.helper.d.ts +25 -0
  25. package/helpers/search-user.helper.d.ts +5 -0
  26. package/helpers/search.helper.d.ts +11 -0
  27. package/{cjs/helpers → helpers}/search.helper.js +5 -3
  28. package/helpers/user-ratings.helper.d.ts +13 -0
  29. package/{cjs/helpers → helpers}/user-ratings.helper.js +2 -1
  30. package/index.d.ts +24 -0
  31. package/index.js +39 -0
  32. package/interfaces/cinema.interface.d.ts +23 -0
  33. package/interfaces/creator.interface.d.ts +12 -0
  34. package/interfaces/global.d.ts +22 -0
  35. package/interfaces/movie.interface.d.ts +66 -0
  36. package/interfaces/search.interface.d.ts +27 -0
  37. package/interfaces/user-ratings.interface.d.ts +18 -0
  38. package/package.json +20 -14
  39. package/services/cinema.service.d.ts +6 -0
  40. package/services/cinema.service.js +34 -0
  41. package/services/creator.service.d.ts +6 -0
  42. package/services/creator.service.js +32 -0
  43. package/services/movie.service.d.ts +6 -0
  44. package/{cjs/services → services}/movie.service.js +10 -21
  45. package/services/search.service.d.ts +5 -0
  46. package/{cjs/services → services}/search.service.js +11 -22
  47. package/services/user-ratings.service.d.ts +7 -0
  48. package/{cjs/services → services}/user-ratings.service.js +25 -36
  49. package/vars.d.ts +6 -0
  50. package/cjs/index.js +0 -58
  51. package/cjs/services/cinema.service.js +0 -45
  52. package/cjs/services/creator.service.js +0 -43
  53. package/types/index.ts +0 -26
  54. /package/{types → esm/types}/fetchers/fetch.polyfill.d.ts +0 -0
  55. /package/{types → esm/types}/fetchers/index.d.ts +0 -0
  56. /package/{types → esm/types}/helpers/creator.helper.d.ts +0 -0
  57. /package/{types → esm/types}/helpers/global.helper.d.ts +0 -0
  58. /package/{types → esm/types}/helpers/movie.helper.d.ts +0 -0
  59. /package/{types → esm/types}/helpers/search-user.helper.d.ts +0 -0
  60. /package/{types → esm/types}/helpers/user-ratings.helper.d.ts +0 -0
  61. /package/{types → esm/types}/interfaces/cinema.interface.d.ts +0 -0
  62. /package/{types → esm/types}/interfaces/creator.interface.d.ts +0 -0
  63. /package/{types → esm/types}/interfaces/global.d.ts +0 -0
  64. /package/{types → esm/types}/interfaces/movie.interface.d.ts +0 -0
  65. /package/{types → esm/types}/interfaces/search.interface.d.ts +0 -0
  66. /package/{types → esm/types}/interfaces/user-ratings.interface.d.ts +0 -0
  67. /package/{types → esm/types}/services/cinema.service.d.ts +0 -0
  68. /package/{types → esm/types}/services/creator.service.d.ts +0 -0
  69. /package/{types → esm/types}/services/movie.service.d.ts +0 -0
  70. /package/{types → esm/types}/services/search.service.d.ts +0 -0
  71. /package/{types → esm/types}/services/user-ratings.service.d.ts +0 -0
  72. /package/{types → esm/types}/vars.d.ts +0 -0
  73. /package/{cjs/fetchers → fetchers}/fetch.polyfill.js +0 -0
  74. /package/{cjs/helpers → helpers}/global.helper.js +0 -0
  75. /package/{cjs/helpers → helpers}/movie.helper.js +0 -0
  76. /package/{cjs/helpers → helpers}/search-user.helper.js +0 -0
  77. /package/{cjs/interfaces → interfaces}/cinema.interface.js +0 -0
  78. /package/{cjs/interfaces → interfaces}/creator.interface.js +0 -0
  79. /package/{cjs/interfaces → interfaces}/global.js +0 -0
  80. /package/{cjs/interfaces → interfaces}/movie.interface.js +0 -0
  81. /package/{cjs/interfaces → interfaces}/search.interface.js +0 -0
  82. /package/{cjs/interfaces → interfaces}/user-ratings.interface.js +0 -0
  83. /package/{cjs/vars.js → vars.js} +0 -0
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseMeta = exports.getFilms = exports.getGroupedFilmsByDate = exports.parseCinema = exports.getCinemaUrl = exports.getCoords = exports.getName = exports.getId = exports.getCinemaId = exports.getColorRating = void 0;
3
+ exports.parseMeta = exports.getFilms = exports.getGroupedFilmsByDate = exports.parseCinema = exports.getCinemaUrl = exports.getCoords = exports.getId = exports.getCinemaId = exports.getColorRating = void 0;
4
4
  const global_helper_1 = require("./global.helper");
5
5
  const getColorRating = (el) => {
6
6
  return (0, global_helper_1.parseColor)(el === null || el === void 0 ? void 0 : el.classNames.split(' ').pop());
@@ -19,20 +19,30 @@ const getId = (url) => {
19
19
  return null;
20
20
  };
21
21
  exports.getId = getId;
22
- const getName = (el) => {
23
- return el.querySelector('h1').innerText.trim();
24
- };
25
- exports.getName = getName;
26
22
  const getCoords = (el) => {
27
- const link = el === null || el === void 0 ? void 0 : el.querySelector('.box-header img[alt="Google Maps"]').closest('a').getAttribute('href');
28
- const coords = link.split('q=')[1].split(',');
29
- const [lat, lng] = coords;
30
- return { lat: +lat, lng: +lng };
23
+ if (!el)
24
+ return null;
25
+ const linkMapsEl = el.querySelector('a[href*="q="]');
26
+ if (!linkMapsEl)
27
+ return null;
28
+ const linkMaps = linkMapsEl.getAttribute('href');
29
+ const [_, latLng] = linkMaps.split('q=');
30
+ const coords = latLng.split(',');
31
+ if (coords.length !== 2)
32
+ return null;
33
+ const lat = Number(coords[0]);
34
+ const lng = Number(coords[1]);
35
+ if (Number.isFinite(lat) && Number.isFinite(lng)) {
36
+ return { lat, lng };
37
+ }
38
+ return null;
31
39
  };
32
40
  exports.getCoords = getCoords;
33
41
  const getCinemaUrl = (el) => {
34
- var _a;
35
- return (_a = el.querySelector('.box-header .cinema-logo a')) === null || _a === void 0 ? void 0 : _a.attributes.href;
42
+ var _a, _b;
43
+ if (!el)
44
+ return '';
45
+ return (_b = (_a = el.querySelector('a[title="Přejít na webovou stránku kina"]')) === null || _a === void 0 ? void 0 : _a.attributes.href) !== null && _b !== void 0 ? _b : '';
36
46
  };
37
47
  exports.getCinemaUrl = getCinemaUrl;
38
48
  const parseCinema = (el) => {
@@ -47,8 +57,9 @@ const getGroupedFilmsByDate = (el) => {
47
57
  .map((_, index) => index)
48
58
  .filter((index) => index % 2 === 0)
49
59
  .map((index) => {
60
+ var _a, _b, _c;
50
61
  const [date, films] = divs.slice(index, index + 2);
51
- const dateText = date === null || date === void 0 ? void 0 : date.innerText.trim();
62
+ const dateText = (_c = (_b = (_a = date === null || date === void 0 ? void 0 : date.firstChild) === null || _a === void 0 ? void 0 : _a.textContent) === null || _b === void 0 ? void 0 : _b.trim()) !== null && _c !== void 0 ? _c : null;
52
63
  return { date: dateText, films: (0, exports.getFilms)('', films) };
53
64
  });
54
65
  return getDatesAndFilms;
@@ -0,0 +1,17 @@
1
+ import { HTMLElement } from 'node-html-parser';
2
+ import { CSFDCreatorScreening } from '../interfaces/creator.interface';
3
+ import { CSFDColorRating } from '../interfaces/global';
4
+ export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
5
+ export declare const getId: (url: string) => number;
6
+ export declare const getName: (el: HTMLElement | null) => string;
7
+ export declare const getBirthdayInfo: (el: HTMLElement | null) => {
8
+ birthday: string;
9
+ age: number;
10
+ birthPlace: string;
11
+ };
12
+ export declare const getBio: (el: HTMLElement | null) => string;
13
+ export declare const getPhoto: (el: HTMLElement | null) => string;
14
+ export declare const parseBirthday: (text: string) => any;
15
+ export declare const parseAge: (text: string) => any;
16
+ export declare const parseBirthPlace: (text: string) => any;
17
+ export declare const getFilms: (el: HTMLElement | null) => CSFDCreatorScreening[];
@@ -18,24 +18,25 @@ const getName = (el) => {
18
18
  };
19
19
  exports.getName = getName;
20
20
  const getBirthdayInfo = (el) => {
21
- const text = el.querySelector('h1 + p').innerHTML.trim();
22
- const parts = text.split('\n');
23
- let birthday;
24
- let age;
25
- let birthPlace;
26
- if (parts.length) {
21
+ var _a, _b;
22
+ const infoBlock = el.querySelector('h1 + p');
23
+ const text = infoBlock === null || infoBlock === void 0 ? void 0 : infoBlock.innerHTML.trim();
24
+ const birthPlaceRow = (_a = infoBlock === null || infoBlock === void 0 ? void 0 : infoBlock.querySelector('.info-place')) === null || _a === void 0 ? void 0 : _a.innerHTML.trim();
25
+ const ageRow = (_b = infoBlock === null || infoBlock === void 0 ? void 0 : infoBlock.querySelector('.info')) === null || _b === void 0 ? void 0 : _b.innerHTML.trim();
26
+ let birthday = '';
27
+ if (text) {
28
+ const parts = text.split('\n');
27
29
  const birthdayRow = parts.find((x) => x.includes('nar.'));
28
- const ageRow = parts.find((x) => x.includes('let)'));
29
- const birthPlaceRow = parts.find((x) => x.includes('<br>')); // Ugly but there is no other way to detect
30
30
  birthday = birthdayRow ? (0, exports.parseBirthday)(birthdayRow) : '';
31
- age = ageRow ? +(0, exports.parseAge)(ageRow) : null;
32
- birthPlace = birthPlaceRow ? (0, exports.parseBirthPlace)(birthPlaceRow) : '';
33
31
  }
32
+ const age = ageRow ? +(0, exports.parseAge)(ageRow) : null;
33
+ const birthPlace = birthPlaceRow ? (0, exports.parseBirthPlace)(birthPlaceRow) : '';
34
34
  return { birthday, age, birthPlace };
35
35
  };
36
36
  exports.getBirthdayInfo = getBirthdayInfo;
37
37
  const getBio = (el) => {
38
- return el.querySelector('.article-content p').text.trim().split('\n')[0].trim();
38
+ var _a;
39
+ return ((_a = el.querySelector('.article-content p')) === null || _a === void 0 ? void 0 : _a.text.trim().split('\n')[0].trim()) || null;
39
40
  };
40
41
  exports.getBio = getBio;
41
42
  const getPhoto = (el) => {
@@ -0,0 +1,17 @@
1
+ import { CSFDColorRating } from '../interfaces/global';
2
+ import { Colors } from '../interfaces/user-ratings.interface';
3
+ export declare const parseIdFromUrl: (url: string) => number;
4
+ export declare const getColor: (cls: string) => CSFDColorRating;
5
+ export declare const parseColor: (quality: Colors) => CSFDColorRating;
6
+ export declare const addProtocol: (url: string) => string;
7
+ export declare const getDuration: (matches: any[]) => {
8
+ sign: string;
9
+ years: any;
10
+ months: any;
11
+ weeks: any;
12
+ days: any;
13
+ hours: any;
14
+ minutes: any;
15
+ seconds: any;
16
+ };
17
+ export declare const parseISO8601Duration: (iso: string) => number;
@@ -0,0 +1,25 @@
1
+ import { HTMLElement } from 'node-html-parser';
2
+ import { CSFDColorRating } from '../interfaces/global';
3
+ import { CSFDBoxContent, CSFDCreator, CSFDCreatorGroups, CSFDGenres, CSFDMovieListItem, CSFDPremiere, CSFDTitlesOther, CSFDVod } from '../interfaces/movie.interface';
4
+ export declare const getId: (el: HTMLElement) => number;
5
+ export declare const getTitle: (el: HTMLElement) => string;
6
+ export declare const getGenres: (el: HTMLElement) => CSFDGenres[];
7
+ export declare const getOrigins: (el: HTMLElement) => string[];
8
+ export declare const getColorRating: (bodyClasses: string[]) => CSFDColorRating;
9
+ export declare const getRating: (el: HTMLElement) => number;
10
+ export declare const getRatingCount: (el: HTMLElement) => number;
11
+ export declare const getYear: (el: string) => number;
12
+ export declare const getDuration: (jsonLdRaw: string, el: HTMLElement) => number;
13
+ export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
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
+ export declare const getDescriptions: (el: HTMLElement) => string[];
18
+ export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
19
+ export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
20
+ export declare const getType: (el: HTMLElement) => string;
21
+ export declare const getVods: (el: HTMLElement | null) => CSFDVod[];
22
+ export declare const getBoxContent: (el: HTMLElement, box: string) => HTMLElement;
23
+ export declare const getBoxMovies: (el: HTMLElement, boxName: CSFDBoxContent) => CSFDMovieListItem[];
24
+ export declare const getPremieres: (el: HTMLElement) => CSFDPremiere[];
25
+ export declare const getTags: (el: HTMLElement) => string[];
@@ -0,0 +1,5 @@
1
+ import { HTMLElement } from 'node-html-parser';
2
+ export declare const getUser: (el: HTMLElement) => string;
3
+ export declare const getUserRealName: (el: HTMLElement) => string;
4
+ export declare const getAvatar: (el: HTMLElement) => string;
5
+ export declare const getUserUrl: (el: HTMLElement) => string;
@@ -0,0 +1,11 @@
1
+ import { HTMLElement } from 'node-html-parser';
2
+ import { CSFDColorRating, CSFDFilmTypes } from '../interfaces/global';
3
+ import { CSFDCreator } from '../interfaces/movie.interface';
4
+ export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
5
+ export declare const getTitle: (el: HTMLElement) => string;
6
+ export declare const getYear: (el: HTMLElement) => number;
7
+ export declare const getUrl: (el: HTMLElement) => string;
8
+ export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
9
+ export declare const getPoster: (el: HTMLElement) => string;
10
+ export declare const getOrigins: (el: HTMLElement) => string[];
11
+ export declare const parsePeople: (el: HTMLElement, type: "directors" | "actors") => CSFDCreator[];
@@ -30,9 +30,11 @@ const getPoster = (el) => {
30
30
  };
31
31
  exports.getPoster = getPoster;
32
32
  const getOrigins = (el) => {
33
- var _a;
34
- const originsRaw = el.querySelector('.article-content p .info').text;
35
- const originsAll = (_a = originsRaw === null || originsRaw === void 0 ? void 0 : originsRaw.split(', ')) === null || _a === void 0 ? void 0 : _a[0];
33
+ var _a, _b;
34
+ const originsRaw = (_a = el.querySelector('.article-content p .info')) === null || _a === void 0 ? void 0 : _a.text;
35
+ if (!originsRaw)
36
+ return [];
37
+ const originsAll = (_b = originsRaw === null || originsRaw === void 0 ? void 0 : originsRaw.split(', ')) === null || _b === void 0 ? void 0 : _b[0];
36
38
  return originsAll === null || originsAll === void 0 ? void 0 : originsAll.split('/').map((country) => country.trim());
37
39
  };
38
40
  exports.getOrigins = getOrigins;
@@ -0,0 +1,13 @@
1
+ import { HTMLElement } from 'node-html-parser';
2
+ import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../interfaces/global';
3
+ import { Colors } from '../interfaces/user-ratings.interface';
4
+ export declare const getId: (el: HTMLElement) => number;
5
+ export declare const getUserRating: (el: HTMLElement) => CSFDStars;
6
+ export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
7
+ export declare const getTitle: (el: HTMLElement) => string;
8
+ export declare const getYear: (el: HTMLElement) => number;
9
+ export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
10
+ export declare const getDate: (el: HTMLElement) => string;
11
+ export declare const getUrl: (el: HTMLElement) => string;
12
+ export declare const parseColor: (quality: Colors) => CSFDColorRating;
13
+ export declare const sleep: (ms: number) => Promise<unknown>;
@@ -23,7 +23,8 @@ const getTitle = (el) => {
23
23
  };
24
24
  exports.getTitle = getTitle;
25
25
  const getYear = (el) => {
26
- return +el.querySelectorAll('td.name .film-title-info .info')[0].text.slice(1, -1);
26
+ var _a;
27
+ return +((_a = el.querySelectorAll('td.name .film-title-info .info')[0]) === null || _a === void 0 ? void 0 : _a.text.slice(1, -1)) || null;
27
28
  };
28
29
  exports.getYear = getYear;
29
30
  const getColorRating = (el) => {
package/index.d.ts ADDED
@@ -0,0 +1,24 @@
1
+ import { CSFDCinema, CSFDCinemaPeriod } from 'interfaces/cinema.interface';
2
+ import { CSFDCreator } from './interfaces/creator.interface';
3
+ import { CSFDMovie } from './interfaces/movie.interface';
4
+ import { CSFDSearch } from './interfaces/search.interface';
5
+ import { CSFDUserRatingConfig, CSFDUserRatings } from './interfaces/user-ratings.interface';
6
+ import { CinemaScraper } from './services/cinema.service';
7
+ import { CreatorScraper } from './services/creator.service';
8
+ import { MovieScraper } from './services/movie.service';
9
+ import { SearchScraper } from './services/search.service';
10
+ import { UserRatingsScraper } from './services/user-ratings.service';
11
+ export declare class Csfd {
12
+ private userRatingsService;
13
+ private movieService;
14
+ private creatorService;
15
+ private searchService;
16
+ private cinemaService;
17
+ constructor(userRatingsService: UserRatingsScraper, movieService: MovieScraper, creatorService: CreatorScraper, searchService: SearchScraper, cinemaService: CinemaScraper);
18
+ userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
19
+ movie(movie: number): Promise<CSFDMovie>;
20
+ creator(creator: number): Promise<CSFDCreator>;
21
+ search(text: string): Promise<CSFDSearch>;
22
+ cinema(district: number | string, period: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
23
+ }
24
+ export declare const csfd: Csfd;
package/index.js ADDED
@@ -0,0 +1,39 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.csfd = exports.Csfd = void 0;
4
+ const cinema_service_1 = require("./services/cinema.service");
5
+ const creator_service_1 = require("./services/creator.service");
6
+ const movie_service_1 = require("./services/movie.service");
7
+ const search_service_1 = require("./services/search.service");
8
+ const user_ratings_service_1 = require("./services/user-ratings.service");
9
+ class Csfd {
10
+ constructor(userRatingsService, movieService, creatorService, searchService, cinemaService) {
11
+ this.userRatingsService = userRatingsService;
12
+ this.movieService = movieService;
13
+ this.creatorService = creatorService;
14
+ this.searchService = searchService;
15
+ this.cinemaService = cinemaService;
16
+ }
17
+ async userRatings(user, config) {
18
+ return this.userRatingsService.userRatings(user, config);
19
+ }
20
+ async movie(movie) {
21
+ return this.movieService.movie(+movie);
22
+ }
23
+ async creator(creator) {
24
+ return this.creatorService.creator(+creator);
25
+ }
26
+ async search(text) {
27
+ return this.searchService.search(text);
28
+ }
29
+ async cinema(district, period) {
30
+ return this.cinemaService.cinemas(+district, period);
31
+ }
32
+ }
33
+ exports.Csfd = Csfd;
34
+ const movieScraper = new movie_service_1.MovieScraper();
35
+ const userRatingsScraper = new user_ratings_service_1.UserRatingsScraper();
36
+ const cinemaScraper = new cinema_service_1.CinemaScraper();
37
+ const creatorScraper = new creator_service_1.CreatorScraper();
38
+ const searchScraper = new search_service_1.SearchScraper();
39
+ exports.csfd = new Csfd(userRatingsScraper, movieScraper, creatorScraper, searchScraper, cinemaScraper);
@@ -0,0 +1,23 @@
1
+ import { CSFDMovieListItem } from './movie.interface';
2
+ export interface CSFDCinema {
3
+ id: number;
4
+ name: string;
5
+ city: string;
6
+ url: string;
7
+ coords: {
8
+ lat: number;
9
+ lng: number;
10
+ };
11
+ region?: string;
12
+ screenings: CSFDCinemaGroupedFilmsByDate[];
13
+ }
14
+ export interface CSFDCinemaGroupedFilmsByDate {
15
+ date: string;
16
+ films: CSFDCinemaMovie[];
17
+ }
18
+ export interface CSFDCinemaMovie extends CSFDMovieListItem {
19
+ meta: CSFDCinemaMeta[];
20
+ showTimes: string[];
21
+ }
22
+ export type CSFDCinemaMeta = 'dubbing' | '3D' | 'subtitles' | string;
23
+ export type CSFDCinemaPeriod = 'today' | 'weekend' | 'week' | 'tomorrow' | 'month';
@@ -0,0 +1,12 @@
1
+ import { CSFDScreening } from './global';
2
+ export interface CSFDCreator {
3
+ id: number;
4
+ name: string;
5
+ birthday: string;
6
+ birthplace: string;
7
+ photo: string;
8
+ age: number | string;
9
+ bio: string;
10
+ films: CSFDCreatorScreening[];
11
+ }
12
+ export type CSFDCreatorScreening = Omit<CSFDScreening, 'url' | 'type'>;
@@ -0,0 +1,22 @@
1
+ export interface CSFDScreening {
2
+ id: number;
3
+ title: string;
4
+ year: number;
5
+ url: string;
6
+ type: CSFDFilmTypes;
7
+ /**
8
+ * Overall aggregated rating. (On the web usually represented by colors).
9
+ *
10
+ * 'unknown': unknown (gray color)
11
+ *
12
+ * 'good': 70% – 100 % (red color)
13
+ *
14
+ * 'average': 30% - 69% (blue color)
15
+ *
16
+ * 'bad': 0% - 29% (black color)
17
+ */
18
+ colorRating: CSFDColorRating;
19
+ }
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';
@@ -0,0 +1,66 @@
1
+ import { CSFDScreening } from './global';
2
+ export interface CSFDMovie extends CSFDScreening {
3
+ rating: number | null;
4
+ poster: string;
5
+ photo: string;
6
+ ratingCount: number | null;
7
+ duration: number | string;
8
+ titlesOther: CSFDTitlesOther[];
9
+ origins: string[];
10
+ descriptions: string[];
11
+ trivia: string[];
12
+ genres: CSFDGenres[] | string[];
13
+ creators: CSFDCreators;
14
+ vod: CSFDVod[];
15
+ tags: string[];
16
+ premieres: CSFDPremiere[];
17
+ related: CSFDMovieListItem[];
18
+ similar: CSFDMovieListItem[];
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';
21
+ export interface CSFDVod {
22
+ title: CSFDVodService;
23
+ url: string;
24
+ }
25
+ export interface CSFDCreators {
26
+ directors: CSFDCreator[];
27
+ writers: CSFDCreator[];
28
+ cinematography: CSFDCreator[];
29
+ music: CSFDCreator[];
30
+ actors: CSFDCreator[];
31
+ basedOn: CSFDCreator[];
32
+ producers: CSFDCreator[];
33
+ filmEditing: CSFDCreator[];
34
+ costumeDesign: CSFDCreator[];
35
+ productionDesign: CSFDCreator[];
36
+ }
37
+ export interface CSFDTitlesOther {
38
+ country: string;
39
+ title: string;
40
+ }
41
+ export interface CSFDCreator {
42
+ /**
43
+ * CSFD person ID.
44
+ *
45
+ * You can always assemble url from ID like this:
46
+ *
47
+ * `https://www.csfd.cz/tvurce/${id}`
48
+ */
49
+ id: number;
50
+ name: string;
51
+ url: string;
52
+ }
53
+ export interface CSFDMovieListItem {
54
+ id: number;
55
+ title: string;
56
+ url: string;
57
+ }
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';
60
+ export interface CSFDPremiere {
61
+ country: string;
62
+ format: string;
63
+ date: string;
64
+ company: string;
65
+ }
66
+ export type CSFDBoxContent = 'Související' | 'Podobné';
@@ -0,0 +1,27 @@
1
+ import { CSFDScreening } from './global';
2
+ import { CSFDCreator } from './movie.interface';
3
+ export interface CSFDSearch {
4
+ movies: CSFDSearchMovie[];
5
+ tvSeries: CSFDSearchMovie[];
6
+ creators: CSFDSearchCreator[];
7
+ users: CSFDSearchUser[];
8
+ }
9
+ export interface CSFDSearchMovie extends CSFDScreening {
10
+ poster: string;
11
+ origins: string[];
12
+ creators: CSFDSearchCreators;
13
+ }
14
+ export interface CSFDSearchUser {
15
+ id: number;
16
+ user: string;
17
+ userRealName: string;
18
+ avatar: string;
19
+ url: string;
20
+ }
21
+ export interface CSFDSearchCreator extends CSFDCreator {
22
+ image: string;
23
+ }
24
+ export interface CSFDSearchCreators {
25
+ directors: CSFDCreator[];
26
+ actors: CSFDCreator[];
27
+ }
@@ -0,0 +1,18 @@
1
+ import { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';
2
+ export interface CSFDUserRatings extends CSFDScreening {
3
+ userRating: CSFDStars;
4
+ userDate: string;
5
+ }
6
+ export interface CSFDUserRatingConfig {
7
+ includesOnly?: CSFDFilmTypes[];
8
+ excludes?: CSFDFilmTypes[];
9
+ /**
10
+ * Fetch all ratings. (Warning: Use it wisely. Can be detected and banned. Consider using it together with `allPagesDelay` attribute)
11
+ */
12
+ allPages?: boolean;
13
+ /**
14
+ * Delay on each page request. In milliseconds
15
+ */
16
+ allPagesDelay?: number;
17
+ }
18
+ export type Colors = 'lightgrey' | 'blue' | 'red' | 'grey';
package/package.json CHANGED
@@ -1,21 +1,29 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "3.0.0-next.20",
3
+ "version": "3.0.0-next.22",
4
4
  "description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
5
- "main": "./cjs/index.js",
5
+ "main": "./index.js",
6
+ "module": "./index.js",
7
+ "types": "./index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "require": "./dist/index.js",
11
+ "import": "./dist/esm/index.js"
12
+ }
13
+ },
6
14
  "author": "BART! <bart@bartweb.cz>",
7
15
  "scripts": {
8
16
  "start": "tsc -w",
9
- "prebuild": "rimraf dist",
10
- "build": "tsc && tsc -p tsconfig-cjs.json && yarn barrels",
11
- "barrels": "barrelsby --delete -c barrels.json",
12
- "postbuild": "npm-prepare-dist -s postinstall -s prepare && yarn fix-paths",
17
+ "prebuild": "rimraf dist dist/esm dist/cjs",
18
+ "build:cjs": "tsc --project tsconfig.json",
19
+ "build:esm": "tsc --project tsconfig.esm.json",
20
+ "build": "npm run build:cjs && npm run build:esm",
21
+ "postbuild": "npm-prepare-dist -s postinstall -s prepare",
13
22
  "tsc": "tsc",
14
23
  "demo": "tsx demo",
15
24
  "lint": "eslint ./src/**/**/* --fix",
16
25
  "test": "vitest",
17
26
  "test:coverage": "yarn test run --coverage",
18
- "fix-paths": "yarn json -I -f ./dist/package.json -e \"this.module='./esm/index.js';this.main='./cjs/index.js';this.types='./types/index.d.ts'\"",
19
27
  "publish:next": "yarn && yarn build && yarn test:coverage && cd dist && npm publish --tag next",
20
28
  "postversion": "git push && git push --follow-tags",
21
29
  "release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
@@ -29,8 +37,8 @@
29
37
  "registry": "https://registry.npmjs.org"
30
38
  },
31
39
  "dependencies": {
32
- "cross-fetch": "^4.0.0",
33
- "node-html-parser": "^6.1.12"
40
+ "cross-fetch": "^4.1.0",
41
+ "node-html-parser": "^7.0.1"
34
42
  },
35
43
  "repository": {
36
44
  "url": "git+https://github.com/bartholomej/node-csfd-api.git",
@@ -54,12 +62,10 @@
54
62
  "api"
55
63
  ],
56
64
  "engines": {
57
- "node": ">= 14"
65
+ "node": ">= 18"
58
66
  },
59
67
  "license": "MIT",
60
68
  "lint-staged": {
61
69
  "*.ts": "eslint --cache --fix"
62
- },
63
- "module": "./esm/index.js",
64
- "types": "./types/index.d.ts"
65
- }
70
+ }
71
+ }
@@ -0,0 +1,6 @@
1
+ import { CSFDCinema, CSFDCinemaPeriod } from '../interfaces/cinema.interface';
2
+ export declare class CinemaScraper {
3
+ private cinema;
4
+ cinemas(district?: number, period?: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
5
+ private buildCinemas;
6
+ }
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CinemaScraper = void 0;
4
+ const node_html_parser_1 = require("node-html-parser");
5
+ const fetchers_1 = require("../fetchers");
6
+ const vars_1 = require("../vars");
7
+ const cinema_helper_1 = require("./../helpers/cinema.helper");
8
+ class CinemaScraper {
9
+ async cinemas(district = 1, period = 'today') {
10
+ const url = (0, vars_1.cinemasUrl)(district, period);
11
+ const response = await (0, fetchers_1.fetchPage)(url);
12
+ const cinemasHtml = (0, node_html_parser_1.parse)(response);
13
+ const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
14
+ this.buildCinemas(contentNode);
15
+ return this.cinema;
16
+ }
17
+ buildCinemas(contentNode) {
18
+ const cinemas = [];
19
+ contentNode.forEach((x) => {
20
+ const cinemaInfo = (0, cinema_helper_1.parseCinema)(x);
21
+ const cinema = {
22
+ id: (0, cinema_helper_1.getCinemaId)(x),
23
+ name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
24
+ city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
25
+ url: (0, cinema_helper_1.getCinemaUrl)(x),
26
+ coords: (0, cinema_helper_1.getCoords)(x),
27
+ screenings: (0, cinema_helper_1.getGroupedFilmsByDate)(x)
28
+ };
29
+ cinemas.push(cinema);
30
+ });
31
+ this.cinema = cinemas;
32
+ }
33
+ }
34
+ exports.CinemaScraper = CinemaScraper;
@@ -0,0 +1,6 @@
1
+ import { CSFDCreator } from '../interfaces/creator.interface';
2
+ export declare class CreatorScraper {
3
+ private person;
4
+ creator(creatorId: number): Promise<CSFDCreator>;
5
+ private buildCreator;
6
+ }
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CreatorScraper = void 0;
4
+ const node_html_parser_1 = require("node-html-parser");
5
+ const fetchers_1 = require("../fetchers");
6
+ const creator_helper_1 = require("../helpers/creator.helper");
7
+ const vars_1 = require("../vars");
8
+ class CreatorScraper {
9
+ async creator(creatorId) {
10
+ const url = (0, vars_1.creatorUrl)(+creatorId);
11
+ const response = await (0, fetchers_1.fetchPage)(url);
12
+ const creatorHtml = (0, node_html_parser_1.parse)(response);
13
+ const asideNode = creatorHtml.querySelector('.creator-about');
14
+ const filmsNode = creatorHtml.querySelector('.creator-filmography');
15
+ this.buildCreator(+creatorId, asideNode, filmsNode);
16
+ return this.person;
17
+ }
18
+ buildCreator(id, asideEl, filmsNode) {
19
+ var _a, _b, _c;
20
+ this.person = {
21
+ id,
22
+ name: (0, creator_helper_1.getName)(asideEl),
23
+ birthday: (_a = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
24
+ birthplace: (_b = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
25
+ photo: (0, creator_helper_1.getPhoto)(asideEl),
26
+ age: ((_c = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
27
+ bio: (0, creator_helper_1.getBio)(asideEl),
28
+ films: (0, creator_helper_1.getFilms)(filmsNode)
29
+ };
30
+ }
31
+ }
32
+ exports.CreatorScraper = CreatorScraper;
@@ -0,0 +1,6 @@
1
+ import { CSFDMovie } from '../interfaces/movie.interface';
2
+ export declare class MovieScraper {
3
+ private film;
4
+ movie(movieId: number): Promise<CSFDMovie>;
5
+ private buildMovie;
6
+ }