node-csfd-api 1.11.0-beta.1 → 2.0.1

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.
package/README.md CHANGED
@@ -5,33 +5,33 @@
5
5
 
6
6
  # CSFD API 2021
7
7
 
8
- > Tiny NPM library for scraping csfd.cz
8
+ > JavaScript NPM library for scraping **Czech Movie Database (csfd.cz)**
9
9
  >
10
10
  > - Browser + Node.js (SSR)
11
- > - TypeScript 100%
12
- > - Ready for CSFD 2021!
13
-
14
- Scraper:
15
-
16
- > - [Movies and TV Series](#Movie)
17
- > - [User Ratings](#User-Ratings)
18
- > - [Search](#Search)
11
+ > - JavaScript / TypeScript
12
+ > - Tested (~100% Code coverage)
13
+ > - ✅ Ready for new ČSFD 2021!
14
+ > - You can use in:
15
+ > - Firebase function
16
+ > - AWS λ (lambda function)
17
+ > - Chrome extension
18
+ > - React native app
19
+ > - ...
19
20
 
20
21
  ## Install
21
22
 
22
- via yarn
23
-
24
23
  ```bash
25
- yarn add node-csfd-api
24
+ npm install node-csfd-api --save
25
+ # yarn add node-csfd-api
26
26
  ```
27
27
 
28
- via npm
28
+ ## Usage and examples
29
29
 
30
- ```bash
31
- npm install node-csfd-api
32
- ```
30
+ - [Movies and TV Series](#Movie)
31
+ - [User Ratings](#User-Ratings)
32
+ - [Search](#Search)
33
33
 
34
- ## Movie
34
+ ### Movie
35
35
 
36
36
  Get info about [this movie](https://www.csfd.cz/film/535121-na-spatne-strane/komentare/) _(id: 535121)_
37
37
 
@@ -41,7 +41,7 @@ import { csfd } from 'node-csfd-api';
41
41
  csfd.movie(535121).then((movie) => console.log(movie));
42
42
  ```
43
43
 
44
- ### Results
44
+ #### Results
45
45
 
46
46
  ```javascript
47
47
  {
@@ -59,8 +59,6 @@ csfd.movie(535121).then((movie) => console.log(movie));
59
59
  colorRating: 'good',
60
60
  rating: 73,
61
61
  ratingCount: 6654,
62
- photo: '//image.pmgstatic.com/cache/resized/w1326/files/images/film/photos/162/980/162980090_bbffbb.jpg',
63
- trivia: ['Když Henry (Tory Kittles) se svým mladším bratrem...', 'Ve filmu se střídají...'],
64
62
  titlesOther: [
65
63
  { country: 'USA', title: 'Dragged Across Concrete' },
66
64
  { country: 'Kanada', title: 'Dragged Across Concrete' },
@@ -68,7 +66,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
68
66
  { country: 'Austrálie', title: 'Dragged Across Concrete' },
69
67
  { country: 'Velká Británie', title: 'Dragged Across Concrete' }
70
68
  ],
71
- poster: '//image.pmgstatic.com/cache/resized/w1080/files/images/film/posters/163/579/163579352_bf8737.jpg',
69
+ poster: 'https://image.pmgstatic.com/cache/resized/w1080/files/images/film/posters/163/579/163579352_bf8737.jpg',
72
70
  creators: {
73
71
  directors: [
74
72
  {
@@ -135,7 +133,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
135
133
  }
136
134
  ```
137
135
 
138
- ## Search
136
+ ### Search
139
137
 
140
138
  > Search movies and users
141
139
 
@@ -145,7 +143,7 @@ import { csfd } from 'node-csfd-api';
145
143
  csfd.search('bart').then((search) => console.log(search));
146
144
  ```
147
145
 
148
- ### Results
146
+ #### Results
149
147
 
150
148
  ```javascript
151
149
  movies: [
@@ -177,13 +175,13 @@ users: [
177
175
  id: 912,
178
176
  user: 'BART!',
179
177
  userRealName: 'Lukáš Barták',
180
- avatar: '//image.pmgstatic.com/cache/resized/w45h60/files/images/user/avatars/000/281/281554_1c0fef.jpg',
178
+ avatar: 'https://image.pmgstatic.com/cache/resized/w45h60/files/images/user/avatars/000/281/281554_1c0fef.jpg',
181
179
  url: 'https://www.csfd.cz/uzivatel/912-bart/'
182
180
  }
183
181
  ]
184
182
  ```
185
183
 
186
- ## Creators
184
+ ### Creators
187
185
 
188
186
  > Search creators and filmography
189
187
 
@@ -193,7 +191,7 @@ import { csfd } from 'node-csfd-api';
193
191
  csfd.creator(2120).then((creator) => console.log(creator));
194
192
  ```
195
193
 
196
- ### Results
194
+ #### Results
197
195
 
198
196
  ```javascript
199
197
  {
@@ -201,7 +199,7 @@ csfd.creator(2120).then((creator) => console.log(creator));
201
199
  name: 'Quentin Tarantino',
202
200
  birthday: '27.03.1963',
203
201
  birthplace: 'Knoxville, Tennessee, USA',
204
- photo: '//image.pmgstatic.com/cache/resized/w100h132crop/files/images/creator/photos/164/515/164515525_b98f8a.jpg',
202
+ photo: 'https://image.pmgstatic.com/cache/resized/w100h132crop/files/images/creator/photos/164/515/164515525_b98f8a.jpg',
205
203
  age: 58,
206
204
  bio: 'Quentin Tarantino se narodil 27. března roku 1963 v americkém Knoxville teprve šestnáctileté Connie Tarantinové. Své jméno Quentin dostal podle matčiny oblíbené televizní postavy Quinta ze seriálu "Gunsmoke". Quentinův otec byl jistý Tony Tarantino, který rodinu opustil když byl Quentin ještě malinký. Jeho dětství a dospívání ovlivnily nejen filmy, ale pop kultura obecně. Televizní seriály, komiksy, populární hudba, to vše jako mladý hltal ve velkém a stále neměl…',
207
205
  films: [
@@ -270,9 +268,9 @@ csfd.creator(2120).then((creator) => console.log(creator));
270
268
  }
271
269
  ```
272
270
 
273
- ## User Ratings
271
+ ### User Ratings
274
272
 
275
- ### Last ratings (last page)
273
+ #### Last ratings (last page)
276
274
 
277
275
  Get [my last 50 ratings](https://www.csfd.cz/uzivatel/912-bart/hodnoceni/)
278
276
 
@@ -282,7 +280,7 @@ import { csfd } from 'node-csfd-api';
282
280
  csfd.userRatings('912-bart').then((ratings) => console.log(ratings));
283
281
  ```
284
282
 
285
- ### All ratings (all pages)
283
+ #### All ratings (all pages)
286
284
 
287
285
  > Warning: Use it wisely. Can be detected and banned. Consider using it together with `allPagesDelay` attribute.
288
286
 
@@ -299,7 +297,7 @@ csfd
299
297
  .then((ratings) => console.log(ratings));
300
298
  ```
301
299
 
302
- ### Results
300
+ #### Results
303
301
 
304
302
  ```javascript
305
303
  [
@@ -324,14 +322,14 @@ csfd
324
322
  ];
325
323
  ```
326
324
 
327
- ### Options
325
+ #### Options
328
326
 
329
- | Option | Type | Default | Description |
330
- | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------- | --------------------------------------------------------- |
331
- | **includesOnly** | [CSFDFilmTypes[]](https://github.com/bartholomej/node-csfd-api/blob/8fa5f9cbc7e7f2b62b0bd2c2b5a24c9a63444f6a/src/interfaces/global.ts#L25) | null | Including only film types. eg. `['TV Seriál', 'koncert']` |
332
- | **exclude** | [CSFDFilmTypes[]](https://github.com/bartholomej/node-csfd-api/blob/8fa5f9cbc7e7f2b62b0bd2c2b5a24c9a63444f6a/src/interfaces/global.ts#L25) | null | Excluding film types eg. `['epizoda', 'série']` |
333
- | **allPages** | boolean | false | Get all pages |
334
- | **allPagesDelay** | number | 0 | Delay on each page request. In milliseconds |
327
+ | Option | Type | Default | Description |
328
+ | ----------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------- | ------------------------------------------------------ |
329
+ | **includesOnly** | [CSFDFilmTypes[]](https://github.com/bartholomej/node-csfd-api/blob/8fa5f9cbc7e7f2b62b0bd2c2b5a24c9a63444f6a/src/interfaces/global.ts#L25) | null | Including only film types. eg. `['seriál', 'koncert']` |
330
+ | **exclude** | [CSFDFilmTypes[]](https://github.com/bartholomej/node-csfd-api/blob/8fa5f9cbc7e7f2b62b0bd2c2b5a24c9a63444f6a/src/interfaces/global.ts#L25) | null | Excluding film types eg. `['epizoda', 'série']` |
331
+ | **allPages** | boolean | false | Get all pages |
332
+ | **allPagesDelay** | number | 0 | Delay on each page request. In milliseconds |
335
333
 
336
334
  _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter 'includesOnly' has a priority._
337
335
 
@@ -373,7 +371,6 @@ _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter
373
371
  - [x] Premieres
374
372
  - [x] Related movies
375
373
  - [x] Similar movies
376
- - [x] Trivia
377
374
  - [ ] All images
378
375
  - [ ] Reviews
379
376
  - [ ] OST
@@ -39,7 +39,8 @@ const getBio = (el) => {
39
39
  };
40
40
  exports.getBio = getBio;
41
41
  const getPhoto = (el) => {
42
- return el.querySelector('img').attributes.src;
42
+ const image = el.querySelector('img').attributes.src;
43
+ return (0, global_helper_1.addProtocol)(image);
43
44
  };
44
45
  exports.getPhoto = getPhoto;
45
46
  const parseBirthday = (text) => {
@@ -3,3 +3,4 @@ import { Colors } from '../interfaces/user-ratings.interface';
3
3
  export declare const parseIdFromUrl: (url: string) => number;
4
4
  export declare const getColor: (cls: string) => CSFDColorRating;
5
5
  export declare const parseColor: (quality: Colors) => CSFDColorRating;
6
+ export declare const addProtocol: (url: string) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseColor = exports.getColor = exports.parseIdFromUrl = void 0;
3
+ exports.addProtocol = exports.parseColor = exports.getColor = exports.parseIdFromUrl = void 0;
4
4
  const parseIdFromUrl = (url) => {
5
5
  const idSlug = url.split('/')[2];
6
6
  const id = idSlug.split('-')[0];
@@ -37,3 +37,7 @@ const parseColor = (quality) => {
37
37
  }
38
38
  };
39
39
  exports.parseColor = parseColor;
40
+ const addProtocol = (url) => {
41
+ return url.startsWith('//') ? 'https:' + url : url;
42
+ };
43
+ exports.addProtocol = addProtocol;
@@ -8,14 +8,11 @@ export declare const getOrigins: (el: HTMLElement) => string[];
8
8
  export declare const getColorRating: (bodyClasses: string[]) => CSFDColorRating;
9
9
  export declare const getRating: (el: HTMLElement) => number;
10
10
  export declare const getRatingCount: (el: HTMLElement) => number;
11
- export declare const getYear: (el: HTMLElement) => string | number;
11
+ export declare const getYear: (el: string) => number;
12
12
  export declare const getDuration: (el: HTMLElement) => number;
13
13
  export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
14
14
  export declare const getPoster: (el: HTMLElement) => string;
15
- export declare const getRandomPhoto: (el: HTMLElement) => string;
16
- export declare const getTrivia: (el: HTMLElement) => string[];
17
15
  export declare const getDescriptions: (el: HTMLElement) => string[];
18
- export declare const getDirectors: (el: HTMLElement) => CSFDCreator[];
19
16
  export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
20
17
  export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
21
18
  export declare const getType: (el: HTMLElement) => string;
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getTrivia = exports.getRandomPhoto = exports.getPoster = exports.getTitlesOther = exports.getDuration = exports.getYear = exports.getRatingCount = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0;
3
+ exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = 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;
4
4
  const global_helper_1 = require("./global.helper");
5
5
  const getId = (el) => {
6
6
  const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;
@@ -50,7 +50,14 @@ const getRatingCount = (el) => {
50
50
  };
51
51
  exports.getRatingCount = getRatingCount;
52
52
  const getYear = (el) => {
53
- return el.querySelector('.origin span').innerText.replace(/[{()}]/g, '');
53
+ try {
54
+ const jsonLd = JSON.parse(el);
55
+ return +jsonLd.dateCreated;
56
+ }
57
+ catch (error) {
58
+ console.error('node-csfd-api: Error parsing JSON-LD', error);
59
+ return null;
60
+ }
54
61
  };
55
62
  exports.getYear = getYear;
56
63
  const getDuration = (el) => {
@@ -90,15 +97,16 @@ exports.getTitlesOther = getTitlesOther;
90
97
  const getPoster = (el) => {
91
98
  var _a;
92
99
  const poster = el.querySelector('.film-posters img');
100
+ // Resolve empty image
93
101
  if (poster) {
94
- // Resolve empty image
95
102
  if ((_a = poster.classNames) === null || _a === void 0 ? void 0 : _a.includes('empty-image')) {
96
103
  return null;
97
104
  }
98
105
  else {
99
106
  // Full sized image (not thumb)
100
107
  const imageThumb = poster.attributes.src.split('?')[0];
101
- return imageThumb.replace(/\/w140\//, '/w1080/');
108
+ const image = imageThumb.replace(/\/w140\//, '/w1080/');
109
+ return (0, global_helper_1.addProtocol)(image);
102
110
  }
103
111
  }
104
112
  else {
@@ -106,28 +114,6 @@ const getPoster = (el) => {
106
114
  }
107
115
  };
108
116
  exports.getPoster = getPoster;
109
- const getRandomPhoto = (el) => {
110
- var _a;
111
- const imageNode = el.querySelector('.gallery-item picture img');
112
- const image = (_a = imageNode === null || imageNode === void 0 ? void 0 : imageNode.attributes) === null || _a === void 0 ? void 0 : _a.src;
113
- if (image) {
114
- return image.replace(/\/w663\//, '/w1326/');
115
- }
116
- else {
117
- return null;
118
- }
119
- };
120
- exports.getRandomPhoto = getRandomPhoto;
121
- const getTrivia = (el) => {
122
- const triviaNodes = el.querySelectorAll('.article-trivia ul li');
123
- if (triviaNodes === null || triviaNodes === void 0 ? void 0 : triviaNodes.length) {
124
- return triviaNodes.map((node) => node.textContent.trim().replace(/(\r\n|\n|\r|\t)/gm, ''));
125
- }
126
- else {
127
- return null;
128
- }
129
- };
130
- exports.getTrivia = getTrivia;
131
117
  const getDescriptions = (el) => {
132
118
  var _a;
133
119
  // TODO more plots
@@ -136,12 +122,6 @@ const getDescriptions = (el) => {
136
122
  return plot ? [plot] : [];
137
123
  };
138
124
  exports.getDescriptions = getDescriptions;
139
- const getDirectors = (el) => {
140
- const creators = el.querySelectorAll('.creators span');
141
- const directorsSpan = creators.filter((creator) => creator.attributes.itemprop === 'director')[0];
142
- return (directorsSpan && (0, exports.parsePeople)(directorsSpan)) || [];
143
- };
144
- exports.getDirectors = getDirectors;
145
125
  const parsePeople = (el) => {
146
126
  const people = el.querySelectorAll('a');
147
127
  return (people
@@ -1,6 +1,7 @@
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 global_helper_1 = require("./global.helper");
4
5
  const getUser = (el) => {
5
6
  return el.querySelector('.user-title-name').text;
6
7
  };
@@ -11,7 +12,8 @@ const getUserRealName = (el) => {
11
12
  };
12
13
  exports.getUserRealName = getUserRealName;
13
14
  const getAvatar = (el) => {
14
- return el.querySelector('.article-img img').attributes.src;
15
+ const image = el.querySelector('.article-img img').attributes.src;
16
+ return (0, global_helper_1.addProtocol)(image);
15
17
  };
16
18
  exports.getAvatar = getAvatar;
17
19
  const getUserUrl = (el) => {
@@ -3,7 +3,7 @@ import { CSFDColorRating, CSFDFilmTypes } from '../interfaces/global';
3
3
  import { CSFDCreator } from '../interfaces/movie.interface';
4
4
  export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
5
5
  export declare const getTitle: (el: HTMLElement) => string;
6
- export declare const getYear: (el: HTMLElement) => string;
6
+ export declare const getYear: (el: HTMLElement) => number;
7
7
  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;
@@ -13,7 +13,7 @@ const getTitle = (el) => {
13
13
  exports.getTitle = getTitle;
14
14
  const getYear = (el) => {
15
15
  var _a;
16
- return (_a = el.querySelectorAll('.film-title-info .info')[0]) === null || _a === void 0 ? void 0 : _a.innerText.replace(/[{()}]/g, '');
16
+ return +((_a = el.querySelectorAll('.film-title-info .info')[0]) === null || _a === void 0 ? void 0 : _a.innerText.replace(/[{()}]/g, ''));
17
17
  };
18
18
  exports.getYear = getYear;
19
19
  const getUrl = (el) => {
@@ -25,14 +25,15 @@ const getColorRating = (el) => {
25
25
  };
26
26
  exports.getColorRating = getColorRating;
27
27
  const getPoster = (el) => {
28
- return el.querySelector('img').attributes.src;
28
+ const image = el.querySelector('img').attributes.src;
29
+ return (0, global_helper_1.addProtocol)(image);
29
30
  };
30
31
  exports.getPoster = getPoster;
31
32
  const getOrigins = (el) => {
33
+ var _a;
32
34
  const originsRaw = el.querySelector('.article-content p .info').text;
33
- const origins = originsRaw === null || originsRaw === void 0 ? void 0 : originsRaw.split(', ');
34
- origins.pop();
35
- return origins;
35
+ const originsAll = (_a = originsRaw === null || originsRaw === void 0 ? void 0 : originsRaw.split(', ')) === null || _a === void 0 ? void 0 : _a[0];
36
+ return originsAll === null || originsAll === void 0 ? void 0 : originsAll.split('/').map((country) => country.trim());
36
37
  };
37
38
  exports.getOrigins = getOrigins;
38
39
  const parsePeople = (el, type) => {
@@ -1,7 +1,7 @@
1
1
  export interface CSFDScreening {
2
2
  id: number;
3
3
  title: string;
4
- year: number | string;
4
+ year: number;
5
5
  url: string;
6
6
  type: CSFDFilmTypes;
7
7
  /**
@@ -19,4 +19,4 @@ export interface CSFDScreening {
19
19
  }
20
20
  export declare type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown';
21
21
  export declare type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5;
22
- export declare type CSFDFilmTypes = 'film' | 'TV film' | 'TV pořad' | 'TV seriál' | 'divadelní záznam' | 'koncert' | 'série' | 'studentský film' | 'amatérský film' | 'hudební videoklip' | 'epizoda';
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';
@@ -2,13 +2,11 @@ import { CSFDScreening } from './global';
2
2
  export interface CSFDMovie extends CSFDScreening {
3
3
  rating: number | null;
4
4
  poster: string;
5
- photo: string;
6
5
  ratingCount: number | null;
7
6
  duration: number | string;
8
7
  titlesOther: CSFDTitlesOther[];
9
8
  origins: string[];
10
9
  descriptions: string[];
11
- trivia: string[];
12
10
  genres: CSFDGenres[] | string[];
13
11
  creators: CSFDCreators;
14
12
  vod: CSFDVod[];
@@ -18,7 +16,7 @@ export interface CSFDMovie extends CSFDScreening {
18
16
  similar: CSFDMovieListItem[];
19
17
  }
20
18
  export interface CSFDVod {
21
- title: 'Netflix' | 'hbogo' | 'Primve Video' | 'Apple TV+' | 'ivysilani' | 'Aerovod' | 'o2tv' | 'Voyo' | 'FILMY ČESKY A ZADARMO' | 'VAPET' | 'VOREL FILM' | string;
19
+ 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
20
  url: string;
23
21
  }
24
22
  export interface CSFDCreators {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "1.11.0-beta.1",
4
- "description": "Simple NPM library for scraping CSFD",
3
+ "version": "2.0.1",
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
  "scripts": {
@@ -16,14 +16,13 @@
16
16
  "publish:next": "yarn && yarn build && yarn test --coverage true && npm publish --folder dist --tag beta",
17
17
  "postversion": "git push && git push --follow-tags",
18
18
  "release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
19
- "prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
20
19
  "release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
21
20
  "release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
22
21
  "release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
23
22
  },
24
23
  "dependencies": {
25
24
  "cross-fetch": "^3.1.4",
26
- "node-html-parser": "^5.1.0"
25
+ "node-html-parser": "^5.2.0"
27
26
  },
28
27
  "repository": {
29
28
  "url": "git+https://github.com/bartholomej/node-csfd-api.git",
@@ -47,7 +46,7 @@
47
46
  "api"
48
47
  ],
49
48
  "engines": {
50
- "node": ">= 10"
49
+ "node": ">= 12"
51
50
  },
52
51
  "license": "MIT",
53
52
  "module": "./index.js",
@@ -13,14 +13,15 @@ class MovieScraper {
13
13
  const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');
14
14
  const asideNode = movieHtml.querySelector('.aside-movie-profile');
15
15
  const movieNode = movieHtml.querySelector('.main-movie-profile');
16
- this.buildMovie(+movieId, movieNode, asideNode, pageClasses);
16
+ const jsonLd = movieHtml.querySelector('script[type="application/ld+json"]').innerText;
17
+ this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
17
18
  return this.film;
18
19
  }
19
- buildMovie(movieId, el, asideEl, pageClasses) {
20
+ buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
20
21
  this.film = {
21
22
  id: movieId,
22
23
  title: (0, movie_helper_1.getTitle)(el),
23
- year: (0, movie_helper_1.getYear)(el),
24
+ year: (0, movie_helper_1.getYear)(jsonLd),
24
25
  duration: (0, movie_helper_1.getDuration)(el),
25
26
  descriptions: (0, movie_helper_1.getDescriptions)(el),
26
27
  genres: (0, movie_helper_1.getGenres)(el),
@@ -32,10 +33,8 @@ class MovieScraper {
32
33
  ratingCount: (0, movie_helper_1.getRatingCount)(asideEl),
33
34
  titlesOther: (0, movie_helper_1.getTitlesOther)(el),
34
35
  poster: (0, movie_helper_1.getPoster)(el),
35
- photo: (0, movie_helper_1.getRandomPhoto)(el),
36
- trivia: (0, movie_helper_1.getTrivia)(el),
37
36
  creators: {
38
- directors: (0, movie_helper_1.getDirectors)(el),
37
+ directors: (0, movie_helper_1.getGroup)(el, 'Režie'),
39
38
  writers: (0, movie_helper_1.getGroup)(el, 'Scénář'),
40
39
  cinematography: (0, movie_helper_1.getGroup)(el, 'Kamera'),
41
40
  music: (0, movie_helper_1.getGroup)(el, 'Hudba'),
package/vars.js CHANGED
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.searchUrl = exports.creatorUrl = exports.movieUrl = exports.userRatingsUrl = void 0;
4
4
  const userRatingsUrl = (user, page) => `https://www.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/${page ? '?page=' + page : ''}`;
5
5
  exports.userRatingsUrl = userRatingsUrl;
6
- const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}/prehled/`;
6
+ const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}`;
7
7
  exports.movieUrl = movieUrl;
8
8
  const creatorUrl = (creator) => `https://www.csfd.cz/tvurce/${encodeURIComponent(creator)}`;
9
9
  exports.creatorUrl = creatorUrl;