node-csfd-api 3.0.0-next.21 → 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 (50) hide show
  1. package/esm/fetchers/fetch.polyfill.js +6 -0
  2. package/esm/fetchers/index.js +23 -0
  3. package/esm/helpers/cinema.helper.js +93 -0
  4. package/esm/helpers/creator.helper.js +74 -0
  5. package/esm/helpers/global.helper.js +59 -0
  6. package/esm/helpers/movie.helper.js +228 -0
  7. package/esm/helpers/search-user.helper.js +15 -0
  8. package/esm/helpers/search.helper.js +51 -0
  9. package/esm/helpers/user-ratings.helper.js +48 -0
  10. package/esm/index.js +35 -0
  11. package/esm/interfaces/cinema.interface.js +1 -0
  12. package/esm/interfaces/creator.interface.js +1 -0
  13. package/esm/interfaces/global.js +1 -0
  14. package/esm/interfaces/movie.interface.js +1 -0
  15. package/esm/interfaces/search.interface.js +1 -0
  16. package/esm/interfaces/user-ratings.interface.js +1 -0
  17. package/esm/services/cinema.service.js +30 -0
  18. package/esm/services/creator.service.js +28 -0
  19. package/esm/services/movie.service.js +54 -0
  20. package/esm/services/search.service.js +76 -0
  21. package/esm/services/user-ratings.service.js +80 -0
  22. package/esm/types/fetchers/fetch.polyfill.d.ts +1 -0
  23. package/esm/types/fetchers/index.d.ts +1 -0
  24. package/esm/types/helpers/cinema.helper.d.ts +18 -0
  25. package/esm/types/helpers/creator.helper.d.ts +17 -0
  26. package/esm/types/helpers/global.helper.d.ts +17 -0
  27. package/esm/types/helpers/movie.helper.d.ts +25 -0
  28. package/esm/types/helpers/search-user.helper.d.ts +5 -0
  29. package/esm/types/helpers/search.helper.d.ts +11 -0
  30. package/esm/types/helpers/user-ratings.helper.d.ts +13 -0
  31. package/esm/types/index.d.ts +24 -0
  32. package/esm/types/interfaces/cinema.interface.d.ts +23 -0
  33. package/esm/types/interfaces/creator.interface.d.ts +12 -0
  34. package/esm/types/interfaces/global.d.ts +22 -0
  35. package/esm/types/interfaces/movie.interface.d.ts +66 -0
  36. package/esm/types/interfaces/search.interface.d.ts +27 -0
  37. package/esm/types/interfaces/user-ratings.interface.d.ts +18 -0
  38. package/esm/types/services/cinema.service.d.ts +6 -0
  39. package/esm/types/services/creator.service.d.ts +6 -0
  40. package/esm/types/services/movie.service.d.ts +6 -0
  41. package/esm/types/services/search.service.d.ts +5 -0
  42. package/esm/types/services/user-ratings.service.d.ts +7 -0
  43. package/esm/types/vars.d.ts +6 -0
  44. package/esm/vars.js +7 -0
  45. package/helpers/cinema.helper.d.ts +2 -3
  46. package/helpers/cinema.helper.js +6 -6
  47. package/index.d.ts +1 -1
  48. package/package.json +14 -6
  49. package/services/cinema.service.js +4 -4
  50. package/services/search.service.js +3 -3
@@ -3,12 +3,11 @@ import { HTMLElement } from 'node-html-parser';
3
3
  import { CSFDColorRating } from '../interfaces/global';
4
4
  export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
5
5
  export declare const getCinemaId: (el: HTMLElement | null) => number;
6
- export declare const getId: (url: string) => number;
7
- export declare const getName: (el: HTMLElement | null) => string;
6
+ export declare const getId: (url: string) => number | null;
8
7
  export declare const getCoords: (el: HTMLElement | null) => {
9
8
  lat: number;
10
9
  lng: number;
11
- };
10
+ } | null;
12
11
  export declare const getCinemaUrl: (el: HTMLElement | null) => string;
13
12
  export declare const parseCinema: (el: HTMLElement | null) => {
14
13
  city: string;
@@ -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,11 +19,9 @@ 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) => {
23
+ if (!el)
24
+ return null;
27
25
  const linkMapsEl = el.querySelector('a[href*="q="]');
28
26
  if (!linkMapsEl)
29
27
  return null;
@@ -42,6 +40,8 @@ const getCoords = (el) => {
42
40
  exports.getCoords = getCoords;
43
41
  const getCinemaUrl = (el) => {
44
42
  var _a, _b;
43
+ if (!el)
44
+ return '';
45
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 : '';
46
46
  };
47
47
  exports.getCinemaUrl = getCinemaUrl;
@@ -59,7 +59,7 @@ const getGroupedFilmsByDate = (el) => {
59
59
  .map((index) => {
60
60
  var _a, _b, _c;
61
61
  const [date, films] = divs.slice(index, index + 2);
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 : "";
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;
63
63
  return { date: dateText, films: (0, exports.getFilms)('', films) };
64
64
  });
65
65
  return getDatesAndFilms;
package/index.d.ts CHANGED
@@ -19,6 +19,6 @@ export declare class Csfd {
19
19
  movie(movie: number): Promise<CSFDMovie>;
20
20
  creator(creator: number): Promise<CSFDCreator>;
21
21
  search(text: string): Promise<CSFDSearch>;
22
- cinema(district: number, period: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
22
+ cinema(district: number | string, period: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
23
23
  }
24
24
  export declare const csfd: Csfd;
package/package.json CHANGED
@@ -1,13 +1,23 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "3.0.0-next.21",
3
+ "version": "3.0.0-next.22",
4
4
  "description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
5
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",
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",
11
21
  "postbuild": "npm-prepare-dist -s postinstall -s prepare",
12
22
  "tsc": "tsc",
13
23
  "demo": "tsx demo",
@@ -57,7 +67,5 @@
57
67
  "license": "MIT",
58
68
  "lint-staged": {
59
69
  "*.ts": "eslint --cache --fix"
60
- },
61
- "module": "./index.js",
62
- "types": "./index.d.ts"
70
+ }
63
71
  }
@@ -16,12 +16,12 @@ class CinemaScraper {
16
16
  }
17
17
  buildCinemas(contentNode) {
18
18
  const cinemas = [];
19
- contentNode.map((x) => {
20
- var _a, _b;
19
+ contentNode.forEach((x) => {
20
+ const cinemaInfo = (0, cinema_helper_1.parseCinema)(x);
21
21
  const cinema = {
22
22
  id: (0, cinema_helper_1.getCinemaId)(x),
23
- name: (_a = (0, cinema_helper_1.parseCinema)(x)) === null || _a === void 0 ? void 0 : _a.name,
24
- city: (_b = (0, cinema_helper_1.parseCinema)(x)) === null || _b === void 0 ? void 0 : _b.city,
23
+ name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
24
+ city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
25
25
  url: (0, cinema_helper_1.getCinemaUrl)(x),
26
26
  coords: (0, cinema_helper_1.getCoords)(x),
27
27
  screenings: (0, cinema_helper_1.getGroupedFilmsByDate)(x)
@@ -21,7 +21,7 @@ class SearchScraper {
21
21
  const movies = [];
22
22
  const users = [];
23
23
  const tvSeries = [];
24
- moviesNode.map((m) => {
24
+ moviesNode.forEach((m) => {
25
25
  const url = (0, search_helper_1.getUrl)(m);
26
26
  const movie = {
27
27
  id: (0, global_helper_1.parseIdFromUrl)(url),
@@ -39,7 +39,7 @@ class SearchScraper {
39
39
  };
40
40
  movies.push(movie);
41
41
  });
42
- usersNode.map((m) => {
42
+ usersNode.forEach((m) => {
43
43
  const url = (0, search_user_helper_1.getUserUrl)(m);
44
44
  const user = {
45
45
  id: (0, global_helper_1.parseIdFromUrl)(url),
@@ -50,7 +50,7 @@ class SearchScraper {
50
50
  };
51
51
  users.push(user);
52
52
  });
53
- tvSeriesNode.map((m) => {
53
+ tvSeriesNode.forEach((m) => {
54
54
  const url = (0, search_helper_1.getUrl)(m);
55
55
  const user = {
56
56
  id: (0, global_helper_1.parseIdFromUrl)(url),