node-csfd-api 3.0.0-next.26 → 3.0.0-next.28
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/cjs/fetchers/{index.js → fetchers.js} +2 -2
- package/cjs/helpers/cinema.helper.js +9 -7
- package/cjs/helpers/creator.helper.js +34 -35
- package/cjs/helpers/global.helper.js +12 -1
- package/cjs/helpers/movie.helper.js +85 -9
- package/cjs/helpers/search-user.helper.js +9 -4
- package/cjs/helpers/search.helper.js +6 -5
- package/cjs/helpers/user-ratings.helper.js +2 -2
- package/cjs/index.js +10 -10
- package/cjs/services/cinema.service.js +10 -10
- package/cjs/services/creator.service.js +16 -12
- package/cjs/services/movie.service.js +48 -35
- package/cjs/services/search.service.js +32 -32
- package/cjs/services/user-ratings.service.js +17 -17
- package/cjs/types.js +22 -0
- package/esm/fetchers/{index.js → fetchers.js} +1 -1
- package/esm/helpers/cinema.helper.js +9 -7
- package/esm/helpers/creator.helper.js +34 -35
- package/esm/helpers/global.helper.js +10 -0
- package/esm/helpers/movie.helper.js +73 -2
- package/esm/helpers/search-user.helper.js +8 -3
- package/esm/helpers/search.helper.js +3 -2
- package/esm/helpers/user-ratings.helper.js +1 -1
- package/esm/index.js +5 -5
- package/esm/services/cinema.service.js +3 -3
- package/esm/services/creator.service.js +8 -4
- package/esm/services/movie.service.js +21 -8
- package/esm/services/search.service.js +5 -5
- package/esm/services/user-ratings.service.js +3 -3
- package/esm/types.js +6 -0
- package/index.dto.d.ts +8 -7
- package/package.json +1 -1
- package/types/{interfaces/cinema.interface.d.ts → dto/cinema.d.ts} +1 -1
- package/types/{interfaces/movie.interface.d.ts → dto/movie.d.ts} +22 -1
- package/types/{interfaces/search.interface.d.ts → dto/search.d.ts} +1 -1
- package/types/helpers/cinema.helper.d.ts +4 -4
- package/types/helpers/creator.helper.d.ts +5 -5
- package/types/helpers/global.helper.d.ts +3 -2
- package/types/helpers/movie.helper.d.ts +16 -2
- package/types/helpers/search.helper.d.ts +2 -2
- package/types/helpers/user-ratings.helper.d.ts +1 -1
- package/types/index.d.ts +10 -10
- package/types/services/cinema.service.d.ts +1 -1
- package/types/services/creator.service.d.ts +1 -1
- package/types/services/movie.service.d.ts +1 -1
- package/types/services/search.service.d.ts +1 -1
- package/types/services/user-ratings.service.d.ts +1 -1
- package/types/types.d.ts +6 -0
- package/types/vars.d.ts +1 -1
- /package/cjs/{interfaces/cinema.interface.js → dto/cinema.js} +0 -0
- /package/cjs/{interfaces/creator.interface.js → dto/creator.js} +0 -0
- /package/cjs/{interfaces → dto}/global.js +0 -0
- /package/cjs/{interfaces/movie.interface.js → dto/movie.js} +0 -0
- /package/cjs/{interfaces/search.interface.js → dto/search.js} +0 -0
- /package/cjs/{interfaces/user-ratings.interface.js → dto/user-ratings.js} +0 -0
- /package/esm/{interfaces/cinema.interface.js → dto/cinema.js} +0 -0
- /package/esm/{interfaces/creator.interface.js → dto/creator.js} +0 -0
- /package/esm/{interfaces → dto}/global.js +0 -0
- /package/esm/{interfaces/movie.interface.js → dto/movie.js} +0 -0
- /package/esm/{interfaces/search.interface.js → dto/search.js} +0 -0
- /package/esm/{interfaces/user-ratings.interface.js → dto/user-ratings.js} +0 -0
- /package/types/{interfaces/creator.interface.d.ts → dto/creator.d.ts} +0 -0
- /package/types/{interfaces → dto}/global.d.ts +0 -0
- /package/types/{interfaces/user-ratings.interface.d.ts → dto/user-ratings.d.ts} +0 -0
- /package/types/fetchers/{index.d.ts → fetchers.d.ts} +0 -0
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.fetchPage = void 0;
|
|
13
|
-
const
|
|
13
|
+
const fetch_polyfill_js_1 = require("./fetch.polyfill.js");
|
|
14
14
|
const USER_AGENTS = [
|
|
15
15
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
|
16
16
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1',
|
|
@@ -22,7 +22,7 @@ const headers = {
|
|
|
22
22
|
};
|
|
23
23
|
const fetchPage = (url) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
24
|
try {
|
|
25
|
-
const response = yield (0,
|
|
25
|
+
const response = yield (0, fetch_polyfill_js_1.fetchSafe)(url, { headers });
|
|
26
26
|
if (response.status >= 400 && response.status < 600) {
|
|
27
27
|
throw new Error(`node-csfd-api: Bad response ${response.status} for url: ${url}`);
|
|
28
28
|
}
|
|
@@ -1,9 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseMeta = exports.getCinemaFilms = exports.getGroupedFilmsByDate = exports.parseCinema = exports.getCinemaUrl = exports.getCinemaCoords = exports.getCinemaUrlId = exports.getCinemaId = exports.getCinemaColorRating = void 0;
|
|
4
|
-
const
|
|
4
|
+
const global_helper_js_1 = require("./global.helper.js");
|
|
5
5
|
const getCinemaColorRating = (el) => {
|
|
6
|
-
|
|
6
|
+
var _a;
|
|
7
|
+
const classes = (_a = el === null || el === void 0 ? void 0 : el.classNames.split(' ')) !== null && _a !== void 0 ? _a : [];
|
|
8
|
+
const last = classes.length ? classes[classes.length - 1] : undefined;
|
|
9
|
+
return last ? (0, global_helper_js_1.parseColor)(last) : 'unknown';
|
|
7
10
|
};
|
|
8
11
|
exports.getCinemaColorRating = getCinemaColorRating;
|
|
9
12
|
const getCinemaId = (el) => {
|
|
@@ -13,10 +16,9 @@ const getCinemaId = (el) => {
|
|
|
13
16
|
};
|
|
14
17
|
exports.getCinemaId = getCinemaId;
|
|
15
18
|
const getCinemaUrlId = (url) => {
|
|
16
|
-
if (url)
|
|
17
|
-
return
|
|
18
|
-
|
|
19
|
-
return null;
|
|
19
|
+
if (!url)
|
|
20
|
+
return null;
|
|
21
|
+
return (0, global_helper_js_1.parseIdFromUrl)(url);
|
|
20
22
|
};
|
|
21
23
|
exports.getCinemaUrlId = getCinemaUrlId;
|
|
22
24
|
const getCinemaCoords = (el) => {
|
|
@@ -70,7 +72,7 @@ const getCinemaFilms = (date, el) => {
|
|
|
70
72
|
const films = filmNodes.map((filmNode) => {
|
|
71
73
|
var _a, _b, _c, _d;
|
|
72
74
|
const url = (_a = filmNode.querySelector('td.name h3 a')) === null || _a === void 0 ? void 0 : _a.attributes.href;
|
|
73
|
-
const id = (0, exports.getCinemaUrlId)(url);
|
|
75
|
+
const id = url ? (0, exports.getCinemaUrlId)(url) : null;
|
|
74
76
|
const title = (_b = filmNode.querySelector('.name h3')) === null || _b === void 0 ? void 0 : _b.text.trim();
|
|
75
77
|
const colorRating = (0, exports.getCinemaColorRating)(filmNode.querySelector('.name .icon'));
|
|
76
78
|
const showTimes = (_c = filmNode.querySelectorAll('.td-time')) === null || _c === void 0 ? void 0 : _c.map((x) => x.textContent.trim());
|
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getCreatorFilms = exports.getCreatorPhoto = exports.getCreatorBio = exports.getCreatorBirthdayInfo = exports.getCreatorName = exports.getCreatorId = void 0;
|
|
4
|
-
const
|
|
4
|
+
const global_helper_js_1 = require("./global.helper.js");
|
|
5
5
|
const getCreatorColorRating = (el) => {
|
|
6
|
-
|
|
6
|
+
var _a;
|
|
7
|
+
const classes = (_a = el === null || el === void 0 ? void 0 : el.classNames.split(' ')) !== null && _a !== void 0 ? _a : [];
|
|
8
|
+
const last = classes[classes.length - 1];
|
|
9
|
+
return (0, global_helper_js_1.parseColor)(last);
|
|
7
10
|
};
|
|
8
11
|
const getCreatorId = (url) => {
|
|
9
|
-
|
|
10
|
-
return (0, global_helper_1.parseIdFromUrl)(url);
|
|
11
|
-
}
|
|
12
|
-
return null;
|
|
12
|
+
return url ? (0, global_helper_js_1.parseIdFromUrl)(url) : null;
|
|
13
13
|
};
|
|
14
14
|
exports.getCreatorId = getCreatorId;
|
|
15
15
|
const getCreatorName = (el) => {
|
|
16
|
-
|
|
16
|
+
var _a, _b;
|
|
17
|
+
const h1 = el === null || el === void 0 ? void 0 : el.querySelector('h1');
|
|
18
|
+
return (_b = (_a = h1 === null || h1 === void 0 ? void 0 : h1.innerText) === null || _a === void 0 ? void 0 : _a.trim()) !== null && _b !== void 0 ? _b : null;
|
|
17
19
|
};
|
|
18
20
|
exports.getCreatorName = getCreatorName;
|
|
19
21
|
const getCreatorBirthdayInfo = (el) => {
|
|
@@ -34,50 +36,47 @@ const getCreatorBirthdayInfo = (el) => {
|
|
|
34
36
|
};
|
|
35
37
|
exports.getCreatorBirthdayInfo = getCreatorBirthdayInfo;
|
|
36
38
|
const getCreatorBio = (el) => {
|
|
37
|
-
var _a;
|
|
38
|
-
|
|
39
|
+
var _a, _b;
|
|
40
|
+
const p = el === null || el === void 0 ? void 0 : el.querySelector('.article-content p');
|
|
41
|
+
const first = (_b = (_a = p === null || p === void 0 ? void 0 : p.text) === null || _a === void 0 ? void 0 : _a.trim().split('\n')[0]) === null || _b === void 0 ? void 0 : _b.trim();
|
|
42
|
+
return first || null;
|
|
39
43
|
};
|
|
40
44
|
exports.getCreatorBio = getCreatorBio;
|
|
41
45
|
const getCreatorPhoto = (el) => {
|
|
42
|
-
|
|
43
|
-
|
|
46
|
+
var _a;
|
|
47
|
+
const src = (_a = el === null || el === void 0 ? void 0 : el.querySelector('img')) === null || _a === void 0 ? void 0 : _a.getAttribute('src');
|
|
48
|
+
return src ? (0, global_helper_js_1.addProtocol)(src) : null;
|
|
44
49
|
};
|
|
45
50
|
exports.getCreatorPhoto = getCreatorPhoto;
|
|
46
|
-
const parseBirthday = (text) =>
|
|
47
|
-
return text.replace(/nar./g, '').trim();
|
|
48
|
-
};
|
|
51
|
+
const parseBirthday = (text) => text.replace(/nar\./g, '').trim();
|
|
49
52
|
const parseAge = (text) => {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
const parseBirthPlace = (text) => {
|
|
53
|
-
return text.trim().replace(/<br>/g, '').trim();
|
|
53
|
+
const digits = text.replace(/[^\d]/g, '');
|
|
54
|
+
return digits ? Number(digits) : null;
|
|
54
55
|
};
|
|
56
|
+
const parseBirthPlace = (text) => text.trim().replace(/<br>/g, '').trim();
|
|
55
57
|
const getCreatorFilms = (el) => {
|
|
56
|
-
var _a;
|
|
57
|
-
const filmNodes = (_a = el.querySelectorAll('.box')[0]) === null ||
|
|
58
|
-
let yearCache;
|
|
58
|
+
var _a, _b, _c;
|
|
59
|
+
const filmNodes = (_c = (_b = (_a = el === null || el === void 0 ? void 0 : el.querySelectorAll('.box')) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.querySelectorAll('table tr')) !== null && _c !== void 0 ? _c : [];
|
|
60
|
+
let yearCache = null;
|
|
59
61
|
const films = filmNodes.map((filmNode) => {
|
|
60
|
-
var _a, _b, _c;
|
|
61
|
-
const id = (0, exports.getCreatorId)((_a = filmNode.querySelector('td.name .film-title-name')) === null || _a === void 0 ? void 0 : _a.attributes.href);
|
|
62
|
-
const title = (
|
|
63
|
-
const
|
|
62
|
+
var _a, _b, _c, _d, _e, _f;
|
|
63
|
+
const id = (0, exports.getCreatorId)((_b = (_a = filmNode.querySelector('td.name .film-title-name')) === null || _a === void 0 ? void 0 : _a.attributes) === null || _b === void 0 ? void 0 : _b.href);
|
|
64
|
+
const title = (_d = (_c = filmNode.querySelector('.name')) === null || _c === void 0 ? void 0 : _c.text) === null || _d === void 0 ? void 0 : _d.trim();
|
|
65
|
+
const yearText = (_f = (_e = filmNode.querySelector('.year')) === null || _e === void 0 ? void 0 : _e.text) === null || _f === void 0 ? void 0 : _f.trim();
|
|
66
|
+
const year = yearText ? +yearText : null;
|
|
64
67
|
const colorRating = getCreatorColorRating(filmNode.querySelector('.name .icon'));
|
|
65
68
|
// Cache year from previous film because there is a gap between movies with same year
|
|
66
|
-
if (year) {
|
|
69
|
+
if (typeof year === 'number' && !isNaN(year)) {
|
|
67
70
|
yearCache = +year;
|
|
68
71
|
}
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
title,
|
|
73
|
-
year: year || yearCache,
|
|
74
|
-
colorRating
|
|
75
|
-
};
|
|
72
|
+
const finalYear = year !== null && year !== void 0 ? year : yearCache;
|
|
73
|
+
if (id != null && title && finalYear != null) {
|
|
74
|
+
return { id, title, year: finalYear, colorRating };
|
|
76
75
|
}
|
|
77
|
-
return
|
|
76
|
+
return null;
|
|
78
77
|
});
|
|
79
78
|
// Remove empty objects
|
|
80
|
-
const filmsUnique = films.filter(
|
|
79
|
+
const filmsUnique = films.filter(Boolean);
|
|
81
80
|
return filmsUnique;
|
|
82
81
|
};
|
|
83
82
|
exports.getCreatorFilms = getCreatorFilms;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseISO8601Duration = exports.getDuration = exports.addProtocol = exports.parseColor = exports.getColor = exports.parseIdFromUrl = void 0;
|
|
3
|
+
exports.parseISO8601Duration = exports.getDuration = exports.addProtocol = exports.parseColor = exports.getColor = exports.parseLastIdFromUrl = exports.parseIdFromUrl = void 0;
|
|
4
4
|
const parseIdFromUrl = (url) => {
|
|
5
5
|
if (url) {
|
|
6
6
|
const idSlug = url === null || url === void 0 ? void 0 : url.split('/')[2];
|
|
@@ -12,6 +12,17 @@ const parseIdFromUrl = (url) => {
|
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
14
|
exports.parseIdFromUrl = parseIdFromUrl;
|
|
15
|
+
const parseLastIdFromUrl = (url) => {
|
|
16
|
+
if (url) {
|
|
17
|
+
const idSlug = url === null || url === void 0 ? void 0 : url.split('/')[3];
|
|
18
|
+
const id = idSlug === null || idSlug === void 0 ? void 0 : idSlug.split('-')[0];
|
|
19
|
+
return +id || null;
|
|
20
|
+
}
|
|
21
|
+
else {
|
|
22
|
+
return null;
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
exports.parseLastIdFromUrl = parseLastIdFromUrl;
|
|
15
26
|
const getColor = (cls) => {
|
|
16
27
|
switch (cls) {
|
|
17
28
|
case 'page-lightgrey':
|
|
@@ -1,12 +1,27 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getMovieTags = exports.getMoviePremieres = exports.getMovieBoxMovies = exports.getMovieVods = exports.getMovieType = exports.getMovieGroup = exports.getMovieDescriptions = exports.getMovieTrivia = exports.getMovieRandomPhoto = exports.getMoviePoster = exports.getMovieTitlesOther = exports.getMovieDuration = exports.getMovieYear = exports.getMovieRatingCount = exports.getMovieRating = exports.getMovieColorRating = exports.getMovieOrigins = exports.getMovieGenres = exports.getMovieTitle = exports.getMovieId = void 0;
|
|
4
|
-
const
|
|
3
|
+
exports.getMovieTags = exports.getMoviePremieres = exports.getMovieBoxMovies = exports.getMovieVods = exports.getMovieType = exports.getMovieGroup = exports.getSeasonorEpisodeParent = exports.detectSeasonOrEpisodeListType = exports.getEpisodeCode = exports.getSeasonsOrEpisodes = exports.getMovieDescriptions = exports.getMovieTrivia = exports.getMovieRandomPhoto = exports.getMoviePoster = exports.getMovieTitlesOther = exports.getMovieDuration = exports.getMovieYear = exports.getMovieRatingCount = exports.getMovieRating = exports.getMovieColorRating = exports.getMovieOrigins = exports.getMovieGenres = exports.getMovieTitle = exports.getSerieasAndSeasonTitle = exports.getMovieId = void 0;
|
|
4
|
+
const global_helper_js_1 = require("./global.helper.js");
|
|
5
5
|
const getMovieId = (el) => {
|
|
6
6
|
const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, global_helper_js_1.parseIdFromUrl)(url);
|
|
8
8
|
};
|
|
9
9
|
exports.getMovieId = getMovieId;
|
|
10
|
+
const getSerieasAndSeasonTitle = (el) => {
|
|
11
|
+
const titleElement = el.querySelector('h1');
|
|
12
|
+
if (!titleElement) {
|
|
13
|
+
return { seriesName: null, seasonName: null };
|
|
14
|
+
}
|
|
15
|
+
const fullText = titleElement.innerText.trim();
|
|
16
|
+
// Check if there's a series part indicated by ' - '
|
|
17
|
+
if (fullText.includes(' - ')) {
|
|
18
|
+
const [seriesName, seasonName] = fullText.split(' - ').map(part => part.trim());
|
|
19
|
+
return { seriesName, seasonName };
|
|
20
|
+
}
|
|
21
|
+
// If no series part found, return just the name
|
|
22
|
+
return { seriesName: fullText, seasonName: null };
|
|
23
|
+
};
|
|
24
|
+
exports.getSerieasAndSeasonTitle = getSerieasAndSeasonTitle;
|
|
10
25
|
const getMovieTitle = (el) => {
|
|
11
26
|
return el.querySelector('h1').innerText.split(`(`)[0].trim();
|
|
12
27
|
};
|
|
@@ -23,7 +38,7 @@ const getMovieOrigins = (el) => {
|
|
|
23
38
|
};
|
|
24
39
|
exports.getMovieOrigins = getMovieOrigins;
|
|
25
40
|
const getMovieColorRating = (bodyClasses) => {
|
|
26
|
-
return (0,
|
|
41
|
+
return (0, global_helper_js_1.getColor)(bodyClasses[1]);
|
|
27
42
|
};
|
|
28
43
|
exports.getMovieColorRating = getMovieColorRating;
|
|
29
44
|
const getMovieRating = (el) => {
|
|
@@ -66,7 +81,7 @@ const getMovieDuration = (jsonLdRaw, el) => {
|
|
|
66
81
|
try {
|
|
67
82
|
const jsonLd = JSON.parse(jsonLdRaw);
|
|
68
83
|
duration = jsonLd.duration;
|
|
69
|
-
return (0,
|
|
84
|
+
return (0, global_helper_js_1.parseISO8601Duration)(duration);
|
|
70
85
|
}
|
|
71
86
|
catch (error) {
|
|
72
87
|
const origin = el.querySelector('.origin').innerText;
|
|
@@ -122,7 +137,7 @@ const getMoviePoster = (el) => {
|
|
|
122
137
|
// Full sized image (not thumb)
|
|
123
138
|
const imageThumb = poster.attributes.src.split('?')[0];
|
|
124
139
|
const image = imageThumb.replace(/\/w140\//, '/w1080/');
|
|
125
|
-
return (0,
|
|
140
|
+
return (0, global_helper_js_1.addProtocol)(image);
|
|
126
141
|
}
|
|
127
142
|
}
|
|
128
143
|
else {
|
|
@@ -165,12 +180,73 @@ const parseMoviePeople = (el) => {
|
|
|
165
180
|
.filter((x) => x.classNames.length === 0)
|
|
166
181
|
.map((person) => {
|
|
167
182
|
return {
|
|
168
|
-
id: (0,
|
|
183
|
+
id: (0, global_helper_js_1.parseIdFromUrl)(person.attributes.href),
|
|
169
184
|
name: person.innerText.trim(),
|
|
170
185
|
url: `https://www.csfd.cz${person.attributes.href}`
|
|
171
186
|
};
|
|
172
187
|
}));
|
|
173
188
|
};
|
|
189
|
+
const getSeasonsOrEpisodes = (el, serie) => {
|
|
190
|
+
const childrenList = el.querySelector('.film-episodes-list');
|
|
191
|
+
if (!childrenList)
|
|
192
|
+
return null;
|
|
193
|
+
const childrenNodes = childrenList.querySelectorAll('.film-title');
|
|
194
|
+
if (!(childrenNodes === null || childrenNodes === void 0 ? void 0 : childrenNodes.length))
|
|
195
|
+
return [];
|
|
196
|
+
return childrenNodes.map((season) => {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
const nameContainer = season.querySelector('.film-title-name');
|
|
199
|
+
const infoContainer = season.querySelector('.info');
|
|
200
|
+
return {
|
|
201
|
+
id: (0, global_helper_js_1.parseLastIdFromUrl)((nameContainer === null || nameContainer === void 0 ? void 0 : nameContainer.getAttribute('href')) || ''),
|
|
202
|
+
name: ((_a = nameContainer === null || nameContainer === void 0 ? void 0 : nameContainer.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || null,
|
|
203
|
+
url: (nameContainer === null || nameContainer === void 0 ? void 0 : nameContainer.getAttribute('href')) || null,
|
|
204
|
+
info: ((_b = infoContainer === null || infoContainer === void 0 ? void 0 : infoContainer.textContent) === null || _b === void 0 ? void 0 : _b.replace(/[{()}]/g, '').trim()) || null,
|
|
205
|
+
};
|
|
206
|
+
});
|
|
207
|
+
};
|
|
208
|
+
exports.getSeasonsOrEpisodes = getSeasonsOrEpisodes;
|
|
209
|
+
const getEpisodeCode = (el) => {
|
|
210
|
+
var _a;
|
|
211
|
+
const filmHeaderName = el.querySelector('.film-header-name h1');
|
|
212
|
+
if (!filmHeaderName)
|
|
213
|
+
return null;
|
|
214
|
+
const text = ((_a = filmHeaderName.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || '';
|
|
215
|
+
const match = text.match(/\(([^)]+)\)/);
|
|
216
|
+
const code = match ? match[1] : null;
|
|
217
|
+
return code;
|
|
218
|
+
};
|
|
219
|
+
exports.getEpisodeCode = getEpisodeCode;
|
|
220
|
+
const detectSeasonOrEpisodeListType = (el) => {
|
|
221
|
+
var _a, _b;
|
|
222
|
+
const headerText = (_b = (_a = el.querySelector('.box-header h3')) === null || _a === void 0 ? void 0 : _a.innerText.trim()) !== null && _b !== void 0 ? _b : '';
|
|
223
|
+
if (headerText.includes('Série'))
|
|
224
|
+
return 'seasons';
|
|
225
|
+
if (headerText.startsWith('Epizody'))
|
|
226
|
+
return 'episodes';
|
|
227
|
+
return null;
|
|
228
|
+
};
|
|
229
|
+
exports.detectSeasonOrEpisodeListType = detectSeasonOrEpisodeListType;
|
|
230
|
+
const getSeasonorEpisodeParent = (el, serie) => {
|
|
231
|
+
var _a, _b;
|
|
232
|
+
const parents = el.querySelectorAll('.film-header h2 a');
|
|
233
|
+
if (parents.length === 0) {
|
|
234
|
+
if (!serie)
|
|
235
|
+
return null;
|
|
236
|
+
return { series: serie, season: null };
|
|
237
|
+
}
|
|
238
|
+
const [parentSeries, parentSeason] = parents;
|
|
239
|
+
const seriesId = (0, global_helper_js_1.parseIdFromUrl)(parentSeries === null || parentSeries === void 0 ? void 0 : parentSeries.getAttribute('href'));
|
|
240
|
+
const seasonId = (0, global_helper_js_1.parseIdFromUrl)(parentSeason === null || parentSeason === void 0 ? void 0 : parentSeason.getAttribute('href'));
|
|
241
|
+
const seriesName = ((_a = parentSeries === null || parentSeries === void 0 ? void 0 : parentSeries.textContent) === null || _a === void 0 ? void 0 : _a.trim()) || null;
|
|
242
|
+
const seasonName = ((_b = parentSeason === null || parentSeason === void 0 ? void 0 : parentSeason.textContent) === null || _b === void 0 ? void 0 : _b.trim()) || null;
|
|
243
|
+
const series = seriesId && seriesName ? { id: seriesId, name: seriesName } : null;
|
|
244
|
+
const season = seasonId && seasonName ? { id: seasonId, name: seasonName } : null;
|
|
245
|
+
if (!series && !season)
|
|
246
|
+
return null;
|
|
247
|
+
return { series, season };
|
|
248
|
+
};
|
|
249
|
+
exports.getSeasonorEpisodeParent = getSeasonorEpisodeParent;
|
|
174
250
|
const getMovieGroup = (el, group) => {
|
|
175
251
|
const creators = el.querySelectorAll('.creators h4');
|
|
176
252
|
const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];
|
|
@@ -216,7 +292,7 @@ const getMovieBoxMovies = (el, boxName) => {
|
|
|
216
292
|
if (movieTitleNodes === null || movieTitleNodes === void 0 ? void 0 : movieTitleNodes.length) {
|
|
217
293
|
for (const item of movieTitleNodes) {
|
|
218
294
|
movieListItem.push({
|
|
219
|
-
id: (0,
|
|
295
|
+
id: (0, global_helper_js_1.parseIdFromUrl)(item.attributes.href),
|
|
220
296
|
title: item.textContent.trim(),
|
|
221
297
|
url: `https://www.csfd.cz${item.attributes.href}`
|
|
222
298
|
});
|
|
@@ -245,7 +321,7 @@ const getMoviePremieres = (el) => {
|
|
|
245
321
|
};
|
|
246
322
|
exports.getMoviePremieres = getMoviePremieres;
|
|
247
323
|
const getMovieTags = (el) => {
|
|
248
|
-
const tagsRaw = el.querySelectorAll('.box-content a[href*="/
|
|
324
|
+
const tagsRaw = el.querySelectorAll('.box-content a[href*="/tag/"]');
|
|
249
325
|
return tagsRaw.map((tag) => tag.textContent);
|
|
250
326
|
};
|
|
251
327
|
exports.getMovieTags = getMovieTags;
|
|
@@ -1,19 +1,24 @@
|
|
|
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
|
|
4
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
+
const global_helper_js_1 = require("./global.helper.js");
|
|
5
6
|
const getUser = (el) => {
|
|
6
7
|
return el.querySelector('.user-title-name').text;
|
|
7
8
|
};
|
|
8
9
|
exports.getUser = getUser;
|
|
9
10
|
const getUserRealName = (el) => {
|
|
10
|
-
|
|
11
|
-
|
|
11
|
+
const p = el.querySelector('.article-content p');
|
|
12
|
+
if (!p)
|
|
13
|
+
return null;
|
|
14
|
+
const textNodes = p.childNodes.filter(n => n.nodeType === node_html_parser_1.NodeType.TEXT_NODE && n.rawText.trim() !== '');
|
|
15
|
+
const name = textNodes.length ? textNodes[0].rawText.trim() : null;
|
|
16
|
+
return name;
|
|
12
17
|
};
|
|
13
18
|
exports.getUserRealName = getUserRealName;
|
|
14
19
|
const getAvatar = (el) => {
|
|
15
20
|
const image = el.querySelector('.article-img img').attributes.src;
|
|
16
|
-
return (0,
|
|
21
|
+
return (0, global_helper_js_1.addProtocol)(image);
|
|
17
22
|
};
|
|
18
23
|
exports.getAvatar = getAvatar;
|
|
19
24
|
const getUserUrl = (el) => {
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.parseSearchPeople = exports.getSearchOrigins = exports.getSearchPoster = exports.getSearchColorRating = exports.getSearchUrl = exports.getSearchYear = exports.getSearchTitle = exports.getSearchType = void 0;
|
|
4
|
-
const
|
|
4
|
+
const global_helper_js_1 = require("./global.helper.js");
|
|
5
5
|
const getSearchType = (el) => {
|
|
6
|
+
var _a, _b;
|
|
6
7
|
const type = el.querySelectorAll('.film-title-info .info')[1];
|
|
7
|
-
return ((type === null || type === void 0 ? void 0 : type.innerText.replace(/[{()}]/g, '')) || 'film');
|
|
8
|
+
return (((_b = (_a = type === null || type === void 0 ? void 0 : type.innerText) === null || _a === void 0 ? void 0 : _a.replace(/[{()}]/g, '')) === null || _b === void 0 ? void 0 : _b.trim()) || 'film');
|
|
8
9
|
};
|
|
9
10
|
exports.getSearchType = getSearchType;
|
|
10
11
|
const getSearchTitle = (el) => {
|
|
@@ -21,12 +22,12 @@ const getSearchUrl = (el) => {
|
|
|
21
22
|
};
|
|
22
23
|
exports.getSearchUrl = getSearchUrl;
|
|
23
24
|
const getSearchColorRating = (el) => {
|
|
24
|
-
return (0,
|
|
25
|
+
return (0, global_helper_js_1.parseColor)(el.querySelector('.article-header i.icon').classNames.split(' ').pop());
|
|
25
26
|
};
|
|
26
27
|
exports.getSearchColorRating = getSearchColorRating;
|
|
27
28
|
const getSearchPoster = (el) => {
|
|
28
29
|
const image = el.querySelector('img').attributes.src;
|
|
29
|
-
return (0,
|
|
30
|
+
return (0, global_helper_js_1.addProtocol)(image);
|
|
30
31
|
};
|
|
31
32
|
exports.getSearchPoster = getSearchPoster;
|
|
32
33
|
const getSearchOrigins = (el) => {
|
|
@@ -49,7 +50,7 @@ const parseSearchPeople = (el, type) => {
|
|
|
49
50
|
const people = Array.from(peopleNode.querySelectorAll('a'));
|
|
50
51
|
return people.map((person) => {
|
|
51
52
|
return {
|
|
52
|
-
id: (0,
|
|
53
|
+
id: (0, global_helper_js_1.parseIdFromUrl)(person.attributes.href),
|
|
53
54
|
name: person.innerText.trim(),
|
|
54
55
|
url: `https://www.csfd.cz${person.attributes.href}`
|
|
55
56
|
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.sleep = exports.getUserRatingUrl = exports.getUserRatingDate = exports.getUserRatingColorRating = exports.getUserRatingYear = exports.getUserRatingTitle = exports.getUserRatingType = exports.getUserRating = exports.getUserRatingId = void 0;
|
|
4
|
-
const
|
|
4
|
+
const global_helper_js_1 = require("./global.helper.js");
|
|
5
5
|
const getUserRatingId = (el) => {
|
|
6
6
|
const url = el.querySelector('td.name .film-title-name').attributes.href;
|
|
7
|
-
return (0,
|
|
7
|
+
return (0, global_helper_js_1.parseIdFromUrl)(url);
|
|
8
8
|
};
|
|
9
9
|
exports.getUserRatingId = getUserRatingId;
|
|
10
10
|
const getUserRating = (el) => {
|
package/cjs/index.js
CHANGED
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.csfd = exports.Csfd = void 0;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
17
|
-
const
|
|
13
|
+
const cinema_service_js_1 = require("./services/cinema.service.js");
|
|
14
|
+
const creator_service_js_1 = require("./services/creator.service.js");
|
|
15
|
+
const movie_service_js_1 = require("./services/movie.service.js");
|
|
16
|
+
const search_service_js_1 = require("./services/search.service.js");
|
|
17
|
+
const user_ratings_service_js_1 = require("./services/user-ratings.service.js");
|
|
18
18
|
class Csfd {
|
|
19
19
|
constructor(userRatingsService, movieService, creatorService, searchService, cinemaService) {
|
|
20
20
|
this.userRatingsService = userRatingsService;
|
|
@@ -50,9 +50,9 @@ class Csfd {
|
|
|
50
50
|
}
|
|
51
51
|
}
|
|
52
52
|
exports.Csfd = Csfd;
|
|
53
|
-
const movieScraper = new
|
|
54
|
-
const userRatingsScraper = new
|
|
55
|
-
const cinemaScraper = new
|
|
56
|
-
const creatorScraper = new
|
|
57
|
-
const searchScraper = new
|
|
53
|
+
const movieScraper = new movie_service_js_1.MovieScraper();
|
|
54
|
+
const userRatingsScraper = new user_ratings_service_js_1.UserRatingsScraper();
|
|
55
|
+
const cinemaScraper = new cinema_service_js_1.CinemaScraper();
|
|
56
|
+
const creatorScraper = new creator_service_js_1.CreatorScraper();
|
|
57
|
+
const searchScraper = new search_service_js_1.SearchScraper();
|
|
58
58
|
exports.csfd = new Csfd(userRatingsScraper, movieScraper, creatorScraper, searchScraper, cinemaScraper);
|
|
@@ -11,14 +11,14 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CinemaScraper = void 0;
|
|
13
13
|
const node_html_parser_1 = require("node-html-parser");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const fetchers_js_1 = require("../fetchers/fetchers.js");
|
|
15
|
+
const vars_js_1 = require("../vars.js");
|
|
16
|
+
const cinema_helper_js_1 = require("./../helpers/cinema.helper.js");
|
|
17
17
|
class CinemaScraper {
|
|
18
18
|
cinemas() {
|
|
19
19
|
return __awaiter(this, arguments, void 0, function* (district = 1, period = 'today') {
|
|
20
|
-
const url = (0,
|
|
21
|
-
const response = yield (0,
|
|
20
|
+
const url = (0, vars_js_1.cinemasUrl)(district, period);
|
|
21
|
+
const response = yield (0, fetchers_js_1.fetchPage)(url);
|
|
22
22
|
const cinemasHtml = (0, node_html_parser_1.parse)(response);
|
|
23
23
|
const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
|
|
24
24
|
this.buildCinemas(contentNode);
|
|
@@ -28,14 +28,14 @@ class CinemaScraper {
|
|
|
28
28
|
buildCinemas(contentNode) {
|
|
29
29
|
const cinemas = [];
|
|
30
30
|
contentNode.forEach((x) => {
|
|
31
|
-
const cinemaInfo = (0,
|
|
31
|
+
const cinemaInfo = (0, cinema_helper_js_1.parseCinema)(x);
|
|
32
32
|
const cinema = {
|
|
33
|
-
id: (0,
|
|
33
|
+
id: (0, cinema_helper_js_1.getCinemaId)(x),
|
|
34
34
|
name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
|
|
35
35
|
city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
|
|
36
|
-
url: (0,
|
|
37
|
-
coords: (0,
|
|
38
|
-
screenings: (0,
|
|
36
|
+
url: (0, cinema_helper_js_1.getCinemaUrl)(x),
|
|
37
|
+
coords: (0, cinema_helper_js_1.getCinemaCoords)(x),
|
|
38
|
+
screenings: (0, cinema_helper_js_1.getGroupedFilmsByDate)(x)
|
|
39
39
|
};
|
|
40
40
|
cinemas.push(cinema);
|
|
41
41
|
});
|
|
@@ -11,14 +11,18 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
12
|
exports.CreatorScraper = void 0;
|
|
13
13
|
const node_html_parser_1 = require("node-html-parser");
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
const
|
|
14
|
+
const fetchers_js_1 = require("../fetchers/fetchers.js");
|
|
15
|
+
const creator_helper_js_1 = require("../helpers/creator.helper.js");
|
|
16
|
+
const vars_js_1 = require("../vars.js");
|
|
17
17
|
class CreatorScraper {
|
|
18
18
|
creator(creatorId) {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const
|
|
21
|
-
|
|
20
|
+
const id = Number(creatorId);
|
|
21
|
+
if (isNaN(id)) {
|
|
22
|
+
throw new Error('node-csfd-api: creatorId must be a valid number');
|
|
23
|
+
}
|
|
24
|
+
const url = (0, vars_js_1.creatorUrl)(id);
|
|
25
|
+
const response = yield (0, fetchers_js_1.fetchPage)(url);
|
|
22
26
|
const creatorHtml = (0, node_html_parser_1.parse)(response);
|
|
23
27
|
const asideNode = creatorHtml.querySelector('.creator-about');
|
|
24
28
|
const filmsNode = creatorHtml.querySelector('.creator-filmography');
|
|
@@ -30,13 +34,13 @@ class CreatorScraper {
|
|
|
30
34
|
var _a, _b, _c;
|
|
31
35
|
this.person = {
|
|
32
36
|
id,
|
|
33
|
-
name: (0,
|
|
34
|
-
birthday: (_a = (0,
|
|
35
|
-
birthplace: (_b = (0,
|
|
36
|
-
photo: (0,
|
|
37
|
-
age: ((_c = (0,
|
|
38
|
-
bio: (0,
|
|
39
|
-
films: (0,
|
|
37
|
+
name: (0, creator_helper_js_1.getCreatorName)(asideEl),
|
|
38
|
+
birthday: (_a = (0, creator_helper_js_1.getCreatorBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
|
|
39
|
+
birthplace: (_b = (0, creator_helper_js_1.getCreatorBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
|
|
40
|
+
photo: (0, creator_helper_js_1.getCreatorPhoto)(asideEl),
|
|
41
|
+
age: ((_c = (0, creator_helper_js_1.getCreatorBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
|
|
42
|
+
bio: (0, creator_helper_js_1.getCreatorBio)(asideEl),
|
|
43
|
+
films: (0, creator_helper_js_1.getCreatorFilms)(filmsNode)
|
|
40
44
|
};
|
|
41
45
|
}
|
|
42
46
|
}
|