node-csfd-api 3.0.0-next.20 → 3.0.0-next.22
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +41 -3
- package/esm/fetchers/index.js +4 -13
- package/esm/helpers/cinema.helper.js +22 -10
- package/esm/helpers/creator.helper.js +12 -11
- package/esm/helpers/search.helper.js +5 -3
- package/esm/helpers/user-ratings.helper.js +2 -1
- package/esm/index.js +10 -29
- package/esm/services/cinema.service.js +11 -22
- package/esm/services/creator.service.js +8 -19
- package/esm/services/movie.service.js +10 -21
- package/esm/services/search.service.js +11 -22
- package/esm/services/user-ratings.service.js +25 -36
- package/{types → esm/types}/helpers/cinema.helper.d.ts +2 -3
- package/{types → esm/types}/helpers/search.helper.d.ts +1 -1
- package/{types → esm/types}/index.d.ts +1 -1
- package/fetchers/fetch.polyfill.d.ts +1 -0
- package/fetchers/index.d.ts +1 -0
- package/{cjs/fetchers → fetchers}/index.js +4 -13
- package/helpers/cinema.helper.d.ts +18 -0
- package/{cjs/helpers → helpers}/cinema.helper.js +23 -12
- package/helpers/creator.helper.d.ts +17 -0
- package/{cjs/helpers → helpers}/creator.helper.js +12 -11
- package/helpers/global.helper.d.ts +17 -0
- package/helpers/movie.helper.d.ts +25 -0
- package/helpers/search-user.helper.d.ts +5 -0
- package/helpers/search.helper.d.ts +11 -0
- package/{cjs/helpers → helpers}/search.helper.js +5 -3
- package/helpers/user-ratings.helper.d.ts +13 -0
- package/{cjs/helpers → helpers}/user-ratings.helper.js +2 -1
- package/index.d.ts +24 -0
- package/index.js +39 -0
- package/interfaces/cinema.interface.d.ts +23 -0
- package/interfaces/creator.interface.d.ts +12 -0
- package/interfaces/global.d.ts +22 -0
- package/interfaces/movie.interface.d.ts +66 -0
- package/interfaces/search.interface.d.ts +27 -0
- package/interfaces/user-ratings.interface.d.ts +18 -0
- package/package.json +20 -14
- package/services/cinema.service.d.ts +6 -0
- package/services/cinema.service.js +34 -0
- package/services/creator.service.d.ts +6 -0
- package/services/creator.service.js +32 -0
- package/services/movie.service.d.ts +6 -0
- package/{cjs/services → services}/movie.service.js +10 -21
- package/services/search.service.d.ts +5 -0
- package/{cjs/services → services}/search.service.js +11 -22
- package/services/user-ratings.service.d.ts +7 -0
- package/{cjs/services → services}/user-ratings.service.js +25 -36
- package/vars.d.ts +6 -0
- package/cjs/index.js +0 -58
- package/cjs/services/cinema.service.js +0 -45
- package/cjs/services/creator.service.js +0 -43
- package/types/index.ts +0 -26
- /package/{types → esm/types}/fetchers/fetch.polyfill.d.ts +0 -0
- /package/{types → esm/types}/fetchers/index.d.ts +0 -0
- /package/{types → esm/types}/helpers/creator.helper.d.ts +0 -0
- /package/{types → esm/types}/helpers/global.helper.d.ts +0 -0
- /package/{types → esm/types}/helpers/movie.helper.d.ts +0 -0
- /package/{types → esm/types}/helpers/search-user.helper.d.ts +0 -0
- /package/{types → esm/types}/helpers/user-ratings.helper.d.ts +0 -0
- /package/{types → esm/types}/interfaces/cinema.interface.d.ts +0 -0
- /package/{types → esm/types}/interfaces/creator.interface.d.ts +0 -0
- /package/{types → esm/types}/interfaces/global.d.ts +0 -0
- /package/{types → esm/types}/interfaces/movie.interface.d.ts +0 -0
- /package/{types → esm/types}/interfaces/search.interface.d.ts +0 -0
- /package/{types → esm/types}/interfaces/user-ratings.interface.d.ts +0 -0
- /package/{types → esm/types}/services/cinema.service.d.ts +0 -0
- /package/{types → esm/types}/services/creator.service.d.ts +0 -0
- /package/{types → esm/types}/services/movie.service.d.ts +0 -0
- /package/{types → esm/types}/services/search.service.d.ts +0 -0
- /package/{types → esm/types}/services/user-ratings.service.d.ts +0 -0
- /package/{types → esm/types}/vars.d.ts +0 -0
- /package/{cjs/fetchers → fetchers}/fetch.polyfill.js +0 -0
- /package/{cjs/helpers → helpers}/global.helper.js +0 -0
- /package/{cjs/helpers → helpers}/movie.helper.js +0 -0
- /package/{cjs/helpers → helpers}/search-user.helper.js +0 -0
- /package/{cjs/interfaces → interfaces}/cinema.interface.js +0 -0
- /package/{cjs/interfaces → interfaces}/creator.interface.js +0 -0
- /package/{cjs/interfaces → interfaces}/global.js +0 -0
- /package/{cjs/interfaces → interfaces}/movie.interface.js +0 -0
- /package/{cjs/interfaces → interfaces}/search.interface.js +0 -0
- /package/{cjs/interfaces → interfaces}/user-ratings.interface.js +0 -0
- /package/{cjs/vars.js → vars.js} +0 -0
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.MovieScraper = void 0;
|
|
13
4
|
const node_html_parser_1 = require("node-html-parser");
|
|
@@ -15,18 +6,16 @@ const fetchers_1 = require("../fetchers");
|
|
|
15
6
|
const movie_helper_1 = require("../helpers/movie.helper");
|
|
16
7
|
const vars_1 = require("../vars");
|
|
17
8
|
class MovieScraper {
|
|
18
|
-
movie(movieId) {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return this.film;
|
|
29
|
-
});
|
|
9
|
+
async movie(movieId) {
|
|
10
|
+
const url = (0, vars_1.movieUrl)(+movieId);
|
|
11
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
12
|
+
const movieHtml = (0, node_html_parser_1.parse)(response);
|
|
13
|
+
const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');
|
|
14
|
+
const asideNode = movieHtml.querySelector('.aside-movie-profile');
|
|
15
|
+
const movieNode = movieHtml.querySelector('.main-movie-profile');
|
|
16
|
+
const jsonLd = movieHtml.querySelector('script[type="application/ld+json"]').innerText;
|
|
17
|
+
this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
18
|
+
return this.film;
|
|
30
19
|
}
|
|
31
20
|
buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
|
|
32
21
|
this.film = {
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.SearchScraper = void 0;
|
|
13
4
|
const node_html_parser_1 = require("node-html-parser");
|
|
@@ -17,22 +8,20 @@ const search_user_helper_1 = require("../helpers/search-user.helper");
|
|
|
17
8
|
const search_helper_1 = require("../helpers/search.helper");
|
|
18
9
|
const vars_1 = require("../vars");
|
|
19
10
|
class SearchScraper {
|
|
20
|
-
search(text) {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
|
|
29
|
-
});
|
|
11
|
+
async search(text) {
|
|
12
|
+
const url = (0, vars_1.searchUrl)(text);
|
|
13
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
14
|
+
const html = (0, node_html_parser_1.parse)(response);
|
|
15
|
+
const moviesNode = html.querySelectorAll('.main-movies article');
|
|
16
|
+
const usersNode = html.querySelectorAll('.main-users article');
|
|
17
|
+
const tvSeriesNode = html.querySelectorAll('.main-series article');
|
|
18
|
+
return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
|
|
30
19
|
}
|
|
31
20
|
parseSearch(moviesNode, usersNode, tvSeriesNode) {
|
|
32
21
|
const movies = [];
|
|
33
22
|
const users = [];
|
|
34
23
|
const tvSeries = [];
|
|
35
|
-
moviesNode.
|
|
24
|
+
moviesNode.forEach((m) => {
|
|
36
25
|
const url = (0, search_helper_1.getUrl)(m);
|
|
37
26
|
const movie = {
|
|
38
27
|
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
@@ -50,7 +39,7 @@ class SearchScraper {
|
|
|
50
39
|
};
|
|
51
40
|
movies.push(movie);
|
|
52
41
|
});
|
|
53
|
-
usersNode.
|
|
42
|
+
usersNode.forEach((m) => {
|
|
54
43
|
const url = (0, search_user_helper_1.getUserUrl)(m);
|
|
55
44
|
const user = {
|
|
56
45
|
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
@@ -61,7 +50,7 @@ class SearchScraper {
|
|
|
61
50
|
};
|
|
62
51
|
users.push(user);
|
|
63
52
|
});
|
|
64
|
-
tvSeriesNode.
|
|
53
|
+
tvSeriesNode.forEach((m) => {
|
|
65
54
|
const url = (0, search_helper_1.getUrl)(m);
|
|
66
55
|
const user = {
|
|
67
56
|
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { CSFDUserRatingConfig, CSFDUserRatings } from '../interfaces/user-ratings.interface';
|
|
2
|
+
export declare class UserRatingsScraper {
|
|
3
|
+
private films;
|
|
4
|
+
userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
|
|
5
|
+
private getPage;
|
|
6
|
+
private buildUserRatings;
|
|
7
|
+
}
|
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.UserRatingsScraper = void 0;
|
|
13
4
|
const node_html_parser_1 = require("node-html-parser");
|
|
@@ -18,36 +9,34 @@ class UserRatingsScraper {
|
|
|
18
9
|
constructor() {
|
|
19
10
|
this.films = [];
|
|
20
11
|
}
|
|
21
|
-
userRatings(user, config) {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
yield (0, user_ratings_helper_1.sleep)(config.allPagesDelay);
|
|
45
|
-
}
|
|
12
|
+
async userRatings(user, config) {
|
|
13
|
+
let allMovies = [];
|
|
14
|
+
const url = (0, vars_1.userRatingsUrl)(user);
|
|
15
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
16
|
+
const items = (0, node_html_parser_1.parse)(response);
|
|
17
|
+
const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
|
|
18
|
+
// Get number of pages
|
|
19
|
+
const pagesNode = items.querySelector('.pagination');
|
|
20
|
+
const pages = +(pagesNode === null || pagesNode === void 0 ? void 0 : pagesNode.childNodes[pagesNode.childNodes.length - 4].rawText) || 1;
|
|
21
|
+
allMovies = this.getPage(config, movies);
|
|
22
|
+
if (config === null || config === void 0 ? void 0 : config.allPages) {
|
|
23
|
+
console.log('User', user, url);
|
|
24
|
+
console.log('Fetching all pages', pages);
|
|
25
|
+
for (let i = 2; i <= pages; i++) {
|
|
26
|
+
console.log('Fetching page', i, 'out of', pages, '...');
|
|
27
|
+
const url = (0, vars_1.userRatingsUrl)(user, i);
|
|
28
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
29
|
+
const items = (0, node_html_parser_1.parse)(response);
|
|
30
|
+
const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
|
|
31
|
+
allMovies = [...this.getPage(config, movies)];
|
|
32
|
+
// Sleep
|
|
33
|
+
if (config.allPagesDelay) {
|
|
34
|
+
await (0, user_ratings_helper_1.sleep)(config.allPagesDelay);
|
|
46
35
|
}
|
|
47
|
-
return allMovies;
|
|
48
36
|
}
|
|
49
37
|
return allMovies;
|
|
50
|
-
}
|
|
38
|
+
}
|
|
39
|
+
return allMovies;
|
|
51
40
|
}
|
|
52
41
|
getPage(config, movies) {
|
|
53
42
|
var _a, _b, _c, _d;
|
package/vars.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CSFDCinemaPeriod } from 'interfaces/cinema.interface';
|
|
2
|
+
export declare const userRatingsUrl: (user: string | number, page?: number) => string;
|
|
3
|
+
export declare const movieUrl: (movie: number) => string;
|
|
4
|
+
export declare const creatorUrl: (creator: number | string) => string;
|
|
5
|
+
export declare const cinemasUrl: (district: number | string, period: CSFDCinemaPeriod) => string;
|
|
6
|
+
export declare const searchUrl: (text: string) => string;
|
package/cjs/index.js
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.csfd = exports.Csfd = void 0;
|
|
13
|
-
const cinema_service_1 = require("./services/cinema.service");
|
|
14
|
-
const creator_service_1 = require("./services/creator.service");
|
|
15
|
-
const movie_service_1 = require("./services/movie.service");
|
|
16
|
-
const search_service_1 = require("./services/search.service");
|
|
17
|
-
const user_ratings_service_1 = require("./services/user-ratings.service");
|
|
18
|
-
class Csfd {
|
|
19
|
-
constructor(userRatingsService, movieService, creatorService, searchService, cinemaService) {
|
|
20
|
-
this.userRatingsService = userRatingsService;
|
|
21
|
-
this.movieService = movieService;
|
|
22
|
-
this.creatorService = creatorService;
|
|
23
|
-
this.searchService = searchService;
|
|
24
|
-
this.cinemaService = cinemaService;
|
|
25
|
-
}
|
|
26
|
-
userRatings(user, config) {
|
|
27
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
28
|
-
return this.userRatingsService.userRatings(user, config);
|
|
29
|
-
});
|
|
30
|
-
}
|
|
31
|
-
movie(movie) {
|
|
32
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
-
return this.movieService.movie(+movie);
|
|
34
|
-
});
|
|
35
|
-
}
|
|
36
|
-
creator(creator) {
|
|
37
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
38
|
-
return this.creatorService.creator(+creator);
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
search(text) {
|
|
42
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
43
|
-
return this.searchService.search(text);
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
cinema(district, period) {
|
|
47
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return this.cinemaService.cinemas(+district, period);
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
}
|
|
52
|
-
exports.Csfd = Csfd;
|
|
53
|
-
const movieScraper = new movie_service_1.MovieScraper();
|
|
54
|
-
const userRatingsScraper = new user_ratings_service_1.UserRatingsScraper();
|
|
55
|
-
const cinemaScraper = new cinema_service_1.CinemaScraper();
|
|
56
|
-
const creatorScraper = new creator_service_1.CreatorScraper();
|
|
57
|
-
const searchScraper = new search_service_1.SearchScraper();
|
|
58
|
-
exports.csfd = new Csfd(userRatingsScraper, movieScraper, creatorScraper, searchScraper, cinemaScraper);
|
|
@@ -1,45 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CinemaScraper = void 0;
|
|
13
|
-
const node_html_parser_1 = require("node-html-parser");
|
|
14
|
-
const fetchers_1 = require("../fetchers");
|
|
15
|
-
const vars_1 = require("../vars");
|
|
16
|
-
const cinema_helper_1 = require("./../helpers/cinema.helper");
|
|
17
|
-
class CinemaScraper {
|
|
18
|
-
cinemas(district = 1, period = 'today') {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const url = (0, vars_1.cinemasUrl)(district, period);
|
|
21
|
-
const response = yield (0, fetchers_1.fetchPage)(url);
|
|
22
|
-
const cinemasHtml = (0, node_html_parser_1.parse)(response);
|
|
23
|
-
const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
|
|
24
|
-
this.buildCinemas(contentNode);
|
|
25
|
-
return this.cinema;
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
buildCinemas(contentNode) {
|
|
29
|
-
const cinemas = [];
|
|
30
|
-
contentNode.map((x) => {
|
|
31
|
-
var _a, _b;
|
|
32
|
-
const cinema = {
|
|
33
|
-
id: (0, cinema_helper_1.getCinemaId)(x),
|
|
34
|
-
name: (_a = (0, cinema_helper_1.parseCinema)(x)) === null || _a === void 0 ? void 0 : _a.name,
|
|
35
|
-
city: (_b = (0, cinema_helper_1.parseCinema)(x)) === null || _b === void 0 ? void 0 : _b.city,
|
|
36
|
-
url: (0, cinema_helper_1.getCinemaUrl)(x),
|
|
37
|
-
coords: (0, cinema_helper_1.getCoords)(x),
|
|
38
|
-
screenings: (0, cinema_helper_1.getGroupedFilmsByDate)(x)
|
|
39
|
-
};
|
|
40
|
-
cinemas.push(cinema);
|
|
41
|
-
});
|
|
42
|
-
this.cinema = cinemas;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
exports.CinemaScraper = CinemaScraper;
|
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.CreatorScraper = void 0;
|
|
13
|
-
const node_html_parser_1 = require("node-html-parser");
|
|
14
|
-
const fetchers_1 = require("../fetchers");
|
|
15
|
-
const creator_helper_1 = require("../helpers/creator.helper");
|
|
16
|
-
const vars_1 = require("../vars");
|
|
17
|
-
class CreatorScraper {
|
|
18
|
-
creator(creatorId) {
|
|
19
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const url = (0, vars_1.creatorUrl)(+creatorId);
|
|
21
|
-
const response = yield (0, fetchers_1.fetchPage)(url);
|
|
22
|
-
const creatorHtml = (0, node_html_parser_1.parse)(response);
|
|
23
|
-
const asideNode = creatorHtml.querySelector('.creator-about');
|
|
24
|
-
const filmsNode = creatorHtml.querySelector('.creator-filmography');
|
|
25
|
-
this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
26
|
-
return this.person;
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
buildCreator(id, asideEl, filmsNode) {
|
|
30
|
-
var _a, _b, _c;
|
|
31
|
-
this.person = {
|
|
32
|
-
id,
|
|
33
|
-
name: (0, creator_helper_1.getName)(asideEl),
|
|
34
|
-
birthday: (_a = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
|
|
35
|
-
birthplace: (_b = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
|
|
36
|
-
photo: (0, creator_helper_1.getPhoto)(asideEl),
|
|
37
|
-
age: ((_c = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
|
|
38
|
-
bio: (0, creator_helper_1.getBio)(asideEl),
|
|
39
|
-
films: (0, creator_helper_1.getFilms)(filmsNode)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
exports.CreatorScraper = CreatorScraper;
|
package/types/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @file Automatically generated by barrelsby.
|
|
3
|
-
*/
|
|
4
|
-
|
|
5
|
-
export * from "./index";
|
|
6
|
-
export * from "./vars";
|
|
7
|
-
export * from "./fetchers/fetch.polyfill";
|
|
8
|
-
export * from "./fetchers/index";
|
|
9
|
-
export * from "./helpers/cinema.helper";
|
|
10
|
-
export * from "./helpers/creator.helper";
|
|
11
|
-
export * from "./helpers/global.helper";
|
|
12
|
-
export * from "./helpers/movie.helper";
|
|
13
|
-
export * from "./helpers/search-user.helper";
|
|
14
|
-
export * from "./helpers/search.helper";
|
|
15
|
-
export * from "./helpers/user-ratings.helper";
|
|
16
|
-
export * from "./interfaces/cinema.interface";
|
|
17
|
-
export * from "./interfaces/creator.interface";
|
|
18
|
-
export * from "./interfaces/global";
|
|
19
|
-
export * from "./interfaces/movie.interface";
|
|
20
|
-
export * from "./interfaces/search.interface";
|
|
21
|
-
export * from "./interfaces/user-ratings.interface";
|
|
22
|
-
export * from "./services/cinema.service";
|
|
23
|
-
export * from "./services/creator.service";
|
|
24
|
-
export * from "./services/movie.service";
|
|
25
|
-
export * from "./services/search.service";
|
|
26
|
-
export * from "./services/user-ratings.service";
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
/package/{cjs/vars.js → vars.js}
RENAMED
|
File without changes
|