node-csfd-api 3.0.0-next.22 → 3.0.0-next.24
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/{fetchers → cjs/fetchers}/index.js +13 -4
- package/{helpers → cjs/helpers}/cinema.helper.js +12 -12
- package/{helpers → cjs/helpers}/creator.helper.js +19 -23
- package/{helpers → cjs/helpers}/movie.helper.js +44 -46
- package/{helpers → cjs/helpers}/search.helper.js +17 -17
- package/{helpers → cjs/helpers}/user-ratings.helper.js +16 -17
- package/cjs/index.js +58 -0
- package/cjs/services/cinema.service.js +45 -0
- package/cjs/services/creator.service.js +43 -0
- package/cjs/services/movie.service.js +69 -0
- package/cjs/services/search.service.js +91 -0
- package/cjs/services/user-ratings.service.js +95 -0
- package/esm/fetchers/index.js +13 -4
- 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/index.js +29 -10
- package/esm/services/cinema.service.js +20 -9
- package/esm/services/creator.service.js +27 -16
- package/esm/services/movie.service.js +51 -40
- package/esm/services/search.service.js +38 -27
- package/esm/services/user-ratings.service.js +45 -34
- package/package.json +11 -17
- package/{helpers → types/helpers}/cinema.helper.d.ts +5 -5
- package/types/helpers/creator.helper.d.ts +12 -0
- package/types/helpers/movie.helper.d.ts +23 -0
- package/types/helpers/search.helper.d.ts +11 -0
- package/types/helpers/user-ratings.helper.d.ts +11 -0
- package/{esm/types → types}/index.d.ts +1 -1
- package/types/index.ts +22 -0
- package/{interfaces → types/interfaces}/movie.interface.d.ts +11 -11
- package/{interfaces → types/interfaces}/search.interface.d.ts +4 -4
- package/{vars.d.ts → types/vars.d.ts} +1 -1
- package/esm/types/helpers/cinema.helper.d.ts +0 -18
- package/esm/types/helpers/creator.helper.d.ts +0 -17
- package/esm/types/helpers/movie.helper.d.ts +0 -25
- package/esm/types/helpers/search.helper.d.ts +0 -11
- package/esm/types/helpers/user-ratings.helper.d.ts +0 -13
- package/esm/types/interfaces/movie.interface.d.ts +0 -66
- package/esm/types/interfaces/search.interface.d.ts +0 -27
- package/esm/types/vars.d.ts +0 -6
- package/fetchers/fetch.polyfill.d.ts +0 -1
- package/fetchers/index.d.ts +0 -1
- package/helpers/creator.helper.d.ts +0 -17
- package/helpers/global.helper.d.ts +0 -17
- package/helpers/movie.helper.d.ts +0 -25
- package/helpers/search-user.helper.d.ts +0 -5
- package/helpers/search.helper.d.ts +0 -11
- package/helpers/user-ratings.helper.d.ts +0 -13
- package/index.d.ts +0 -24
- package/index.js +0 -39
- package/interfaces/cinema.interface.d.ts +0 -23
- package/interfaces/creator.interface.d.ts +0 -12
- package/interfaces/global.d.ts +0 -22
- package/interfaces/user-ratings.interface.d.ts +0 -18
- package/services/cinema.service.d.ts +0 -6
- package/services/cinema.service.js +0 -34
- package/services/creator.service.d.ts +0 -6
- package/services/creator.service.js +0 -32
- package/services/movie.service.d.ts +0 -6
- package/services/movie.service.js +0 -58
- package/services/search.service.d.ts +0 -5
- package/services/search.service.js +0 -80
- package/services/user-ratings.service.d.ts +0 -7
- package/services/user-ratings.service.js +0 -84
- /package/{fetchers → cjs/fetchers}/fetch.polyfill.js +0 -0
- /package/{helpers → cjs/helpers}/global.helper.js +0 -0
- /package/{helpers → cjs/helpers}/search-user.helper.js +0 -0
- /package/{interfaces → cjs/interfaces}/cinema.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/creator.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/global.js +0 -0
- /package/{interfaces → cjs/interfaces}/movie.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/search.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/user-ratings.interface.js +0 -0
- /package/{vars.js → cjs/vars.js} +0 -0
- /package/{esm/types → types}/fetchers/fetch.polyfill.d.ts +0 -0
- /package/{esm/types → types}/fetchers/index.d.ts +0 -0
- /package/{esm/types → types}/helpers/global.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/search-user.helper.d.ts +0 -0
- /package/{esm/types → types}/interfaces/cinema.interface.d.ts +0 -0
- /package/{esm/types → types}/interfaces/creator.interface.d.ts +0 -0
- /package/{esm/types → types}/interfaces/global.d.ts +0 -0
- /package/{esm/types → types}/interfaces/user-ratings.interface.d.ts +0 -0
- /package/{esm/types → types}/services/cinema.service.d.ts +0 -0
- /package/{esm/types → types}/services/creator.service.d.ts +0 -0
- /package/{esm/types → types}/services/movie.service.d.ts +0 -0
- /package/{esm/types → types}/services/search.service.d.ts +0 -0
- /package/{esm/types → types}/services/user-ratings.service.d.ts +0 -0
|
@@ -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';
|
package/esm/index.js
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { CinemaScraper } from './services/cinema.service';
|
|
2
11
|
import { CreatorScraper } from './services/creator.service';
|
|
3
12
|
import { MovieScraper } from './services/movie.service';
|
|
@@ -11,20 +20,30 @@ export class Csfd {
|
|
|
11
20
|
this.searchService = searchService;
|
|
12
21
|
this.cinemaService = cinemaService;
|
|
13
22
|
}
|
|
14
|
-
|
|
15
|
-
return this
|
|
23
|
+
userRatings(user, config) {
|
|
24
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
25
|
+
return this.userRatingsService.userRatings(user, config);
|
|
26
|
+
});
|
|
16
27
|
}
|
|
17
|
-
|
|
18
|
-
return this
|
|
28
|
+
movie(movie) {
|
|
29
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
30
|
+
return this.movieService.movie(+movie);
|
|
31
|
+
});
|
|
19
32
|
}
|
|
20
|
-
|
|
21
|
-
return this
|
|
33
|
+
creator(creator) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
return this.creatorService.creator(+creator);
|
|
36
|
+
});
|
|
22
37
|
}
|
|
23
|
-
|
|
24
|
-
return this
|
|
38
|
+
search(text) {
|
|
39
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
40
|
+
return this.searchService.search(text);
|
|
41
|
+
});
|
|
25
42
|
}
|
|
26
|
-
|
|
27
|
-
return this
|
|
43
|
+
cinema(district, period) {
|
|
44
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
+
return this.cinemaService.cinemas(+district, period);
|
|
46
|
+
});
|
|
28
47
|
}
|
|
29
48
|
}
|
|
30
49
|
const movieScraper = new MovieScraper();
|
|
@@ -1,15 +1,26 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { parse } from 'node-html-parser';
|
|
2
11
|
import { fetchPage } from '../fetchers';
|
|
3
12
|
import { cinemasUrl } from '../vars';
|
|
4
|
-
import { getCinemaId, getCinemaUrl,
|
|
13
|
+
import { getCinemaCoords, getCinemaId, getCinemaUrl, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
|
|
5
14
|
export class CinemaScraper {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
15
|
+
cinemas() {
|
|
16
|
+
return __awaiter(this, arguments, void 0, function* (district = 1, period = 'today') {
|
|
17
|
+
const url = cinemasUrl(district, period);
|
|
18
|
+
const response = yield fetchPage(url);
|
|
19
|
+
const cinemasHtml = parse(response);
|
|
20
|
+
const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
|
|
21
|
+
this.buildCinemas(contentNode);
|
|
22
|
+
return this.cinema;
|
|
23
|
+
});
|
|
13
24
|
}
|
|
14
25
|
buildCinemas(contentNode) {
|
|
15
26
|
const cinemas = [];
|
|
@@ -20,7 +31,7 @@ export class CinemaScraper {
|
|
|
20
31
|
name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
|
|
21
32
|
city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
|
|
22
33
|
url: getCinemaUrl(x),
|
|
23
|
-
coords:
|
|
34
|
+
coords: getCinemaCoords(x),
|
|
24
35
|
screenings: getGroupedFilmsByDate(x)
|
|
25
36
|
};
|
|
26
37
|
cinemas.push(cinema);
|
|
@@ -1,28 +1,39 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { parse } from 'node-html-parser';
|
|
2
11
|
import { fetchPage } from '../fetchers';
|
|
3
|
-
import {
|
|
12
|
+
import { getCreatorBio, getCreatorBirthdayInfo, getCreatorFilms, getCreatorName, getCreatorPhoto } from '../helpers/creator.helper';
|
|
4
13
|
import { creatorUrl } from '../vars';
|
|
5
14
|
export class CreatorScraper {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
15
|
+
creator(creatorId) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const url = creatorUrl(+creatorId);
|
|
18
|
+
const response = yield fetchPage(url);
|
|
19
|
+
const creatorHtml = parse(response);
|
|
20
|
+
const asideNode = creatorHtml.querySelector('.creator-about');
|
|
21
|
+
const filmsNode = creatorHtml.querySelector('.creator-filmography');
|
|
22
|
+
this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
23
|
+
return this.person;
|
|
24
|
+
});
|
|
14
25
|
}
|
|
15
26
|
buildCreator(id, asideEl, filmsNode) {
|
|
16
27
|
var _a, _b, _c;
|
|
17
28
|
this.person = {
|
|
18
29
|
id,
|
|
19
|
-
name:
|
|
20
|
-
birthday: (_a =
|
|
21
|
-
birthplace: (_b =
|
|
22
|
-
photo:
|
|
23
|
-
age: ((_c =
|
|
24
|
-
bio:
|
|
25
|
-
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)
|
|
26
37
|
};
|
|
27
38
|
}
|
|
28
39
|
}
|
|
@@ -1,54 +1,65 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { parse } from 'node-html-parser';
|
|
2
11
|
import { fetchPage } from '../fetchers';
|
|
3
|
-
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';
|
|
4
13
|
import { movieUrl } from '../vars';
|
|
5
14
|
export class MovieScraper {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
15
|
+
movie(movieId) {
|
|
16
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
+
const url = movieUrl(+movieId);
|
|
18
|
+
const response = yield fetchPage(url);
|
|
19
|
+
const movieHtml = parse(response);
|
|
20
|
+
const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');
|
|
21
|
+
const asideNode = movieHtml.querySelector('.aside-movie-profile');
|
|
22
|
+
const movieNode = movieHtml.querySelector('.main-movie-profile');
|
|
23
|
+
const jsonLd = movieHtml.querySelector('script[type="application/ld+json"]').innerText;
|
|
24
|
+
this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
25
|
+
return this.film;
|
|
26
|
+
});
|
|
16
27
|
}
|
|
17
28
|
buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
|
|
18
29
|
this.film = {
|
|
19
30
|
id: movieId,
|
|
20
|
-
title:
|
|
21
|
-
year:
|
|
22
|
-
duration:
|
|
23
|
-
descriptions:
|
|
24
|
-
genres:
|
|
25
|
-
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),
|
|
26
37
|
url: movieUrl(movieId),
|
|
27
|
-
origins:
|
|
28
|
-
colorRating:
|
|
29
|
-
rating:
|
|
30
|
-
ratingCount:
|
|
31
|
-
titlesOther:
|
|
32
|
-
poster:
|
|
33
|
-
photo:
|
|
34
|
-
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),
|
|
35
46
|
creators: {
|
|
36
|
-
directors:
|
|
37
|
-
writers:
|
|
38
|
-
cinematography:
|
|
39
|
-
music:
|
|
40
|
-
actors:
|
|
41
|
-
basedOn:
|
|
42
|
-
producers:
|
|
43
|
-
filmEditing:
|
|
44
|
-
costumeDesign:
|
|
45
|
-
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')
|
|
46
57
|
},
|
|
47
|
-
vod:
|
|
48
|
-
tags:
|
|
49
|
-
premieres:
|
|
50
|
-
related:
|
|
51
|
-
similar:
|
|
58
|
+
vod: getMovieVods(asideEl),
|
|
59
|
+
tags: getMovieTags(asideEl),
|
|
60
|
+
premieres: getMoviePremieres(asideEl),
|
|
61
|
+
related: getMovieBoxMovies(asideEl, 'Související'),
|
|
62
|
+
similar: getMovieBoxMovies(asideEl, 'Podobné')
|
|
52
63
|
};
|
|
53
64
|
}
|
|
54
65
|
}
|
|
@@ -1,37 +1,48 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { parse } from 'node-html-parser';
|
|
2
11
|
import { fetchPage } from '../fetchers';
|
|
3
12
|
import { parseIdFromUrl } from '../helpers/global.helper';
|
|
4
13
|
import { getAvatar, getUser, getUserRealName, getUserUrl } from '../helpers/search-user.helper';
|
|
5
|
-
import {
|
|
14
|
+
import { getSearchColorRating, getSearchOrigins, getSearchPoster, getSearchTitle, getSearchType, getSearchUrl, getSearchYear, parseSearchPeople } from '../helpers/search.helper';
|
|
6
15
|
import { searchUrl } from '../vars';
|
|
7
16
|
export class SearchScraper {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
17
|
+
search(text) {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const url = searchUrl(text);
|
|
20
|
+
const response = yield fetchPage(url);
|
|
21
|
+
const html = parse(response);
|
|
22
|
+
const moviesNode = html.querySelectorAll('.main-movies article');
|
|
23
|
+
const usersNode = html.querySelectorAll('.main-users article');
|
|
24
|
+
const tvSeriesNode = html.querySelectorAll('.main-series article');
|
|
25
|
+
return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
|
|
26
|
+
});
|
|
16
27
|
}
|
|
17
28
|
parseSearch(moviesNode, usersNode, tvSeriesNode) {
|
|
18
29
|
const movies = [];
|
|
19
30
|
const users = [];
|
|
20
31
|
const tvSeries = [];
|
|
21
32
|
moviesNode.forEach((m) => {
|
|
22
|
-
const url =
|
|
33
|
+
const url = getSearchUrl(m);
|
|
23
34
|
const movie = {
|
|
24
35
|
id: parseIdFromUrl(url),
|
|
25
|
-
title:
|
|
26
|
-
year:
|
|
36
|
+
title: getSearchTitle(m),
|
|
37
|
+
year: getSearchYear(m),
|
|
27
38
|
url: `https://www.csfd.cz${url}`,
|
|
28
|
-
type:
|
|
29
|
-
colorRating:
|
|
30
|
-
poster:
|
|
31
|
-
origins:
|
|
39
|
+
type: getSearchType(m),
|
|
40
|
+
colorRating: getSearchColorRating(m),
|
|
41
|
+
poster: getSearchPoster(m),
|
|
42
|
+
origins: getSearchOrigins(m),
|
|
32
43
|
creators: {
|
|
33
|
-
directors:
|
|
34
|
-
actors:
|
|
44
|
+
directors: parseSearchPeople(m, 'directors'),
|
|
45
|
+
actors: parseSearchPeople(m, 'actors')
|
|
35
46
|
}
|
|
36
47
|
};
|
|
37
48
|
movies.push(movie);
|
|
@@ -48,19 +59,19 @@ export class SearchScraper {
|
|
|
48
59
|
users.push(user);
|
|
49
60
|
});
|
|
50
61
|
tvSeriesNode.forEach((m) => {
|
|
51
|
-
const url =
|
|
62
|
+
const url = getSearchUrl(m);
|
|
52
63
|
const user = {
|
|
53
64
|
id: parseIdFromUrl(url),
|
|
54
|
-
title:
|
|
55
|
-
year:
|
|
65
|
+
title: getSearchTitle(m),
|
|
66
|
+
year: getSearchYear(m),
|
|
56
67
|
url: `https://www.csfd.cz${url}`,
|
|
57
|
-
type:
|
|
58
|
-
colorRating:
|
|
59
|
-
poster:
|
|
60
|
-
origins:
|
|
68
|
+
type: getSearchType(m),
|
|
69
|
+
colorRating: getSearchColorRating(m),
|
|
70
|
+
poster: getSearchPoster(m),
|
|
71
|
+
origins: getSearchOrigins(m),
|
|
61
72
|
creators: {
|
|
62
|
-
directors:
|
|
63
|
-
actors:
|
|
73
|
+
directors: parseSearchPeople(m, 'directors'),
|
|
74
|
+
actors: parseSearchPeople(m, 'actors')
|
|
64
75
|
}
|
|
65
76
|
};
|
|
66
77
|
tvSeries.push(user);
|
|
@@ -1,39 +1,50 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { parse } from 'node-html-parser';
|
|
2
11
|
import { fetchPage } from '../fetchers';
|
|
3
|
-
import {
|
|
12
|
+
import { getUserRating, getUserRatingColorRating, getUserRatingDate, getUserRatingId, getUserRatingTitle, getUserRatingType, getUserRatingUrl, getUserRatingYear, sleep } from '../helpers/user-ratings.helper';
|
|
4
13
|
import { userRatingsUrl } from '../vars';
|
|
5
14
|
export class UserRatingsScraper {
|
|
6
15
|
constructor() {
|
|
7
16
|
this.films = [];
|
|
8
17
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
18
|
+
userRatings(user, config) {
|
|
19
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
+
let allMovies = [];
|
|
21
|
+
const url = userRatingsUrl(user);
|
|
22
|
+
const response = yield fetchPage(url);
|
|
23
|
+
const items = parse(response);
|
|
24
|
+
const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
|
|
25
|
+
// Get number of pages
|
|
26
|
+
const pagesNode = items.querySelector('.pagination');
|
|
27
|
+
const pages = +(pagesNode === null || pagesNode === void 0 ? void 0 : pagesNode.childNodes[pagesNode.childNodes.length - 4].rawText) || 1;
|
|
28
|
+
allMovies = this.getPage(config, movies);
|
|
29
|
+
if (config === null || config === void 0 ? void 0 : config.allPages) {
|
|
30
|
+
console.log('User', user, url);
|
|
31
|
+
console.log('Fetching all pages', pages);
|
|
32
|
+
for (let i = 2; i <= pages; i++) {
|
|
33
|
+
console.log('Fetching page', i, 'out of', pages, '...');
|
|
34
|
+
const url = userRatingsUrl(user, i);
|
|
35
|
+
const response = yield fetchPage(url);
|
|
36
|
+
const items = parse(response);
|
|
37
|
+
const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
|
|
38
|
+
allMovies = [...this.getPage(config, movies)];
|
|
39
|
+
// Sleep
|
|
40
|
+
if (config.allPagesDelay) {
|
|
41
|
+
yield sleep(config.allPagesDelay);
|
|
42
|
+
}
|
|
32
43
|
}
|
|
44
|
+
return allMovies;
|
|
33
45
|
}
|
|
34
46
|
return allMovies;
|
|
35
|
-
}
|
|
36
|
-
return allMovies;
|
|
47
|
+
});
|
|
37
48
|
}
|
|
38
49
|
getPage(config, movies) {
|
|
39
50
|
var _a, _b, _c, _d;
|
|
@@ -45,7 +56,7 @@ export class UserRatingsScraper {
|
|
|
45
56
|
}
|
|
46
57
|
}
|
|
47
58
|
for (const el of movies) {
|
|
48
|
-
const type =
|
|
59
|
+
const type = getUserRatingType(el);
|
|
49
60
|
// Filtering includesOnly
|
|
50
61
|
if ((_c = config === null || config === void 0 ? void 0 : config.includesOnly) === null || _c === void 0 ? void 0 : _c.length) {
|
|
51
62
|
if (config.includesOnly.some((include) => type === include)) {
|
|
@@ -67,13 +78,13 @@ export class UserRatingsScraper {
|
|
|
67
78
|
}
|
|
68
79
|
buildUserRatings(el) {
|
|
69
80
|
this.films.push({
|
|
70
|
-
id:
|
|
71
|
-
title:
|
|
72
|
-
year:
|
|
73
|
-
type:
|
|
74
|
-
url:
|
|
75
|
-
colorRating:
|
|
76
|
-
userDate:
|
|
81
|
+
id: getUserRatingId(el),
|
|
82
|
+
title: getUserRatingTitle(el),
|
|
83
|
+
year: getUserRatingYear(el),
|
|
84
|
+
type: getUserRatingType(el),
|
|
85
|
+
url: getUserRatingUrl(el),
|
|
86
|
+
colorRating: getUserRatingColorRating(el),
|
|
87
|
+
userDate: getUserRatingDate(el),
|
|
77
88
|
userRating: getUserRating(el)
|
|
78
89
|
});
|
|
79
90
|
}
|
package/package.json
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.24",
|
|
4
4
|
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
|
|
5
|
-
"main": "./index.js",
|
|
6
|
-
"module": "./index.js",
|
|
7
|
-
"types": "./index.d.ts",
|
|
8
|
-
"exports": {
|
|
9
|
-
".": {
|
|
10
|
-
"require": "./dist/index.js",
|
|
11
|
-
"import": "./dist/esm/index.js"
|
|
12
|
-
}
|
|
13
|
-
},
|
|
5
|
+
"main": "./cjs/index.js",
|
|
14
6
|
"author": "BART! <bart@bartweb.cz>",
|
|
15
7
|
"scripts": {
|
|
16
8
|
"start": "tsc -w",
|
|
17
|
-
"prebuild": "rimraf dist
|
|
18
|
-
"build
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
"postbuild": "npm-prepare-dist -s postinstall -s prepare",
|
|
9
|
+
"prebuild": "rimraf dist",
|
|
10
|
+
"build": "tsc && tsc -p tsconfig-cjs.json && yarn barrels",
|
|
11
|
+
"barrels": "barrelsby --delete -c barrels.json",
|
|
12
|
+
"postbuild": "npm-prepare-dist -s postinstall -s prepare && yarn fix-paths",
|
|
22
13
|
"tsc": "tsc",
|
|
23
14
|
"demo": "tsx demo",
|
|
24
15
|
"lint": "eslint ./src/**/**/* --fix",
|
|
25
16
|
"test": "vitest",
|
|
26
17
|
"test:coverage": "yarn test run --coverage",
|
|
18
|
+
"fix-paths": "yarn json -I -f ./dist/package.json -e \"this.module='./esm/index.js';this.main='./cjs/index.js';this.types='./types/index.ts'\"",
|
|
27
19
|
"publish:next": "yarn && yarn build && yarn test:coverage && cd dist && npm publish --tag next",
|
|
28
20
|
"postversion": "git push && git push --follow-tags",
|
|
29
21
|
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
@@ -67,5 +59,7 @@
|
|
|
67
59
|
"license": "MIT",
|
|
68
60
|
"lint-staged": {
|
|
69
61
|
"*.ts": "eslint --cache --fix"
|
|
70
|
-
}
|
|
71
|
-
|
|
62
|
+
},
|
|
63
|
+
"module": "./esm/index.js",
|
|
64
|
+
"types": "./types/index.ts"
|
|
65
|
+
}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from 'interfaces/cinema.interface';
|
|
2
1
|
import { HTMLElement } from 'node-html-parser';
|
|
3
2
|
import { CSFDColorRating } from '../interfaces/global';
|
|
4
|
-
|
|
3
|
+
import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from './../interfaces/cinema.interface';
|
|
4
|
+
export declare const getCinemaColorRating: (el: HTMLElement) => CSFDColorRating;
|
|
5
5
|
export declare const getCinemaId: (el: HTMLElement | null) => number;
|
|
6
|
-
export declare const
|
|
7
|
-
export declare const
|
|
6
|
+
export declare const getCinemaUrlId: (url: string) => number | null;
|
|
7
|
+
export declare const getCinemaCoords: (el: HTMLElement | null) => {
|
|
8
8
|
lat: number;
|
|
9
9
|
lng: number;
|
|
10
10
|
} | null;
|
|
@@ -14,5 +14,5 @@ export declare const parseCinema: (el: HTMLElement | null) => {
|
|
|
14
14
|
name: string;
|
|
15
15
|
};
|
|
16
16
|
export declare const getGroupedFilmsByDate: (el: HTMLElement | null) => CSFDCinemaGroupedFilmsByDate[];
|
|
17
|
-
export declare const
|
|
17
|
+
export declare const getCinemaFilms: (date: string, el: HTMLElement | null) => CSFDCinemaMovie[];
|
|
18
18
|
export declare const parseMeta: (meta: string[]) => CSFDCinemaMeta[];
|