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.
Files changed (90) hide show
  1. package/{fetchers → cjs/fetchers}/index.js +13 -4
  2. package/{helpers → cjs/helpers}/cinema.helper.js +12 -12
  3. package/{helpers → cjs/helpers}/creator.helper.js +19 -23
  4. package/{helpers → cjs/helpers}/movie.helper.js +44 -46
  5. package/{helpers → cjs/helpers}/search.helper.js +17 -17
  6. package/{helpers → cjs/helpers}/user-ratings.helper.js +16 -17
  7. package/cjs/index.js +58 -0
  8. package/cjs/services/cinema.service.js +45 -0
  9. package/cjs/services/creator.service.js +43 -0
  10. package/cjs/services/movie.service.js +69 -0
  11. package/cjs/services/search.service.js +91 -0
  12. package/cjs/services/user-ratings.service.js +95 -0
  13. package/esm/fetchers/index.js +13 -4
  14. package/esm/helpers/cinema.helper.js +7 -7
  15. package/esm/helpers/creator.helper.js +12 -12
  16. package/esm/helpers/movie.helper.js +23 -23
  17. package/esm/helpers/search.helper.js +8 -8
  18. package/esm/helpers/user-ratings.helper.js +8 -8
  19. package/esm/index.js +29 -10
  20. package/esm/services/cinema.service.js +20 -9
  21. package/esm/services/creator.service.js +27 -16
  22. package/esm/services/movie.service.js +51 -40
  23. package/esm/services/search.service.js +38 -27
  24. package/esm/services/user-ratings.service.js +45 -34
  25. package/package.json +11 -17
  26. package/{helpers → types/helpers}/cinema.helper.d.ts +5 -5
  27. package/types/helpers/creator.helper.d.ts +12 -0
  28. package/types/helpers/movie.helper.d.ts +23 -0
  29. package/types/helpers/search.helper.d.ts +11 -0
  30. package/types/helpers/user-ratings.helper.d.ts +11 -0
  31. package/{esm/types → types}/index.d.ts +1 -1
  32. package/types/index.ts +22 -0
  33. package/{interfaces → types/interfaces}/movie.interface.d.ts +11 -11
  34. package/{interfaces → types/interfaces}/search.interface.d.ts +4 -4
  35. package/{vars.d.ts → types/vars.d.ts} +1 -1
  36. package/esm/types/helpers/cinema.helper.d.ts +0 -18
  37. package/esm/types/helpers/creator.helper.d.ts +0 -17
  38. package/esm/types/helpers/movie.helper.d.ts +0 -25
  39. package/esm/types/helpers/search.helper.d.ts +0 -11
  40. package/esm/types/helpers/user-ratings.helper.d.ts +0 -13
  41. package/esm/types/interfaces/movie.interface.d.ts +0 -66
  42. package/esm/types/interfaces/search.interface.d.ts +0 -27
  43. package/esm/types/vars.d.ts +0 -6
  44. package/fetchers/fetch.polyfill.d.ts +0 -1
  45. package/fetchers/index.d.ts +0 -1
  46. package/helpers/creator.helper.d.ts +0 -17
  47. package/helpers/global.helper.d.ts +0 -17
  48. package/helpers/movie.helper.d.ts +0 -25
  49. package/helpers/search-user.helper.d.ts +0 -5
  50. package/helpers/search.helper.d.ts +0 -11
  51. package/helpers/user-ratings.helper.d.ts +0 -13
  52. package/index.d.ts +0 -24
  53. package/index.js +0 -39
  54. package/interfaces/cinema.interface.d.ts +0 -23
  55. package/interfaces/creator.interface.d.ts +0 -12
  56. package/interfaces/global.d.ts +0 -22
  57. package/interfaces/user-ratings.interface.d.ts +0 -18
  58. package/services/cinema.service.d.ts +0 -6
  59. package/services/cinema.service.js +0 -34
  60. package/services/creator.service.d.ts +0 -6
  61. package/services/creator.service.js +0 -32
  62. package/services/movie.service.d.ts +0 -6
  63. package/services/movie.service.js +0 -58
  64. package/services/search.service.d.ts +0 -5
  65. package/services/search.service.js +0 -80
  66. package/services/user-ratings.service.d.ts +0 -7
  67. package/services/user-ratings.service.js +0 -84
  68. /package/{fetchers → cjs/fetchers}/fetch.polyfill.js +0 -0
  69. /package/{helpers → cjs/helpers}/global.helper.js +0 -0
  70. /package/{helpers → cjs/helpers}/search-user.helper.js +0 -0
  71. /package/{interfaces → cjs/interfaces}/cinema.interface.js +0 -0
  72. /package/{interfaces → cjs/interfaces}/creator.interface.js +0 -0
  73. /package/{interfaces → cjs/interfaces}/global.js +0 -0
  74. /package/{interfaces → cjs/interfaces}/movie.interface.js +0 -0
  75. /package/{interfaces → cjs/interfaces}/search.interface.js +0 -0
  76. /package/{interfaces → cjs/interfaces}/user-ratings.interface.js +0 -0
  77. /package/{vars.js → cjs/vars.js} +0 -0
  78. /package/{esm/types → types}/fetchers/fetch.polyfill.d.ts +0 -0
  79. /package/{esm/types → types}/fetchers/index.d.ts +0 -0
  80. /package/{esm/types → types}/helpers/global.helper.d.ts +0 -0
  81. /package/{esm/types → types}/helpers/search-user.helper.d.ts +0 -0
  82. /package/{esm/types → types}/interfaces/cinema.interface.d.ts +0 -0
  83. /package/{esm/types → types}/interfaces/creator.interface.d.ts +0 -0
  84. /package/{esm/types → types}/interfaces/global.d.ts +0 -0
  85. /package/{esm/types → types}/interfaces/user-ratings.interface.d.ts +0 -0
  86. /package/{esm/types → types}/services/cinema.service.d.ts +0 -0
  87. /package/{esm/types → types}/services/creator.service.d.ts +0 -0
  88. /package/{esm/types → types}/services/movie.service.d.ts +0 -0
  89. /package/{esm/types → types}/services/search.service.d.ts +0 -0
  90. /package/{esm/types → types}/services/user-ratings.service.d.ts +0 -0
@@ -1,34 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CinemaScraper = void 0;
4
- const node_html_parser_1 = require("node-html-parser");
5
- const fetchers_1 = require("../fetchers");
6
- const vars_1 = require("../vars");
7
- const cinema_helper_1 = require("./../helpers/cinema.helper");
8
- class CinemaScraper {
9
- async cinemas(district = 1, period = 'today') {
10
- const url = (0, vars_1.cinemasUrl)(district, period);
11
- const response = await (0, fetchers_1.fetchPage)(url);
12
- const cinemasHtml = (0, node_html_parser_1.parse)(response);
13
- const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
14
- this.buildCinemas(contentNode);
15
- return this.cinema;
16
- }
17
- buildCinemas(contentNode) {
18
- const cinemas = [];
19
- contentNode.forEach((x) => {
20
- const cinemaInfo = (0, cinema_helper_1.parseCinema)(x);
21
- const cinema = {
22
- id: (0, cinema_helper_1.getCinemaId)(x),
23
- name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
24
- city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
25
- url: (0, cinema_helper_1.getCinemaUrl)(x),
26
- coords: (0, cinema_helper_1.getCoords)(x),
27
- screenings: (0, cinema_helper_1.getGroupedFilmsByDate)(x)
28
- };
29
- cinemas.push(cinema);
30
- });
31
- this.cinema = cinemas;
32
- }
33
- }
34
- exports.CinemaScraper = CinemaScraper;
@@ -1,6 +0,0 @@
1
- import { CSFDCreator } from '../interfaces/creator.interface';
2
- export declare class CreatorScraper {
3
- private person;
4
- creator(creatorId: number): Promise<CSFDCreator>;
5
- private buildCreator;
6
- }
@@ -1,32 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CreatorScraper = void 0;
4
- const node_html_parser_1 = require("node-html-parser");
5
- const fetchers_1 = require("../fetchers");
6
- const creator_helper_1 = require("../helpers/creator.helper");
7
- const vars_1 = require("../vars");
8
- class CreatorScraper {
9
- async creator(creatorId) {
10
- const url = (0, vars_1.creatorUrl)(+creatorId);
11
- const response = await (0, fetchers_1.fetchPage)(url);
12
- const creatorHtml = (0, node_html_parser_1.parse)(response);
13
- const asideNode = creatorHtml.querySelector('.creator-about');
14
- const filmsNode = creatorHtml.querySelector('.creator-filmography');
15
- this.buildCreator(+creatorId, asideNode, filmsNode);
16
- return this.person;
17
- }
18
- buildCreator(id, asideEl, filmsNode) {
19
- var _a, _b, _c;
20
- this.person = {
21
- id,
22
- name: (0, creator_helper_1.getName)(asideEl),
23
- birthday: (_a = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
24
- birthplace: (_b = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
25
- photo: (0, creator_helper_1.getPhoto)(asideEl),
26
- age: ((_c = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
27
- bio: (0, creator_helper_1.getBio)(asideEl),
28
- films: (0, creator_helper_1.getFilms)(filmsNode)
29
- };
30
- }
31
- }
32
- exports.CreatorScraper = CreatorScraper;
@@ -1,6 +0,0 @@
1
- import { CSFDMovie } from '../interfaces/movie.interface';
2
- export declare class MovieScraper {
3
- private film;
4
- movie(movieId: number): Promise<CSFDMovie>;
5
- private buildMovie;
6
- }
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.MovieScraper = void 0;
4
- const node_html_parser_1 = require("node-html-parser");
5
- const fetchers_1 = require("../fetchers");
6
- const movie_helper_1 = require("../helpers/movie.helper");
7
- const vars_1 = require("../vars");
8
- class MovieScraper {
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;
19
- }
20
- buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
21
- this.film = {
22
- id: movieId,
23
- title: (0, movie_helper_1.getTitle)(el),
24
- year: (0, movie_helper_1.getYear)(jsonLd),
25
- duration: (0, movie_helper_1.getDuration)(jsonLd, el),
26
- descriptions: (0, movie_helper_1.getDescriptions)(el),
27
- genres: (0, movie_helper_1.getGenres)(el),
28
- type: (0, movie_helper_1.getType)(el),
29
- url: (0, vars_1.movieUrl)(movieId),
30
- origins: (0, movie_helper_1.getOrigins)(el),
31
- colorRating: (0, movie_helper_1.getColorRating)(pageClasses),
32
- rating: (0, movie_helper_1.getRating)(asideEl),
33
- ratingCount: (0, movie_helper_1.getRatingCount)(asideEl),
34
- titlesOther: (0, movie_helper_1.getTitlesOther)(el),
35
- poster: (0, movie_helper_1.getPoster)(el),
36
- photo: (0, movie_helper_1.getRandomPhoto)(el),
37
- trivia: (0, movie_helper_1.getTrivia)(el),
38
- creators: {
39
- directors: (0, movie_helper_1.getGroup)(el, 'Režie'),
40
- writers: (0, movie_helper_1.getGroup)(el, 'Scénář'),
41
- cinematography: (0, movie_helper_1.getGroup)(el, 'Kamera'),
42
- music: (0, movie_helper_1.getGroup)(el, 'Hudba'),
43
- actors: (0, movie_helper_1.getGroup)(el, 'Hrají'),
44
- basedOn: (0, movie_helper_1.getGroup)(el, 'Předloha'),
45
- producers: (0, movie_helper_1.getGroup)(el, 'Produkce'),
46
- filmEditing: (0, movie_helper_1.getGroup)(el, 'Střih'),
47
- costumeDesign: (0, movie_helper_1.getGroup)(el, 'Kostýmy'),
48
- productionDesign: (0, movie_helper_1.getGroup)(el, 'Scénografie')
49
- },
50
- vod: (0, movie_helper_1.getVods)(asideEl),
51
- tags: (0, movie_helper_1.getTags)(asideEl),
52
- premieres: (0, movie_helper_1.getPremieres)(asideEl),
53
- related: (0, movie_helper_1.getBoxMovies)(asideEl, 'Související'),
54
- similar: (0, movie_helper_1.getBoxMovies)(asideEl, 'Podobné')
55
- };
56
- }
57
- }
58
- exports.MovieScraper = MovieScraper;
@@ -1,5 +0,0 @@
1
- import { CSFDSearch } from '../interfaces/search.interface';
2
- export declare class SearchScraper {
3
- search(text: string): Promise<CSFDSearch>;
4
- private parseSearch;
5
- }
@@ -1,80 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SearchScraper = void 0;
4
- const node_html_parser_1 = require("node-html-parser");
5
- const fetchers_1 = require("../fetchers");
6
- const global_helper_1 = require("../helpers/global.helper");
7
- const search_user_helper_1 = require("../helpers/search-user.helper");
8
- const search_helper_1 = require("../helpers/search.helper");
9
- const vars_1 = require("../vars");
10
- class SearchScraper {
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);
19
- }
20
- parseSearch(moviesNode, usersNode, tvSeriesNode) {
21
- const movies = [];
22
- const users = [];
23
- const tvSeries = [];
24
- moviesNode.forEach((m) => {
25
- const url = (0, search_helper_1.getUrl)(m);
26
- const movie = {
27
- id: (0, global_helper_1.parseIdFromUrl)(url),
28
- title: (0, search_helper_1.getTitle)(m),
29
- year: (0, search_helper_1.getYear)(m),
30
- url: `https://www.csfd.cz${url}`,
31
- type: (0, search_helper_1.getType)(m),
32
- colorRating: (0, search_helper_1.getColorRating)(m),
33
- poster: (0, search_helper_1.getPoster)(m),
34
- origins: (0, search_helper_1.getOrigins)(m),
35
- creators: {
36
- directors: (0, search_helper_1.parsePeople)(m, 'directors'),
37
- actors: (0, search_helper_1.parsePeople)(m, 'actors')
38
- }
39
- };
40
- movies.push(movie);
41
- });
42
- usersNode.forEach((m) => {
43
- const url = (0, search_user_helper_1.getUserUrl)(m);
44
- const user = {
45
- id: (0, global_helper_1.parseIdFromUrl)(url),
46
- user: (0, search_user_helper_1.getUser)(m),
47
- userRealName: (0, search_user_helper_1.getUserRealName)(m),
48
- avatar: (0, search_user_helper_1.getAvatar)(m),
49
- url: `https://www.csfd.cz${url}`
50
- };
51
- users.push(user);
52
- });
53
- tvSeriesNode.forEach((m) => {
54
- const url = (0, search_helper_1.getUrl)(m);
55
- const user = {
56
- id: (0, global_helper_1.parseIdFromUrl)(url),
57
- title: (0, search_helper_1.getTitle)(m),
58
- year: (0, search_helper_1.getYear)(m),
59
- url: `https://www.csfd.cz${url}`,
60
- type: (0, search_helper_1.getType)(m),
61
- colorRating: (0, search_helper_1.getColorRating)(m),
62
- poster: (0, search_helper_1.getPoster)(m),
63
- origins: (0, search_helper_1.getOrigins)(m),
64
- creators: {
65
- directors: (0, search_helper_1.parsePeople)(m, 'directors'),
66
- actors: (0, search_helper_1.parsePeople)(m, 'actors')
67
- }
68
- };
69
- tvSeries.push(user);
70
- });
71
- const search = {
72
- movies: movies,
73
- users: users,
74
- tvSeries: tvSeries,
75
- creators: []
76
- };
77
- return search;
78
- }
79
- }
80
- exports.SearchScraper = SearchScraper;
@@ -1,7 +0,0 @@
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,84 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.UserRatingsScraper = void 0;
4
- const node_html_parser_1 = require("node-html-parser");
5
- const fetchers_1 = require("../fetchers");
6
- const user_ratings_helper_1 = require("../helpers/user-ratings.helper");
7
- const vars_1 = require("../vars");
8
- class UserRatingsScraper {
9
- constructor() {
10
- this.films = [];
11
- }
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);
35
- }
36
- }
37
- return allMovies;
38
- }
39
- return allMovies;
40
- }
41
- getPage(config, movies) {
42
- var _a, _b, _c, _d;
43
- if (config) {
44
- if (((_a = config.includesOnly) === null || _a === void 0 ? void 0 : _a.length) && ((_b = config.excludes) === null || _b === void 0 ? void 0 : _b.length)) {
45
- console.warn(`node-csfd-api:
46
- You can not use both parameters 'includesOnly' and 'excludes'.
47
- Parameter 'includesOnly' will be used now:`, config.includesOnly);
48
- }
49
- }
50
- for (const el of movies) {
51
- const type = (0, user_ratings_helper_1.getType)(el);
52
- // Filtering includesOnly
53
- if ((_c = config === null || config === void 0 ? void 0 : config.includesOnly) === null || _c === void 0 ? void 0 : _c.length) {
54
- if (config.includesOnly.some((include) => type === include)) {
55
- this.buildUserRatings(el);
56
- }
57
- // Filter exludes
58
- }
59
- else if ((_d = config === null || config === void 0 ? void 0 : config.excludes) === null || _d === void 0 ? void 0 : _d.length) {
60
- if (!config.excludes.some((exclude) => type === exclude)) {
61
- this.buildUserRatings(el);
62
- }
63
- }
64
- else {
65
- // Without filtering
66
- this.buildUserRatings(el);
67
- }
68
- }
69
- return this.films;
70
- }
71
- buildUserRatings(el) {
72
- this.films.push({
73
- id: (0, user_ratings_helper_1.getId)(el),
74
- title: (0, user_ratings_helper_1.getTitle)(el),
75
- year: (0, user_ratings_helper_1.getYear)(el),
76
- type: (0, user_ratings_helper_1.getType)(el),
77
- url: (0, user_ratings_helper_1.getUrl)(el),
78
- colorRating: (0, user_ratings_helper_1.getColorRating)(el),
79
- userDate: (0, user_ratings_helper_1.getDate)(el),
80
- userRating: (0, user_ratings_helper_1.getUserRating)(el)
81
- });
82
- }
83
- }
84
- exports.UserRatingsScraper = UserRatingsScraper;
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes