node-csfd-api 3.0.0-next.23 → 3.0.0-next.25
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/helpers/cinema.helper.js +12 -12
- package/cjs/helpers/creator.helper.js +19 -23
- package/cjs/helpers/movie.helper.js +44 -46
- package/cjs/helpers/search.helper.js +17 -17
- package/cjs/helpers/user-ratings.helper.js +16 -17
- package/cjs/services/cinema.service.js +1 -1
- package/cjs/services/creator.service.js +7 -7
- package/cjs/services/movie.service.js +29 -29
- package/cjs/services/search.service.js +18 -18
- package/cjs/services/user-ratings.service.js +8 -8
- package/esm/helpers/cinema.helper.js +7 -7
- package/esm/helpers/creator.helper.js +12 -12
- package/esm/helpers/movie.helper.js +23 -23
- package/esm/helpers/search.helper.js +8 -8
- package/esm/helpers/user-ratings.helper.js +8 -8
- package/esm/services/cinema.service.js +2 -2
- package/esm/services/creator.service.js +8 -8
- package/esm/services/movie.service.js +30 -30
- package/esm/services/search.service.js +19 -19
- package/esm/services/user-ratings.service.js +9 -9
- package/index.d.ts +20 -0
- package/package.json +3 -3
- package/types/helpers/cinema.helper.d.ts +5 -5
- package/types/helpers/creator.helper.d.ts +6 -11
- package/types/helpers/movie.helper.d.ts +21 -23
- package/types/helpers/search.helper.d.ts +9 -9
- package/types/helpers/user-ratings.helper.d.ts +7 -9
- package/types/interfaces/movie.interface.d.ts +11 -11
- package/types/interfaces/search.interface.d.ts +4 -4
- package/types/vars.d.ts +1 -1
- package/types/fetchers/index.d.ts +0 -1
- package/types/index.d.ts +0 -24
- package/types/index.ts +0 -26
|
@@ -33,19 +33,19 @@ class SearchScraper {
|
|
|
33
33
|
const users = [];
|
|
34
34
|
const tvSeries = [];
|
|
35
35
|
moviesNode.forEach((m) => {
|
|
36
|
-
const url = (0, search_helper_1.
|
|
36
|
+
const url = (0, search_helper_1.getSearchUrl)(m);
|
|
37
37
|
const movie = {
|
|
38
38
|
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
39
|
-
title: (0, search_helper_1.
|
|
40
|
-
year: (0, search_helper_1.
|
|
39
|
+
title: (0, search_helper_1.getSearchTitle)(m),
|
|
40
|
+
year: (0, search_helper_1.getSearchYear)(m),
|
|
41
41
|
url: `https://www.csfd.cz${url}`,
|
|
42
|
-
type: (0, search_helper_1.
|
|
43
|
-
colorRating: (0, search_helper_1.
|
|
44
|
-
poster: (0, search_helper_1.
|
|
45
|
-
origins: (0, search_helper_1.
|
|
42
|
+
type: (0, search_helper_1.getSearchType)(m),
|
|
43
|
+
colorRating: (0, search_helper_1.getSearchColorRating)(m),
|
|
44
|
+
poster: (0, search_helper_1.getSearchPoster)(m),
|
|
45
|
+
origins: (0, search_helper_1.getSearchOrigins)(m),
|
|
46
46
|
creators: {
|
|
47
|
-
directors: (0, search_helper_1.
|
|
48
|
-
actors: (0, search_helper_1.
|
|
47
|
+
directors: (0, search_helper_1.parseSearchPeople)(m, 'directors'),
|
|
48
|
+
actors: (0, search_helper_1.parseSearchPeople)(m, 'actors')
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
movies.push(movie);
|
|
@@ -62,19 +62,19 @@ class SearchScraper {
|
|
|
62
62
|
users.push(user);
|
|
63
63
|
});
|
|
64
64
|
tvSeriesNode.forEach((m) => {
|
|
65
|
-
const url = (0, search_helper_1.
|
|
65
|
+
const url = (0, search_helper_1.getSearchUrl)(m);
|
|
66
66
|
const user = {
|
|
67
67
|
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
68
|
-
title: (0, search_helper_1.
|
|
69
|
-
year: (0, search_helper_1.
|
|
68
|
+
title: (0, search_helper_1.getSearchTitle)(m),
|
|
69
|
+
year: (0, search_helper_1.getSearchYear)(m),
|
|
70
70
|
url: `https://www.csfd.cz${url}`,
|
|
71
|
-
type: (0, search_helper_1.
|
|
72
|
-
colorRating: (0, search_helper_1.
|
|
73
|
-
poster: (0, search_helper_1.
|
|
74
|
-
origins: (0, search_helper_1.
|
|
71
|
+
type: (0, search_helper_1.getSearchType)(m),
|
|
72
|
+
colorRating: (0, search_helper_1.getSearchColorRating)(m),
|
|
73
|
+
poster: (0, search_helper_1.getSearchPoster)(m),
|
|
74
|
+
origins: (0, search_helper_1.getSearchOrigins)(m),
|
|
75
75
|
creators: {
|
|
76
|
-
directors: (0, search_helper_1.
|
|
77
|
-
actors: (0, search_helper_1.
|
|
76
|
+
directors: (0, search_helper_1.parseSearchPeople)(m, 'directors'),
|
|
77
|
+
actors: (0, search_helper_1.parseSearchPeople)(m, 'actors')
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
80
|
tvSeries.push(user);
|
|
@@ -59,7 +59,7 @@ class UserRatingsScraper {
|
|
|
59
59
|
}
|
|
60
60
|
}
|
|
61
61
|
for (const el of movies) {
|
|
62
|
-
const type = (0, user_ratings_helper_1.
|
|
62
|
+
const type = (0, user_ratings_helper_1.getUserRatingType)(el);
|
|
63
63
|
// Filtering includesOnly
|
|
64
64
|
if ((_c = config === null || config === void 0 ? void 0 : config.includesOnly) === null || _c === void 0 ? void 0 : _c.length) {
|
|
65
65
|
if (config.includesOnly.some((include) => type === include)) {
|
|
@@ -81,13 +81,13 @@ class UserRatingsScraper {
|
|
|
81
81
|
}
|
|
82
82
|
buildUserRatings(el) {
|
|
83
83
|
this.films.push({
|
|
84
|
-
id: (0, user_ratings_helper_1.
|
|
85
|
-
title: (0, user_ratings_helper_1.
|
|
86
|
-
year: (0, user_ratings_helper_1.
|
|
87
|
-
type: (0, user_ratings_helper_1.
|
|
88
|
-
url: (0, user_ratings_helper_1.
|
|
89
|
-
colorRating: (0, user_ratings_helper_1.
|
|
90
|
-
userDate: (0, user_ratings_helper_1.
|
|
84
|
+
id: (0, user_ratings_helper_1.getUserRatingId)(el),
|
|
85
|
+
title: (0, user_ratings_helper_1.getUserRatingTitle)(el),
|
|
86
|
+
year: (0, user_ratings_helper_1.getUserRatingYear)(el),
|
|
87
|
+
type: (0, user_ratings_helper_1.getUserRatingType)(el),
|
|
88
|
+
url: (0, user_ratings_helper_1.getUserRatingUrl)(el),
|
|
89
|
+
colorRating: (0, user_ratings_helper_1.getUserRatingColorRating)(el),
|
|
90
|
+
userDate: (0, user_ratings_helper_1.getUserRatingDate)(el),
|
|
91
91
|
userRating: (0, user_ratings_helper_1.getUserRating)(el)
|
|
92
92
|
});
|
|
93
93
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseColor, parseIdFromUrl } from './global.helper';
|
|
2
|
-
export const
|
|
2
|
+
export const getCinemaColorRating = (el) => {
|
|
3
3
|
return parseColor(el === null || el === void 0 ? void 0 : el.classNames.split(' ').pop());
|
|
4
4
|
};
|
|
5
5
|
export const getCinemaId = (el) => {
|
|
@@ -7,13 +7,13 @@ export const getCinemaId = (el) => {
|
|
|
7
7
|
const id = (_a = el === null || el === void 0 ? void 0 : el.id) === null || _a === void 0 ? void 0 : _a.split('-')[1];
|
|
8
8
|
return +id;
|
|
9
9
|
};
|
|
10
|
-
export const
|
|
10
|
+
export const getCinemaUrlId = (url) => {
|
|
11
11
|
if (url) {
|
|
12
12
|
return parseIdFromUrl(url);
|
|
13
13
|
}
|
|
14
14
|
return null;
|
|
15
15
|
};
|
|
16
|
-
export const
|
|
16
|
+
export const getCinemaCoords = (el) => {
|
|
17
17
|
if (!el)
|
|
18
18
|
return null;
|
|
19
19
|
const linkMapsEl = el.querySelector('a[href*="q="]');
|
|
@@ -51,18 +51,18 @@ export const getGroupedFilmsByDate = (el) => {
|
|
|
51
51
|
var _a, _b, _c;
|
|
52
52
|
const [date, films] = divs.slice(index, index + 2);
|
|
53
53
|
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;
|
|
54
|
-
return { date: dateText, films:
|
|
54
|
+
return { date: dateText, films: getCinemaFilms('', films) };
|
|
55
55
|
});
|
|
56
56
|
return getDatesAndFilms;
|
|
57
57
|
};
|
|
58
|
-
export const
|
|
58
|
+
export const getCinemaFilms = (date, el) => {
|
|
59
59
|
const filmNodes = el.querySelectorAll('.cinema-table tr');
|
|
60
60
|
const films = filmNodes.map((filmNode) => {
|
|
61
61
|
var _a, _b, _c, _d;
|
|
62
62
|
const url = (_a = filmNode.querySelector('td.name h3 a')) === null || _a === void 0 ? void 0 : _a.attributes.href;
|
|
63
|
-
const id =
|
|
63
|
+
const id = getCinemaUrlId(url);
|
|
64
64
|
const title = (_b = filmNode.querySelector('.name h3')) === null || _b === void 0 ? void 0 : _b.text.trim();
|
|
65
|
-
const colorRating =
|
|
65
|
+
const colorRating = getCinemaColorRating(filmNode.querySelector('.name .icon'));
|
|
66
66
|
const showTimes = (_c = filmNode.querySelectorAll('.td-time')) === null || _c === void 0 ? void 0 : _c.map((x) => x.textContent.trim());
|
|
67
67
|
const meta = (_d = filmNode.querySelectorAll('.td-title span')) === null || _d === void 0 ? void 0 : _d.map((x) => x.text.trim());
|
|
68
68
|
return {
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { addProtocol, parseColor, parseIdFromUrl } from './global.helper';
|
|
2
|
-
|
|
2
|
+
const getCreatorColorRating = (el) => {
|
|
3
3
|
return parseColor(el === null || el === void 0 ? void 0 : el.classNames.split(' ').pop());
|
|
4
4
|
};
|
|
5
|
-
export const
|
|
5
|
+
export const getCreatorId = (url) => {
|
|
6
6
|
if (url) {
|
|
7
7
|
return parseIdFromUrl(url);
|
|
8
8
|
}
|
|
9
9
|
return null;
|
|
10
10
|
};
|
|
11
|
-
export const
|
|
11
|
+
export const getCreatorName = (el) => {
|
|
12
12
|
return el.querySelector('h1').innerText.trim();
|
|
13
13
|
};
|
|
14
|
-
export const
|
|
14
|
+
export const getCreatorBirthdayInfo = (el) => {
|
|
15
15
|
var _a, _b;
|
|
16
16
|
const infoBlock = el.querySelector('h1 + p');
|
|
17
17
|
const text = infoBlock === null || infoBlock === void 0 ? void 0 : infoBlock.innerHTML.trim();
|
|
@@ -27,33 +27,33 @@ export const getBirthdayInfo = (el) => {
|
|
|
27
27
|
const birthPlace = birthPlaceRow ? parseBirthPlace(birthPlaceRow) : '';
|
|
28
28
|
return { birthday, age, birthPlace };
|
|
29
29
|
};
|
|
30
|
-
export const
|
|
30
|
+
export const getCreatorBio = (el) => {
|
|
31
31
|
var _a;
|
|
32
32
|
return ((_a = el.querySelector('.article-content p')) === null || _a === void 0 ? void 0 : _a.text.trim().split('\n')[0].trim()) || null;
|
|
33
33
|
};
|
|
34
|
-
export const
|
|
34
|
+
export const getCreatorPhoto = (el) => {
|
|
35
35
|
const image = el.querySelector('img').attributes.src;
|
|
36
36
|
return addProtocol(image);
|
|
37
37
|
};
|
|
38
|
-
|
|
38
|
+
const parseBirthday = (text) => {
|
|
39
39
|
return text.replace(/nar./g, '').trim();
|
|
40
40
|
};
|
|
41
|
-
|
|
41
|
+
const parseAge = (text) => {
|
|
42
42
|
return text.trim().replace(/\(/g, '').replace(/let\)/g, '').trim();
|
|
43
43
|
};
|
|
44
|
-
|
|
44
|
+
const parseBirthPlace = (text) => {
|
|
45
45
|
return text.trim().replace(/<br>/g, '').trim();
|
|
46
46
|
};
|
|
47
|
-
export const
|
|
47
|
+
export const getCreatorFilms = (el) => {
|
|
48
48
|
var _a;
|
|
49
49
|
const filmNodes = (_a = el.querySelectorAll('.box')[0]) === null || _a === void 0 ? void 0 : _a.querySelectorAll('table tr');
|
|
50
50
|
let yearCache;
|
|
51
51
|
const films = filmNodes.map((filmNode) => {
|
|
52
52
|
var _a, _b, _c;
|
|
53
|
-
const id =
|
|
53
|
+
const id = getCreatorId((_a = filmNode.querySelector('td.name .film-title-name')) === null || _a === void 0 ? void 0 : _a.attributes.href);
|
|
54
54
|
const title = (_b = filmNode.querySelector('.name')) === null || _b === void 0 ? void 0 : _b.text.trim();
|
|
55
55
|
const year = +((_c = filmNode.querySelector('.year')) === null || _c === void 0 ? void 0 : _c.text.trim());
|
|
56
|
-
const colorRating =
|
|
56
|
+
const colorRating = getCreatorColorRating(filmNode.querySelector('.name .icon'));
|
|
57
57
|
// Cache year from previous film because there is a gap between movies with same year
|
|
58
58
|
if (year) {
|
|
59
59
|
yearCache = +year;
|
|
@@ -1,24 +1,24 @@
|
|
|
1
1
|
import { addProtocol, getColor, parseISO8601Duration, parseIdFromUrl } from './global.helper';
|
|
2
|
-
export const
|
|
2
|
+
export const getMovieId = (el) => {
|
|
3
3
|
const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;
|
|
4
4
|
return parseIdFromUrl(url);
|
|
5
5
|
};
|
|
6
|
-
export const
|
|
6
|
+
export const getMovieTitle = (el) => {
|
|
7
7
|
return el.querySelector('h1').innerText.split(`(`)[0].trim();
|
|
8
8
|
};
|
|
9
|
-
export const
|
|
9
|
+
export const getMovieGenres = (el) => {
|
|
10
10
|
const genresRaw = el.querySelector('.genres').textContent;
|
|
11
11
|
return genresRaw.split(' / ');
|
|
12
12
|
};
|
|
13
|
-
export const
|
|
13
|
+
export const getMovieOrigins = (el) => {
|
|
14
14
|
const originsRaw = el.querySelector('.origin').textContent;
|
|
15
15
|
const origins = originsRaw.split(',')[0];
|
|
16
16
|
return origins.split(' / ');
|
|
17
17
|
};
|
|
18
|
-
export const
|
|
18
|
+
export const getMovieColorRating = (bodyClasses) => {
|
|
19
19
|
return getColor(bodyClasses[1]);
|
|
20
20
|
};
|
|
21
|
-
export const
|
|
21
|
+
export const getMovieRating = (el) => {
|
|
22
22
|
const ratingRaw = el.querySelector('.film-rating-average').textContent;
|
|
23
23
|
const rating = ratingRaw === null || ratingRaw === void 0 ? void 0 : ratingRaw.replace(/%/g, '').trim();
|
|
24
24
|
const ratingInt = parseInt(rating);
|
|
@@ -29,7 +29,7 @@ export const getRating = (el) => {
|
|
|
29
29
|
return null;
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
|
-
export const
|
|
32
|
+
export const getMovieRatingCount = (el) => {
|
|
33
33
|
var _a;
|
|
34
34
|
const ratingCountRaw = (_a = el.querySelector('.box-rating-container .counter')) === null || _a === void 0 ? void 0 : _a.textContent;
|
|
35
35
|
const ratingCount = +(ratingCountRaw === null || ratingCountRaw === void 0 ? void 0 : ratingCountRaw.replace(/[(\s)]/g, ''));
|
|
@@ -40,7 +40,7 @@ export const getRatingCount = (el) => {
|
|
|
40
40
|
return null;
|
|
41
41
|
}
|
|
42
42
|
};
|
|
43
|
-
export const
|
|
43
|
+
export const getMovieYear = (el) => {
|
|
44
44
|
try {
|
|
45
45
|
const jsonLd = JSON.parse(el);
|
|
46
46
|
return +jsonLd.dateCreated;
|
|
@@ -50,7 +50,7 @@ export const getYear = (el) => {
|
|
|
50
50
|
return null;
|
|
51
51
|
}
|
|
52
52
|
};
|
|
53
|
-
export const
|
|
53
|
+
export const getMovieDuration = (jsonLdRaw, el) => {
|
|
54
54
|
let duration = null;
|
|
55
55
|
try {
|
|
56
56
|
const jsonLd = JSON.parse(jsonLdRaw);
|
|
@@ -77,7 +77,7 @@ export const getDuration = (jsonLdRaw, el) => {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
};
|
|
80
|
-
export const
|
|
80
|
+
export const getMovieTitlesOther = (el) => {
|
|
81
81
|
const namesNode = el.querySelectorAll('.film-names li');
|
|
82
82
|
if (!namesNode.length) {
|
|
83
83
|
return [];
|
|
@@ -97,7 +97,7 @@ export const getTitlesOther = (el) => {
|
|
|
97
97
|
});
|
|
98
98
|
return titlesOther.filter((x) => x);
|
|
99
99
|
};
|
|
100
|
-
export const
|
|
100
|
+
export const getMoviePoster = (el) => {
|
|
101
101
|
var _a;
|
|
102
102
|
const poster = el.querySelector('.film-posters img');
|
|
103
103
|
// Resolve empty image
|
|
@@ -116,7 +116,7 @@ export const getPoster = (el) => {
|
|
|
116
116
|
return null;
|
|
117
117
|
}
|
|
118
118
|
};
|
|
119
|
-
export const
|
|
119
|
+
export const getMovieRandomPhoto = (el) => {
|
|
120
120
|
var _a;
|
|
121
121
|
const imageNode = el.querySelector('.gallery-item picture img');
|
|
122
122
|
const image = (_a = imageNode === null || imageNode === void 0 ? void 0 : imageNode.attributes) === null || _a === void 0 ? void 0 : _a.src;
|
|
@@ -127,7 +127,7 @@ export const getRandomPhoto = (el) => {
|
|
|
127
127
|
return null;
|
|
128
128
|
}
|
|
129
129
|
};
|
|
130
|
-
export const
|
|
130
|
+
export const getMovieTrivia = (el) => {
|
|
131
131
|
const triviaNodes = el.querySelectorAll('.article-trivia ul li');
|
|
132
132
|
if (triviaNodes === null || triviaNodes === void 0 ? void 0 : triviaNodes.length) {
|
|
133
133
|
return triviaNodes.map((node) => node.textContent.trim().replace(/(\r\n|\n|\r|\t)/gm, ''));
|
|
@@ -136,12 +136,12 @@ export const getTrivia = (el) => {
|
|
|
136
136
|
return null;
|
|
137
137
|
}
|
|
138
138
|
};
|
|
139
|
-
export const
|
|
139
|
+
export const getMovieDescriptions = (el) => {
|
|
140
140
|
return el
|
|
141
141
|
.querySelectorAll('.body--plots .plot-full p, .body--plots .plots .plots-item p')
|
|
142
142
|
.map((movie) => { var _a; return (_a = movie.textContent) === null || _a === void 0 ? void 0 : _a.trim().replace(/(\r\n|\n|\r|\t)/gm, ''); });
|
|
143
143
|
};
|
|
144
|
-
|
|
144
|
+
const parseMoviePeople = (el) => {
|
|
145
145
|
const people = el.querySelectorAll('a');
|
|
146
146
|
return (people
|
|
147
147
|
// Filter out "more" links
|
|
@@ -154,22 +154,22 @@ export const parsePeople = (el) => {
|
|
|
154
154
|
};
|
|
155
155
|
}));
|
|
156
156
|
};
|
|
157
|
-
export const
|
|
157
|
+
export const getMovieGroup = (el, group) => {
|
|
158
158
|
const creators = el.querySelectorAll('.creators h4');
|
|
159
159
|
const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];
|
|
160
160
|
if (element === null || element === void 0 ? void 0 : element.parentNode) {
|
|
161
|
-
return
|
|
161
|
+
return parseMoviePeople(element.parentNode);
|
|
162
162
|
}
|
|
163
163
|
else {
|
|
164
164
|
return [];
|
|
165
165
|
}
|
|
166
166
|
};
|
|
167
|
-
export const
|
|
167
|
+
export const getMovieType = (el) => {
|
|
168
168
|
var _a;
|
|
169
169
|
const type = el.querySelector('.film-header-name .type');
|
|
170
170
|
return ((_a = type === null || type === void 0 ? void 0 : type.innerText) === null || _a === void 0 ? void 0 : _a.replace(/[{()}]/g, '')) || 'film';
|
|
171
171
|
};
|
|
172
|
-
export const
|
|
172
|
+
export const getMovieVods = (el) => {
|
|
173
173
|
let vods = [];
|
|
174
174
|
if (el) {
|
|
175
175
|
const buttons = el.querySelectorAll('.box-buttons .button');
|
|
@@ -184,12 +184,12 @@ export const getVods = (el) => {
|
|
|
184
184
|
return vods.length ? vods : [];
|
|
185
185
|
};
|
|
186
186
|
// Get box content
|
|
187
|
-
|
|
187
|
+
const getBoxContent = (el, box) => {
|
|
188
188
|
var _a;
|
|
189
189
|
const headers = el.querySelectorAll('section.box .box-header');
|
|
190
190
|
return (_a = headers.find((header) => header.querySelector('h3').textContent.trim().includes(box))) === null || _a === void 0 ? void 0 : _a.parentNode;
|
|
191
191
|
};
|
|
192
|
-
export const
|
|
192
|
+
export const getMovieBoxMovies = (el, boxName) => {
|
|
193
193
|
const movieListItem = [];
|
|
194
194
|
const box = getBoxContent(el, boxName);
|
|
195
195
|
const movieTitleNodes = box === null || box === void 0 ? void 0 : box.querySelectorAll('.article-header .film-title-name');
|
|
@@ -204,7 +204,7 @@ export const getBoxMovies = (el, boxName) => {
|
|
|
204
204
|
}
|
|
205
205
|
return movieListItem;
|
|
206
206
|
};
|
|
207
|
-
export const
|
|
207
|
+
export const getMoviePremieres = (el) => {
|
|
208
208
|
var _a, _b;
|
|
209
209
|
const premiereNodes = el.querySelectorAll('.box-premieres li');
|
|
210
210
|
const premiere = [];
|
|
@@ -222,7 +222,7 @@ export const getPremieres = (el) => {
|
|
|
222
222
|
}
|
|
223
223
|
return premiere;
|
|
224
224
|
};
|
|
225
|
-
export const
|
|
225
|
+
export const getMovieTags = (el) => {
|
|
226
226
|
const tagsRaw = el.querySelectorAll('.box-content a[href*="/podrobne-vyhledavani/?tag="]');
|
|
227
227
|
return tagsRaw.map((tag) => tag.textContent);
|
|
228
228
|
};
|
|
@@ -1,26 +1,26 @@
|
|
|
1
1
|
import { addProtocol, parseColor, parseIdFromUrl } from './global.helper';
|
|
2
|
-
export const
|
|
2
|
+
export const getSearchType = (el) => {
|
|
3
3
|
const type = el.querySelectorAll('.film-title-info .info')[1];
|
|
4
4
|
return ((type === null || type === void 0 ? void 0 : type.innerText.replace(/[{()}]/g, '')) || 'film');
|
|
5
5
|
};
|
|
6
|
-
export const
|
|
6
|
+
export const getSearchTitle = (el) => {
|
|
7
7
|
return el.querySelector('.film-title-name').text;
|
|
8
8
|
};
|
|
9
|
-
export const
|
|
9
|
+
export const getSearchYear = (el) => {
|
|
10
10
|
var _a;
|
|
11
11
|
return +((_a = el.querySelectorAll('.film-title-info .info')[0]) === null || _a === void 0 ? void 0 : _a.innerText.replace(/[{()}]/g, ''));
|
|
12
12
|
};
|
|
13
|
-
export const
|
|
13
|
+
export const getSearchUrl = (el) => {
|
|
14
14
|
return el.querySelector('.film-title-name').attributes.href;
|
|
15
15
|
};
|
|
16
|
-
export const
|
|
16
|
+
export const getSearchColorRating = (el) => {
|
|
17
17
|
return parseColor(el.querySelector('.article-header i.icon').classNames.split(' ').pop());
|
|
18
18
|
};
|
|
19
|
-
export const
|
|
19
|
+
export const getSearchPoster = (el) => {
|
|
20
20
|
const image = el.querySelector('img').attributes.src;
|
|
21
21
|
return addProtocol(image);
|
|
22
22
|
};
|
|
23
|
-
export const
|
|
23
|
+
export const getSearchOrigins = (el) => {
|
|
24
24
|
var _a, _b;
|
|
25
25
|
const originsRaw = (_a = el.querySelector('.article-content p .info')) === null || _a === void 0 ? void 0 : _a.text;
|
|
26
26
|
if (!originsRaw)
|
|
@@ -28,7 +28,7 @@ export const getOrigins = (el) => {
|
|
|
28
28
|
const originsAll = (_b = originsRaw === null || originsRaw === void 0 ? void 0 : originsRaw.split(', ')) === null || _b === void 0 ? void 0 : _b[0];
|
|
29
29
|
return originsAll === null || originsAll === void 0 ? void 0 : originsAll.split('/').map((country) => country.trim());
|
|
30
30
|
};
|
|
31
|
-
export const
|
|
31
|
+
export const parseSearchPeople = (el, type) => {
|
|
32
32
|
let who;
|
|
33
33
|
if (type === 'directors')
|
|
34
34
|
who = 'Režie:';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { parseIdFromUrl } from './global.helper';
|
|
2
|
-
export const
|
|
2
|
+
export const getUserRatingId = (el) => {
|
|
3
3
|
const url = el.querySelector('td.name .film-title-name').attributes.href;
|
|
4
4
|
return parseIdFromUrl(url);
|
|
5
5
|
};
|
|
@@ -8,29 +8,29 @@ export const getUserRating = (el) => {
|
|
|
8
8
|
const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;
|
|
9
9
|
return rating;
|
|
10
10
|
};
|
|
11
|
-
export const
|
|
11
|
+
export const getUserRatingType = (el) => {
|
|
12
12
|
const typeText = el.querySelectorAll('td.name .film-title-info .info');
|
|
13
13
|
return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film');
|
|
14
14
|
};
|
|
15
|
-
export const
|
|
15
|
+
export const getUserRatingTitle = (el) => {
|
|
16
16
|
return el.querySelector('td.name .film-title-name').text;
|
|
17
17
|
};
|
|
18
|
-
export const
|
|
18
|
+
export const getUserRatingYear = (el) => {
|
|
19
19
|
var _a;
|
|
20
20
|
return +((_a = el.querySelectorAll('td.name .film-title-info .info')[0]) === null || _a === void 0 ? void 0 : _a.text.slice(1, -1)) || null;
|
|
21
21
|
};
|
|
22
|
-
export const
|
|
22
|
+
export const getUserRatingColorRating = (el) => {
|
|
23
23
|
const color = parseColor(el.querySelector('td.name .icon').classNames.split(' ').pop());
|
|
24
24
|
return color;
|
|
25
25
|
};
|
|
26
|
-
export const
|
|
26
|
+
export const getUserRatingDate = (el) => {
|
|
27
27
|
return el.querySelector('td.date-only').text.trim();
|
|
28
28
|
};
|
|
29
|
-
export const
|
|
29
|
+
export const getUserRatingUrl = (el) => {
|
|
30
30
|
const url = el.querySelector('td.name .film-title-name').attributes.href;
|
|
31
31
|
return `https://www.csfd.cz${url}`;
|
|
32
32
|
};
|
|
33
|
-
|
|
33
|
+
const parseColor = (quality) => {
|
|
34
34
|
switch (quality) {
|
|
35
35
|
case 'lightgrey':
|
|
36
36
|
return 'unknown';
|
|
@@ -10,7 +10,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { parse } from 'node-html-parser';
|
|
11
11
|
import { fetchPage } from '../fetchers';
|
|
12
12
|
import { cinemasUrl } from '../vars';
|
|
13
|
-
import { getCinemaId, getCinemaUrl,
|
|
13
|
+
import { getCinemaCoords, getCinemaId, getCinemaUrl, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
|
|
14
14
|
export class CinemaScraper {
|
|
15
15
|
cinemas() {
|
|
16
16
|
return __awaiter(this, arguments, void 0, function* (district = 1, period = 'today') {
|
|
@@ -31,7 +31,7 @@ export class CinemaScraper {
|
|
|
31
31
|
name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
|
|
32
32
|
city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
|
|
33
33
|
url: getCinemaUrl(x),
|
|
34
|
-
coords:
|
|
34
|
+
coords: getCinemaCoords(x),
|
|
35
35
|
screenings: getGroupedFilmsByDate(x)
|
|
36
36
|
};
|
|
37
37
|
cinemas.push(cinema);
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { parse } from 'node-html-parser';
|
|
11
11
|
import { fetchPage } from '../fetchers';
|
|
12
|
-
import {
|
|
12
|
+
import { getCreatorBio, getCreatorBirthdayInfo, getCreatorFilms, getCreatorName, getCreatorPhoto } from '../helpers/creator.helper';
|
|
13
13
|
import { creatorUrl } from '../vars';
|
|
14
14
|
export class CreatorScraper {
|
|
15
15
|
creator(creatorId) {
|
|
@@ -27,13 +27,13 @@ export class CreatorScraper {
|
|
|
27
27
|
var _a, _b, _c;
|
|
28
28
|
this.person = {
|
|
29
29
|
id,
|
|
30
|
-
name:
|
|
31
|
-
birthday: (_a =
|
|
32
|
-
birthplace: (_b =
|
|
33
|
-
photo:
|
|
34
|
-
age: ((_c =
|
|
35
|
-
bio:
|
|
36
|
-
films:
|
|
30
|
+
name: getCreatorName(asideEl),
|
|
31
|
+
birthday: (_a = getCreatorBirthdayInfo(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
|
|
32
|
+
birthplace: (_b = getCreatorBirthdayInfo(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
|
|
33
|
+
photo: getCreatorPhoto(asideEl),
|
|
34
|
+
age: ((_c = getCreatorBirthdayInfo(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
|
|
35
|
+
bio: getCreatorBio(asideEl),
|
|
36
|
+
films: getCreatorFilms(filmsNode)
|
|
37
37
|
};
|
|
38
38
|
}
|
|
39
39
|
}
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { parse } from 'node-html-parser';
|
|
11
11
|
import { fetchPage } from '../fetchers';
|
|
12
|
-
import {
|
|
12
|
+
import { getMovieBoxMovies, getMovieColorRating, getMovieDescriptions, getMovieDuration, getMovieGenres, getMovieGroup, getMovieOrigins, getMoviePoster, getMoviePremieres, getMovieRandomPhoto, getMovieRating, getMovieRatingCount, getMovieTags, getMovieTitle, getMovieTitlesOther, getMovieTrivia, getMovieType, getMovieVods, getMovieYear } from '../helpers/movie.helper';
|
|
13
13
|
import { movieUrl } from '../vars';
|
|
14
14
|
export class MovieScraper {
|
|
15
15
|
movie(movieId) {
|
|
@@ -28,38 +28,38 @@ export class MovieScraper {
|
|
|
28
28
|
buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
|
|
29
29
|
this.film = {
|
|
30
30
|
id: movieId,
|
|
31
|
-
title:
|
|
32
|
-
year:
|
|
33
|
-
duration:
|
|
34
|
-
descriptions:
|
|
35
|
-
genres:
|
|
36
|
-
type:
|
|
31
|
+
title: getMovieTitle(el),
|
|
32
|
+
year: getMovieYear(jsonLd),
|
|
33
|
+
duration: getMovieDuration(jsonLd, el),
|
|
34
|
+
descriptions: getMovieDescriptions(el),
|
|
35
|
+
genres: getMovieGenres(el),
|
|
36
|
+
type: getMovieType(el),
|
|
37
37
|
url: movieUrl(movieId),
|
|
38
|
-
origins:
|
|
39
|
-
colorRating:
|
|
40
|
-
rating:
|
|
41
|
-
ratingCount:
|
|
42
|
-
titlesOther:
|
|
43
|
-
poster:
|
|
44
|
-
photo:
|
|
45
|
-
trivia:
|
|
38
|
+
origins: getMovieOrigins(el),
|
|
39
|
+
colorRating: getMovieColorRating(pageClasses),
|
|
40
|
+
rating: getMovieRating(asideEl),
|
|
41
|
+
ratingCount: getMovieRatingCount(asideEl),
|
|
42
|
+
titlesOther: getMovieTitlesOther(el),
|
|
43
|
+
poster: getMoviePoster(el),
|
|
44
|
+
photo: getMovieRandomPhoto(el),
|
|
45
|
+
trivia: getMovieTrivia(el),
|
|
46
46
|
creators: {
|
|
47
|
-
directors:
|
|
48
|
-
writers:
|
|
49
|
-
cinematography:
|
|
50
|
-
music:
|
|
51
|
-
actors:
|
|
52
|
-
basedOn:
|
|
53
|
-
producers:
|
|
54
|
-
filmEditing:
|
|
55
|
-
costumeDesign:
|
|
56
|
-
productionDesign:
|
|
47
|
+
directors: getMovieGroup(el, 'Režie'),
|
|
48
|
+
writers: getMovieGroup(el, 'Scénář'),
|
|
49
|
+
cinematography: getMovieGroup(el, 'Kamera'),
|
|
50
|
+
music: getMovieGroup(el, 'Hudba'),
|
|
51
|
+
actors: getMovieGroup(el, 'Hrají'),
|
|
52
|
+
basedOn: getMovieGroup(el, 'Předloha'),
|
|
53
|
+
producers: getMovieGroup(el, 'Produkce'),
|
|
54
|
+
filmEditing: getMovieGroup(el, 'Střih'),
|
|
55
|
+
costumeDesign: getMovieGroup(el, 'Kostýmy'),
|
|
56
|
+
productionDesign: getMovieGroup(el, 'Scénografie')
|
|
57
57
|
},
|
|
58
|
-
vod:
|
|
59
|
-
tags:
|
|
60
|
-
premieres:
|
|
61
|
-
related:
|
|
62
|
-
similar:
|
|
58
|
+
vod: getMovieVods(asideEl),
|
|
59
|
+
tags: getMovieTags(asideEl),
|
|
60
|
+
premieres: getMoviePremieres(asideEl),
|
|
61
|
+
related: getMovieBoxMovies(asideEl, 'Související'),
|
|
62
|
+
similar: getMovieBoxMovies(asideEl, 'Podobné')
|
|
63
63
|
};
|
|
64
64
|
}
|
|
65
65
|
}
|
|
@@ -11,7 +11,7 @@ import { parse } from 'node-html-parser';
|
|
|
11
11
|
import { fetchPage } from '../fetchers';
|
|
12
12
|
import { parseIdFromUrl } from '../helpers/global.helper';
|
|
13
13
|
import { getAvatar, getUser, getUserRealName, getUserUrl } from '../helpers/search-user.helper';
|
|
14
|
-
import {
|
|
14
|
+
import { getSearchColorRating, getSearchOrigins, getSearchPoster, getSearchTitle, getSearchType, getSearchUrl, getSearchYear, parseSearchPeople } from '../helpers/search.helper';
|
|
15
15
|
import { searchUrl } from '../vars';
|
|
16
16
|
export class SearchScraper {
|
|
17
17
|
search(text) {
|
|
@@ -30,19 +30,19 @@ export class SearchScraper {
|
|
|
30
30
|
const users = [];
|
|
31
31
|
const tvSeries = [];
|
|
32
32
|
moviesNode.forEach((m) => {
|
|
33
|
-
const url =
|
|
33
|
+
const url = getSearchUrl(m);
|
|
34
34
|
const movie = {
|
|
35
35
|
id: parseIdFromUrl(url),
|
|
36
|
-
title:
|
|
37
|
-
year:
|
|
36
|
+
title: getSearchTitle(m),
|
|
37
|
+
year: getSearchYear(m),
|
|
38
38
|
url: `https://www.csfd.cz${url}`,
|
|
39
|
-
type:
|
|
40
|
-
colorRating:
|
|
41
|
-
poster:
|
|
42
|
-
origins:
|
|
39
|
+
type: getSearchType(m),
|
|
40
|
+
colorRating: getSearchColorRating(m),
|
|
41
|
+
poster: getSearchPoster(m),
|
|
42
|
+
origins: getSearchOrigins(m),
|
|
43
43
|
creators: {
|
|
44
|
-
directors:
|
|
45
|
-
actors:
|
|
44
|
+
directors: parseSearchPeople(m, 'directors'),
|
|
45
|
+
actors: parseSearchPeople(m, 'actors')
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
48
|
movies.push(movie);
|
|
@@ -59,19 +59,19 @@ export class SearchScraper {
|
|
|
59
59
|
users.push(user);
|
|
60
60
|
});
|
|
61
61
|
tvSeriesNode.forEach((m) => {
|
|
62
|
-
const url =
|
|
62
|
+
const url = getSearchUrl(m);
|
|
63
63
|
const user = {
|
|
64
64
|
id: parseIdFromUrl(url),
|
|
65
|
-
title:
|
|
66
|
-
year:
|
|
65
|
+
title: getSearchTitle(m),
|
|
66
|
+
year: getSearchYear(m),
|
|
67
67
|
url: `https://www.csfd.cz${url}`,
|
|
68
|
-
type:
|
|
69
|
-
colorRating:
|
|
70
|
-
poster:
|
|
71
|
-
origins:
|
|
68
|
+
type: getSearchType(m),
|
|
69
|
+
colorRating: getSearchColorRating(m),
|
|
70
|
+
poster: getSearchPoster(m),
|
|
71
|
+
origins: getSearchOrigins(m),
|
|
72
72
|
creators: {
|
|
73
|
-
directors:
|
|
74
|
-
actors:
|
|
73
|
+
directors: parseSearchPeople(m, 'directors'),
|
|
74
|
+
actors: parseSearchPeople(m, 'actors')
|
|
75
75
|
}
|
|
76
76
|
};
|
|
77
77
|
tvSeries.push(user);
|