node-csfd-api 1.11.0-beta.0 → 2.0.0
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 +36 -36
- package/helpers/creator.helper.js +2 -1
- package/helpers/global.helper.d.ts +1 -0
- package/helpers/global.helper.js +5 -1
- package/helpers/movie.helper.d.ts +1 -3
- package/helpers/movie.helper.js +12 -22
- package/helpers/search-user.helper.js +3 -1
- package/helpers/search.helper.d.ts +1 -1
- package/helpers/search.helper.js +6 -5
- package/interfaces/global.d.ts +2 -2
- package/interfaces/movie.interface.d.ts +1 -2
- package/package.json +3 -3
- package/services/movie.service.js +5 -5
- package/vars.js +1 -1
package/README.md
CHANGED
|
@@ -5,33 +5,33 @@
|
|
|
5
5
|
|
|
6
6
|
# CSFD API 2021
|
|
7
7
|
|
|
8
|
-
>
|
|
8
|
+
> JavaScript NPM library for scraping **Czech Movie Database (csfd.cz)**
|
|
9
9
|
>
|
|
10
10
|
> - Browser + Node.js (SSR)
|
|
11
|
-
> - TypeScript
|
|
12
|
-
> -
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
>
|
|
17
|
-
>
|
|
18
|
-
>
|
|
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
|
-
|
|
24
|
+
npm install node-csfd-api --save
|
|
25
|
+
# yarn add node-csfd-api
|
|
26
26
|
```
|
|
27
27
|
|
|
28
|
-
|
|
28
|
+
## Usage and examples
|
|
29
29
|
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
30
|
+
- [Movies and TV Series](#Movie)
|
|
31
|
+
- [User Ratings](#User-Ratings)
|
|
32
|
+
- [Search](#Search)
|
|
33
33
|
|
|
34
|
-
|
|
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
|
-
|
|
44
|
+
#### Results
|
|
45
45
|
|
|
46
46
|
```javascript
|
|
47
47
|
{
|
|
@@ -66,7 +66,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
|
|
|
66
66
|
{ country: 'Austrálie', title: 'Dragged Across Concrete' },
|
|
67
67
|
{ country: 'Velká Británie', title: 'Dragged Across Concrete' }
|
|
68
68
|
],
|
|
69
|
-
poster: '
|
|
69
|
+
poster: 'https://image.pmgstatic.com/cache/resized/w1080/files/images/film/posters/163/579/163579352_bf8737.jpg',
|
|
70
70
|
creators: {
|
|
71
71
|
directors: [
|
|
72
72
|
{
|
|
@@ -133,7 +133,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
|
|
|
133
133
|
}
|
|
134
134
|
```
|
|
135
135
|
|
|
136
|
-
|
|
136
|
+
### Search
|
|
137
137
|
|
|
138
138
|
> Search movies and users
|
|
139
139
|
|
|
@@ -143,7 +143,7 @@ import { csfd } from 'node-csfd-api';
|
|
|
143
143
|
csfd.search('bart').then((search) => console.log(search));
|
|
144
144
|
```
|
|
145
145
|
|
|
146
|
-
|
|
146
|
+
#### Results
|
|
147
147
|
|
|
148
148
|
```javascript
|
|
149
149
|
movies: [
|
|
@@ -175,13 +175,13 @@ users: [
|
|
|
175
175
|
id: 912,
|
|
176
176
|
user: 'BART!',
|
|
177
177
|
userRealName: 'Lukáš Barták',
|
|
178
|
-
avatar: '
|
|
178
|
+
avatar: 'https://image.pmgstatic.com/cache/resized/w45h60/files/images/user/avatars/000/281/281554_1c0fef.jpg',
|
|
179
179
|
url: 'https://www.csfd.cz/uzivatel/912-bart/'
|
|
180
180
|
}
|
|
181
181
|
]
|
|
182
182
|
```
|
|
183
183
|
|
|
184
|
-
|
|
184
|
+
### Creators
|
|
185
185
|
|
|
186
186
|
> Search creators and filmography
|
|
187
187
|
|
|
@@ -191,7 +191,7 @@ import { csfd } from 'node-csfd-api';
|
|
|
191
191
|
csfd.creator(2120).then((creator) => console.log(creator));
|
|
192
192
|
```
|
|
193
193
|
|
|
194
|
-
|
|
194
|
+
#### Results
|
|
195
195
|
|
|
196
196
|
```javascript
|
|
197
197
|
{
|
|
@@ -199,7 +199,7 @@ csfd.creator(2120).then((creator) => console.log(creator));
|
|
|
199
199
|
name: 'Quentin Tarantino',
|
|
200
200
|
birthday: '27.03.1963',
|
|
201
201
|
birthplace: 'Knoxville, Tennessee, USA',
|
|
202
|
-
photo: '
|
|
202
|
+
photo: 'https://image.pmgstatic.com/cache/resized/w100h132crop/files/images/creator/photos/164/515/164515525_b98f8a.jpg',
|
|
203
203
|
age: 58,
|
|
204
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…',
|
|
205
205
|
films: [
|
|
@@ -268,9 +268,9 @@ csfd.creator(2120).then((creator) => console.log(creator));
|
|
|
268
268
|
}
|
|
269
269
|
```
|
|
270
270
|
|
|
271
|
-
|
|
271
|
+
### User Ratings
|
|
272
272
|
|
|
273
|
-
|
|
273
|
+
#### Last ratings (last page)
|
|
274
274
|
|
|
275
275
|
Get [my last 50 ratings](https://www.csfd.cz/uzivatel/912-bart/hodnoceni/)
|
|
276
276
|
|
|
@@ -280,7 +280,7 @@ import { csfd } from 'node-csfd-api';
|
|
|
280
280
|
csfd.userRatings('912-bart').then((ratings) => console.log(ratings));
|
|
281
281
|
```
|
|
282
282
|
|
|
283
|
-
|
|
283
|
+
#### All ratings (all pages)
|
|
284
284
|
|
|
285
285
|
> Warning: Use it wisely. Can be detected and banned. Consider using it together with `allPagesDelay` attribute.
|
|
286
286
|
|
|
@@ -297,7 +297,7 @@ csfd
|
|
|
297
297
|
.then((ratings) => console.log(ratings));
|
|
298
298
|
```
|
|
299
299
|
|
|
300
|
-
|
|
300
|
+
#### Results
|
|
301
301
|
|
|
302
302
|
```javascript
|
|
303
303
|
[
|
|
@@ -322,14 +322,14 @@ csfd
|
|
|
322
322
|
];
|
|
323
323
|
```
|
|
324
324
|
|
|
325
|
-
|
|
325
|
+
#### Options
|
|
326
326
|
|
|
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. `['
|
|
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
|
|
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 |
|
|
333
333
|
|
|
334
334
|
_Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter 'includesOnly' has a priority._
|
|
335
335
|
|
|
@@ -39,7 +39,8 @@ const getBio = (el) => {
|
|
|
39
39
|
};
|
|
40
40
|
exports.getBio = getBio;
|
|
41
41
|
const getPhoto = (el) => {
|
|
42
|
-
|
|
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;
|
package/helpers/global.helper.js
CHANGED
|
@@ -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,13 +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:
|
|
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
15
|
export declare const getDescriptions: (el: HTMLElement) => string[];
|
|
17
|
-
export declare const getDirectors: (el: HTMLElement) => CSFDCreator[];
|
|
18
16
|
export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
|
|
19
17
|
export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
|
|
20
18
|
export declare const getType: (el: HTMLElement) => string;
|
package/helpers/movie.helper.js
CHANGED
|
@@ -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.
|
|
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
|
-
|
|
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
|
-
|
|
108
|
+
const image = imageThumb.replace(/\/w140\//, '/w1080/');
|
|
109
|
+
return (0, global_helper_1.addProtocol)(image);
|
|
102
110
|
}
|
|
103
111
|
}
|
|
104
112
|
else {
|
|
@@ -106,18 +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
117
|
const getDescriptions = (el) => {
|
|
122
118
|
var _a;
|
|
123
119
|
// TODO more plots
|
|
@@ -126,12 +122,6 @@ const getDescriptions = (el) => {
|
|
|
126
122
|
return plot ? [plot] : [];
|
|
127
123
|
};
|
|
128
124
|
exports.getDescriptions = getDescriptions;
|
|
129
|
-
const getDirectors = (el) => {
|
|
130
|
-
const creators = el.querySelectorAll('.creators span');
|
|
131
|
-
const directorsSpan = creators.filter((creator) => creator.attributes.itemprop === 'director')[0];
|
|
132
|
-
return (directorsSpan && (0, exports.parsePeople)(directorsSpan)) || [];
|
|
133
|
-
};
|
|
134
|
-
exports.getDirectors = getDirectors;
|
|
135
125
|
const parsePeople = (el) => {
|
|
136
126
|
const people = el.querySelectorAll('a');
|
|
137
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
|
-
|
|
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) =>
|
|
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;
|
package/helpers/search.helper.js
CHANGED
|
@@ -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
|
-
|
|
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
|
|
34
|
-
|
|
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) => {
|
package/interfaces/global.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export interface CSFDScreening {
|
|
2
2
|
id: number;
|
|
3
3
|
title: string;
|
|
4
|
-
year: number
|
|
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' | '
|
|
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,7 +2,6 @@ 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[];
|
|
@@ -17,7 +16,7 @@ export interface CSFDMovie extends CSFDScreening {
|
|
|
17
16
|
similar: CSFDMovieListItem[];
|
|
18
17
|
}
|
|
19
18
|
export interface CSFDVod {
|
|
20
|
-
title: 'Netflix' | 'hbogo' | '
|
|
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;
|
|
21
20
|
url: string;
|
|
22
21
|
}
|
|
23
22
|
export interface CSFDCreators {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "
|
|
4
|
-
"description": "
|
|
3
|
+
"version": "2.0.0",
|
|
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": {
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
"api"
|
|
47
47
|
],
|
|
48
48
|
"engines": {
|
|
49
|
-
"node": ">=
|
|
49
|
+
"node": ">= 12"
|
|
50
50
|
},
|
|
51
51
|
"license": "MIT",
|
|
52
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
|
-
|
|
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)(
|
|
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,9 +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
36
|
creators: {
|
|
37
|
-
directors: (0, movie_helper_1.
|
|
37
|
+
directors: (0, movie_helper_1.getGroup)(el, 'Režie'),
|
|
38
38
|
writers: (0, movie_helper_1.getGroup)(el, 'Scénář'),
|
|
39
39
|
cinematography: (0, movie_helper_1.getGroup)(el, 'Kamera'),
|
|
40
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)}
|
|
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;
|