node-csfd-api 3.0.0-next.9 → 3.0.1

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 (136) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +89 -44
  3. package/_virtual/rolldown_runtime.js +25 -0
  4. package/dto/cinema.d.mts +28 -0
  5. package/dto/cinema.d.ts +28 -0
  6. package/dto/creator.d.mts +17 -0
  7. package/dto/creator.d.ts +17 -0
  8. package/dto/global.d.mts +26 -0
  9. package/dto/global.d.ts +26 -0
  10. package/dto/movie.d.mts +71 -0
  11. package/dto/movie.d.ts +71 -0
  12. package/dto/search.d.mts +32 -0
  13. package/dto/search.d.ts +32 -0
  14. package/dto/user-ratings.d.mts +23 -0
  15. package/dto/user-ratings.d.ts +23 -0
  16. package/fetchers/fetch.polyfill.js +10 -0
  17. package/fetchers/fetch.polyfill.js.map +1 -0
  18. package/fetchers/fetch.polyfill.mjs +8 -0
  19. package/fetchers/fetch.polyfill.mjs.map +1 -0
  20. package/fetchers/index.js +24 -0
  21. package/fetchers/index.js.map +1 -0
  22. package/fetchers/index.mjs +24 -0
  23. package/fetchers/index.mjs.map +1 -0
  24. package/helpers/cinema.helper.js +84 -0
  25. package/helpers/cinema.helper.js.map +1 -0
  26. package/helpers/cinema.helper.mjs +80 -0
  27. package/helpers/cinema.helper.mjs.map +1 -0
  28. package/helpers/creator.helper.js +73 -0
  29. package/helpers/creator.helper.js.map +1 -0
  30. package/helpers/creator.helper.mjs +69 -0
  31. package/helpers/creator.helper.mjs.map +1 -0
  32. package/helpers/global.helper.js +50 -0
  33. package/helpers/global.helper.js.map +1 -0
  34. package/helpers/global.helper.mjs +45 -0
  35. package/helpers/global.helper.mjs.map +1 -0
  36. package/helpers/movie.helper.js +162 -0
  37. package/helpers/movie.helper.js.map +1 -0
  38. package/helpers/movie.helper.mjs +144 -0
  39. package/helpers/movie.helper.mjs.map +1 -0
  40. package/helpers/search-user.helper.js +29 -0
  41. package/helpers/search-user.helper.js.map +1 -0
  42. package/helpers/search-user.helper.mjs +24 -0
  43. package/helpers/search-user.helper.mjs.map +1 -0
  44. package/helpers/search.helper.js +52 -0
  45. package/helpers/search.helper.js.map +1 -0
  46. package/helpers/search.helper.mjs +45 -0
  47. package/helpers/search.helper.mjs.map +1 -0
  48. package/helpers/user-ratings.helper.js +52 -0
  49. package/helpers/user-ratings.helper.js.map +1 -0
  50. package/helpers/user-ratings.helper.mjs +44 -0
  51. package/helpers/user-ratings.helper.mjs.map +1 -0
  52. package/index.d.mts +30 -0
  53. package/index.d.ts +30 -0
  54. package/index.js +42 -0
  55. package/index.js.map +1 -0
  56. package/index.mjs +41 -0
  57. package/index.mjs.map +1 -0
  58. package/package.json +15 -28
  59. package/services/cinema.service.d.mts +11 -0
  60. package/services/cinema.service.d.ts +11 -0
  61. package/services/cinema.service.js +35 -0
  62. package/services/cinema.service.js.map +1 -0
  63. package/services/cinema.service.mjs +33 -0
  64. package/services/cinema.service.mjs.map +1 -0
  65. package/services/creator.service.d.mts +11 -0
  66. package/services/creator.service.d.ts +11 -0
  67. package/services/creator.service.js +35 -0
  68. package/services/creator.service.js.map +1 -0
  69. package/services/creator.service.mjs +33 -0
  70. package/services/creator.service.mjs.map +1 -0
  71. package/services/movie.service.d.mts +11 -0
  72. package/services/movie.service.d.ts +11 -0
  73. package/services/movie.service.js +62 -0
  74. package/services/movie.service.js.map +1 -0
  75. package/services/movie.service.mjs +60 -0
  76. package/services/movie.service.mjs.map +1 -0
  77. package/services/search.service.d.mts +10 -0
  78. package/services/search.service.d.ts +10 -0
  79. package/services/search.service.js +81 -0
  80. package/services/search.service.js.map +1 -0
  81. package/services/search.service.mjs +79 -0
  82. package/services/search.service.mjs.map +1 -0
  83. package/services/user-ratings.service.d.mts +12 -0
  84. package/services/user-ratings.service.d.ts +12 -0
  85. package/services/user-ratings.service.js +66 -0
  86. package/services/user-ratings.service.js.map +1 -0
  87. package/services/user-ratings.service.mjs +64 -0
  88. package/services/user-ratings.service.mjs.map +1 -0
  89. package/{cjs/vars.js → vars.js} +13 -7
  90. package/vars.js.map +1 -0
  91. package/vars.mjs +12 -0
  92. package/vars.mjs.map +1 -0
  93. package/cjs/fetchers/index.js +0 -41
  94. package/cjs/helpers/creator.helper.js +0 -86
  95. package/cjs/helpers/global.helper.js +0 -64
  96. package/cjs/helpers/movie.helper.js +0 -248
  97. package/cjs/helpers/search-user.helper.js +0 -22
  98. package/cjs/helpers/search.helper.js +0 -60
  99. package/cjs/helpers/user-ratings.helper.js +0 -60
  100. package/cjs/index.js +0 -50
  101. package/cjs/services/creator.service.js +0 -43
  102. package/cjs/services/movie.service.js +0 -69
  103. package/cjs/services/search.service.js +0 -91
  104. package/cjs/services/user-ratings.service.js +0 -95
  105. package/esm/fetchers/index.js +0 -37
  106. package/esm/helpers/creator.helper.js +0 -73
  107. package/esm/helpers/global.helper.js +0 -56
  108. package/esm/helpers/movie.helper.js +0 -223
  109. package/esm/helpers/search-user.helper.js +0 -15
  110. package/esm/helpers/search.helper.js +0 -49
  111. package/esm/helpers/user-ratings.helper.js +0 -47
  112. package/esm/index.js +0 -46
  113. package/esm/services/creator.service.js +0 -39
  114. package/esm/services/movie.service.js +0 -65
  115. package/esm/services/search.service.js +0 -87
  116. package/esm/services/user-ratings.service.js +0 -91
  117. package/esm/vars.js +0 -4
  118. package/types/fetchers/index.d.ts +0 -1
  119. package/types/helpers/creator.helper.d.ts +0 -17
  120. package/types/helpers/global.helper.d.ts +0 -7
  121. package/types/helpers/movie.helper.d.ts +0 -25
  122. package/types/helpers/search-user.helper.d.ts +0 -5
  123. package/types/helpers/search.helper.d.ts +0 -11
  124. package/types/helpers/user-ratings.helper.d.ts +0 -13
  125. package/types/index.d.ts +0 -20
  126. package/types/index.ts +0 -22
  127. package/types/interfaces/creator.interface.d.ts +0 -12
  128. package/types/interfaces/global.d.ts +0 -22
  129. package/types/interfaces/movie.interface.d.ts +0 -66
  130. package/types/interfaces/search.interface.d.ts +0 -27
  131. package/types/interfaces/user-ratings.interface.d.ts +0 -18
  132. package/types/services/creator.service.d.ts +0 -6
  133. package/types/services/movie.service.d.ts +0 -6
  134. package/types/services/search.service.d.ts +0 -5
  135. package/types/services/user-ratings.service.d.ts +0 -7
  136. package/types/vars.d.ts +0 -4
@@ -1,47 +0,0 @@
1
- import { parseIdFromUrl } from './global.helper';
2
- export const getId = (el) => {
3
- const url = el.querySelector('td.name .film-title-name').attributes.href;
4
- return parseIdFromUrl(url);
5
- };
6
- export const getUserRating = (el) => {
7
- const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();
8
- const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;
9
- return rating;
10
- };
11
- export const getType = (el) => {
12
- const typeText = el.querySelectorAll('td.name .film-title-info .info');
13
- return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film');
14
- };
15
- export const getTitle = (el) => {
16
- return el.querySelector('td.name .film-title-name').text;
17
- };
18
- export const getYear = (el) => {
19
- return +el.querySelectorAll('td.name .film-title-info .info')[0].text.slice(1, -1);
20
- };
21
- export const getColorRating = (el) => {
22
- const color = parseColor(el.querySelector('td.name .icon').classNames.split(' ').pop());
23
- return color;
24
- };
25
- export const getDate = (el) => {
26
- return el.querySelector('td.date-only').text.trim();
27
- };
28
- export const getUrl = (el) => {
29
- const url = el.querySelector('td.name .film-title-name').attributes.href;
30
- return `https://www.csfd.cz${url}`;
31
- };
32
- export const parseColor = (quality) => {
33
- switch (quality) {
34
- case 'lightgrey':
35
- return 'unknown';
36
- case 'red':
37
- return 'good';
38
- case 'blue':
39
- return 'average';
40
- case 'grey':
41
- return 'bad';
42
- default:
43
- return 'unknown';
44
- }
45
- };
46
- // Sleep in loop
47
- export const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
package/esm/index.js DELETED
@@ -1,46 +0,0 @@
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
- };
10
- import { CreatorScraper } from './services/creator.service';
11
- import { MovieScraper } from './services/movie.service';
12
- import { SearchScraper } from './services/search.service';
13
- import { UserRatingsScraper } from './services/user-ratings.service';
14
- export class Csfd {
15
- constructor(userRatingsService, movieService, creatorService, searchService) {
16
- this.userRatingsService = userRatingsService;
17
- this.movieService = movieService;
18
- this.creatorService = creatorService;
19
- this.searchService = searchService;
20
- }
21
- userRatings(user, config) {
22
- return __awaiter(this, void 0, void 0, function* () {
23
- return this.userRatingsService.userRatings(user, config);
24
- });
25
- }
26
- movie(movie) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- return this.movieService.movie(+movie);
29
- });
30
- }
31
- creator(creator) {
32
- return __awaiter(this, void 0, void 0, function* () {
33
- return this.creatorService.creator(+creator);
34
- });
35
- }
36
- search(text) {
37
- return __awaiter(this, void 0, void 0, function* () {
38
- return this.searchService.search(text);
39
- });
40
- }
41
- }
42
- const movieScraper = new MovieScraper();
43
- const userRatingsScraper = new UserRatingsScraper();
44
- const creatorScraper = new CreatorScraper();
45
- const searchScraper = new SearchScraper();
46
- export const csfd = new Csfd(userRatingsScraper, movieScraper, creatorScraper, searchScraper);
@@ -1,39 +0,0 @@
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
- };
10
- import { parse } from 'node-html-parser';
11
- import { fetchPage } from '../fetchers';
12
- import { getBio, getBirthdayInfo, getFilms, getName, getPhoto } from '../helpers/creator.helper';
13
- import { creatorUrl } from '../vars';
14
- export class CreatorScraper {
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
- });
25
- }
26
- buildCreator(id, asideEl, filmsNode) {
27
- var _a, _b, _c;
28
- this.person = {
29
- id,
30
- name: getName(asideEl),
31
- birthday: (_a = getBirthdayInfo(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
32
- birthplace: (_b = getBirthdayInfo(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
33
- photo: getPhoto(asideEl),
34
- age: ((_c = getBirthdayInfo(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
35
- bio: getBio(asideEl),
36
- films: getFilms(filmsNode)
37
- };
38
- }
39
- }
@@ -1,65 +0,0 @@
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
- };
10
- import { parse } from 'node-html-parser';
11
- import { fetchPage } from '../fetchers';
12
- import { getBoxMovies, getColorRating, getDescriptions, getDuration, getGenres, getGroup, getOrigins, getPoster, getPremieres, getRandomPhoto, getRating, getRatingCount, getTags, getTitle, getTitlesOther, getTrivia, getType, getVods, getYear } from '../helpers/movie.helper';
13
- import { movieUrl } from '../vars';
14
- export class MovieScraper {
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
- });
27
- }
28
- buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
29
- this.film = {
30
- id: movieId,
31
- title: getTitle(el),
32
- year: getYear(jsonLd),
33
- duration: getDuration(jsonLd, el),
34
- descriptions: getDescriptions(el),
35
- genres: getGenres(el),
36
- type: getType(el),
37
- url: movieUrl(movieId),
38
- origins: getOrigins(el),
39
- colorRating: getColorRating(pageClasses),
40
- rating: getRating(asideEl),
41
- ratingCount: getRatingCount(asideEl),
42
- titlesOther: getTitlesOther(el),
43
- poster: getPoster(el),
44
- photo: getRandomPhoto(el),
45
- trivia: getTrivia(el),
46
- creators: {
47
- directors: getGroup(el, 'Režie'),
48
- writers: getGroup(el, 'Scénář'),
49
- cinematography: getGroup(el, 'Kamera'),
50
- music: getGroup(el, 'Hudba'),
51
- actors: getGroup(el, 'Hrají'),
52
- basedOn: getGroup(el, 'Předloha'),
53
- producers: getGroup(el, 'Produkce'),
54
- filmEditing: getGroup(el, 'Střih'),
55
- costumeDesign: getGroup(el, 'Kostýmy'),
56
- productionDesign: getGroup(el, 'Scénografie')
57
- },
58
- vod: getVods(asideEl),
59
- tags: getTags(asideEl),
60
- premieres: getPremieres(asideEl),
61
- related: getBoxMovies(asideEl, 'Související'),
62
- similar: getBoxMovies(asideEl, 'Podobné')
63
- };
64
- }
65
- }
@@ -1,87 +0,0 @@
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
- };
10
- import { parse } from 'node-html-parser';
11
- import { fetchPage } from '../fetchers';
12
- import { parseIdFromUrl } from '../helpers/global.helper';
13
- import { getAvatar, getUser, getUserRealName, getUserUrl } from '../helpers/search-user.helper';
14
- import { getColorRating, getOrigins, getPoster, getTitle, getType, getUrl, getYear, parsePeople } from '../helpers/search.helper';
15
- import { searchUrl } from '../vars';
16
- export class SearchScraper {
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
- });
27
- }
28
- parseSearch(moviesNode, usersNode, tvSeriesNode) {
29
- const movies = [];
30
- const users = [];
31
- const tvSeries = [];
32
- moviesNode.map((m) => {
33
- const url = getUrl(m);
34
- const movie = {
35
- id: parseIdFromUrl(url),
36
- title: getTitle(m),
37
- year: getYear(m),
38
- url: `https://www.csfd.cz${url}`,
39
- type: getType(m),
40
- colorRating: getColorRating(m),
41
- poster: getPoster(m),
42
- origins: getOrigins(m),
43
- creators: {
44
- directors: parsePeople(m, 'directors'),
45
- actors: parsePeople(m, 'actors')
46
- }
47
- };
48
- movies.push(movie);
49
- });
50
- usersNode.map((m) => {
51
- const url = getUserUrl(m);
52
- const user = {
53
- id: parseIdFromUrl(url),
54
- user: getUser(m),
55
- userRealName: getUserRealName(m),
56
- avatar: getAvatar(m),
57
- url: `https://www.csfd.cz${url}`
58
- };
59
- users.push(user);
60
- });
61
- tvSeriesNode.map((m) => {
62
- const url = getUrl(m);
63
- const user = {
64
- id: parseIdFromUrl(url),
65
- title: getTitle(m),
66
- year: getYear(m),
67
- url: `https://www.csfd.cz${url}`,
68
- type: getType(m),
69
- colorRating: getColorRating(m),
70
- poster: getPoster(m),
71
- origins: getOrigins(m),
72
- creators: {
73
- directors: parsePeople(m, 'directors'),
74
- actors: parsePeople(m, 'actors')
75
- }
76
- };
77
- tvSeries.push(user);
78
- });
79
- const search = {
80
- movies: movies,
81
- users: users,
82
- tvSeries: tvSeries,
83
- creators: []
84
- };
85
- return search;
86
- }
87
- }
@@ -1,91 +0,0 @@
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
- };
10
- import { parse } from 'node-html-parser';
11
- import { fetchPage } from '../fetchers';
12
- import { getColorRating, getDate, getId, getTitle, getType, getUrl, getUserRating, getYear, sleep } from '../helpers/user-ratings.helper';
13
- import { userRatingsUrl } from '../vars';
14
- export class UserRatingsScraper {
15
- constructor() {
16
- this.films = [];
17
- }
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
- }
43
- }
44
- return allMovies;
45
- }
46
- return allMovies;
47
- });
48
- }
49
- getPage(config, movies) {
50
- var _a, _b, _c, _d;
51
- if (config) {
52
- if (((_a = config.includesOnly) === null || _a === void 0 ? void 0 : _a.length) && ((_b = config.excludes) === null || _b === void 0 ? void 0 : _b.length)) {
53
- console.warn(`node-csfd-api:
54
- You can not use both parameters 'includesOnly' and 'excludes'.
55
- Parameter 'includesOnly' will be used now:`, config.includesOnly);
56
- }
57
- }
58
- for (const el of movies) {
59
- const type = getType(el);
60
- // Filtering includesOnly
61
- if ((_c = config === null || config === void 0 ? void 0 : config.includesOnly) === null || _c === void 0 ? void 0 : _c.length) {
62
- if (config.includesOnly.some((include) => type === include)) {
63
- this.buildUserRatings(el);
64
- }
65
- // Filter exludes
66
- }
67
- else if ((_d = config === null || config === void 0 ? void 0 : config.excludes) === null || _d === void 0 ? void 0 : _d.length) {
68
- if (!config.excludes.some((exclude) => type === exclude)) {
69
- this.buildUserRatings(el);
70
- }
71
- }
72
- else {
73
- // Without filtering
74
- this.buildUserRatings(el);
75
- }
76
- }
77
- return this.films;
78
- }
79
- buildUserRatings(el) {
80
- this.films.push({
81
- id: getId(el),
82
- title: getTitle(el),
83
- year: getYear(el),
84
- type: getType(el),
85
- url: getUrl(el),
86
- colorRating: getColorRating(el),
87
- userDate: getDate(el),
88
- userRating: getUserRating(el)
89
- });
90
- }
91
- }
package/esm/vars.js DELETED
@@ -1,4 +0,0 @@
1
- export const userRatingsUrl = (user, page) => `https://www.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/${page ? '?page=' + page : ''}`;
2
- export const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}/prehled/`;
3
- export const creatorUrl = (creator) => `https://www.csfd.cz/tvurce/${encodeURIComponent(creator)}`;
4
- export const searchUrl = (text) => `https://www.csfd.cz/hledat/?q=${encodeURIComponent(text)}`;
@@ -1 +0,0 @@
1
- export declare const fetchPage: (url: string) => Promise<string>;
@@ -1,17 +0,0 @@
1
- import { HTMLElement } from 'node-html-parser';
2
- import { CSFDCreatorScreening } from '../interfaces/creator.interface';
3
- import { CSFDColorRating } from '../interfaces/global';
4
- export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
5
- export declare const getId: (url: string) => number;
6
- export declare const getName: (el: HTMLElement | null) => string;
7
- export declare const getBirthdayInfo: (el: HTMLElement | null) => {
8
- birthday: string;
9
- age: number;
10
- birthPlace: string;
11
- };
12
- export declare const getBio: (el: HTMLElement | null) => string;
13
- export declare const getPhoto: (el: HTMLElement | null) => string;
14
- export declare const parseBirthday: (text: string) => any;
15
- export declare const parseAge: (text: string) => any;
16
- export declare const parseBirthPlace: (text: string) => any;
17
- export declare const getFilms: (el: HTMLElement | null) => CSFDCreatorScreening[];
@@ -1,7 +0,0 @@
1
- import { CSFDColorRating } from '../interfaces/global';
2
- import { Colors } from '../interfaces/user-ratings.interface';
3
- export declare const parseIdFromUrl: (url: string) => number;
4
- export declare const getColor: (cls: string) => CSFDColorRating;
5
- export declare const parseColor: (quality: Colors) => CSFDColorRating;
6
- export declare const addProtocol: (url: string) => string;
7
- export declare const parseISO8601Duration: (iso: string) => number;
@@ -1,25 +0,0 @@
1
- import { HTMLElement } from 'node-html-parser';
2
- import { CSFDColorRating } from '../interfaces/global';
3
- import { CSFDBoxContent, CSFDCreator, CSFDCreatorGroups, CSFDGenres, CSFDMovieListItem, CSFDPremiere, CSFDTitlesOther, CSFDVod } from '../interfaces/movie.interface';
4
- export declare const getId: (el: HTMLElement) => number;
5
- export declare const getTitle: (el: HTMLElement) => string;
6
- export declare const getGenres: (el: HTMLElement) => CSFDGenres[];
7
- export declare const getOrigins: (el: HTMLElement) => string[];
8
- export declare const getColorRating: (bodyClasses: string[]) => CSFDColorRating;
9
- export declare const getRating: (el: HTMLElement) => number;
10
- export declare const getRatingCount: (el: HTMLElement) => number;
11
- export declare const getYear: (el: string) => number;
12
- export declare const getDuration: (jsonLdRaw: string, el: HTMLElement) => number;
13
- export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
14
- export declare const getPoster: (el: HTMLElement | null) => string;
15
- export declare const getRandomPhoto: (el: HTMLElement | null) => string;
16
- export declare const getTrivia: (el: HTMLElement | null) => string[];
17
- export declare const getDescriptions: (el: HTMLElement) => string[];
18
- export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
19
- export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
20
- export declare const getType: (el: HTMLElement) => string;
21
- export declare const getVods: (el: HTMLElement | null) => CSFDVod[];
22
- export declare const getBoxContent: (el: HTMLElement, box: string) => HTMLElement;
23
- export declare const getBoxMovies: (el: HTMLElement, boxName: CSFDBoxContent) => CSFDMovieListItem[];
24
- export declare const getPremieres: (el: HTMLElement) => CSFDPremiere[];
25
- export declare const getTags: (el: HTMLElement) => string[];
@@ -1,5 +0,0 @@
1
- import { HTMLElement } from 'node-html-parser';
2
- export declare const getUser: (el: HTMLElement) => string;
3
- export declare const getUserRealName: (el: HTMLElement) => string;
4
- export declare const getAvatar: (el: HTMLElement) => string;
5
- export declare const getUserUrl: (el: HTMLElement) => string;
@@ -1,11 +0,0 @@
1
- import { HTMLElement } from 'node-html-parser';
2
- import { CSFDColorRating, CSFDFilmTypes } from '../interfaces/global';
3
- import { CSFDCreator } from '../interfaces/movie.interface';
4
- export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
5
- export declare const getTitle: (el: HTMLElement) => string;
6
- export declare const getYear: (el: HTMLElement) => number;
7
- export declare const getUrl: (el: HTMLElement) => string;
8
- export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
9
- export declare const getPoster: (el: HTMLElement) => string;
10
- export declare const getOrigins: (el: HTMLElement) => string[];
11
- export declare const parsePeople: (el: HTMLElement, type: 'directors' | 'actors') => CSFDCreator[];
@@ -1,13 +0,0 @@
1
- import { HTMLElement } from 'node-html-parser';
2
- import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../interfaces/global';
3
- import { Colors } from '../interfaces/user-ratings.interface';
4
- export declare const getId: (el: HTMLElement) => number;
5
- export declare const getUserRating: (el: HTMLElement) => CSFDStars;
6
- export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
7
- export declare const getTitle: (el: HTMLElement) => string;
8
- export declare const getYear: (el: HTMLElement) => number;
9
- export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
10
- export declare const getDate: (el: HTMLElement) => string;
11
- export declare const getUrl: (el: HTMLElement) => string;
12
- export declare const parseColor: (quality: Colors) => CSFDColorRating;
13
- export declare const sleep: (ms: number) => Promise<unknown>;
package/types/index.d.ts DELETED
@@ -1,20 +0,0 @@
1
- import { CSFDCreator } from './interfaces/creator.interface';
2
- import { CSFDMovie } from './interfaces/movie.interface';
3
- import { CSFDSearch } from './interfaces/search.interface';
4
- import { CSFDUserRatingConfig, CSFDUserRatings } from './interfaces/user-ratings.interface';
5
- import { CreatorScraper } from './services/creator.service';
6
- import { MovieScraper } from './services/movie.service';
7
- import { SearchScraper } from './services/search.service';
8
- import { UserRatingsScraper } from './services/user-ratings.service';
9
- export declare class Csfd {
10
- private userRatingsService;
11
- private movieService;
12
- private creatorService;
13
- private searchService;
14
- constructor(userRatingsService: UserRatingsScraper, movieService: MovieScraper, creatorService: CreatorScraper, searchService: SearchScraper);
15
- userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
16
- movie(movie: number): Promise<CSFDMovie>;
17
- creator(creator: number): Promise<CSFDCreator>;
18
- search(text: string): Promise<CSFDSearch>;
19
- }
20
- export declare const csfd: Csfd;
package/types/index.ts DELETED
@@ -1,22 +0,0 @@
1
- /**
2
- * @file Automatically generated by barrelsby.
3
- */
4
-
5
- export * from "./index";
6
- export * from "./vars";
7
- export * from "./fetchers/index";
8
- export * from "./helpers/creator.helper";
9
- export * from "./helpers/global.helper";
10
- export * from "./helpers/movie.helper";
11
- export * from "./helpers/search-user.helper";
12
- export * from "./helpers/search.helper";
13
- export * from "./helpers/user-ratings.helper";
14
- export * from "./interfaces/creator.interface";
15
- export * from "./interfaces/global";
16
- export * from "./interfaces/movie.interface";
17
- export * from "./interfaces/search.interface";
18
- export * from "./interfaces/user-ratings.interface";
19
- export * from "./services/creator.service";
20
- export * from "./services/movie.service";
21
- export * from "./services/search.service";
22
- export * from "./services/user-ratings.service";
@@ -1,12 +0,0 @@
1
- import { CSFDScreening } from './global';
2
- export interface CSFDCreator {
3
- id: number;
4
- name: string;
5
- birthday: string;
6
- birthplace: string;
7
- photo: string;
8
- age: number | string;
9
- bio: string;
10
- films: CSFDCreatorScreening[];
11
- }
12
- export type CSFDCreatorScreening = Omit<CSFDScreening, 'url' | 'type'>;
@@ -1,22 +0,0 @@
1
- export interface CSFDScreening {
2
- id: number;
3
- title: string;
4
- year: number;
5
- url: string;
6
- type: CSFDFilmTypes;
7
- /**
8
- * Overall aggregated rating. (On the web usually represented by colors).
9
- *
10
- * 'unknown': unknown (gray color)
11
- *
12
- * 'good': 70% – 100 % (red color)
13
- *
14
- * 'average': 30% - 69% (blue color)
15
- *
16
- * 'bad': 0% - 29% (black color)
17
- */
18
- colorRating: CSFDColorRating;
19
- }
20
- export type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown';
21
- export type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5;
22
- export type CSFDFilmTypes = 'film' | 'TV film' | 'pořad' | 'seriál' | 'divadelní záznam' | 'koncert' | 'série' | 'studentský film' | 'amatérský film' | 'hudební videoklip' | 'epizoda';
@@ -1,66 +0,0 @@
1
- import { CSFDScreening } from './global';
2
- export interface CSFDMovie extends CSFDScreening {
3
- rating: number | null;
4
- poster: string;
5
- photo: string;
6
- ratingCount: number | null;
7
- duration: number | string;
8
- titlesOther: CSFDTitlesOther[];
9
- origins: string[];
10
- descriptions: string[];
11
- trivia: string[];
12
- genres: CSFDGenres[] | string[];
13
- creators: CSFDCreators;
14
- vod: CSFDVod[];
15
- tags: string[];
16
- premieres: CSFDPremiere[];
17
- related: CSFDMovieListItem[];
18
- similar: CSFDMovieListItem[];
19
- }
20
- export type CSFDVodService = 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'iTunes' | 'KVIFF.TV' | 'Edisonline' | 'o2tv' | 'SledovaniTV' | 'Starmax' | 'DAFilms' | 'FILMY ČESKY A ZADARMO' | 'Youtube Česká filmová klasika' | 'VAPET' | 'VOREL FILM' | 'ivysilani' | 'Google Play' | 'Voyo' | 'DVD';
21
- export interface CSFDVod {
22
- title: CSFDVodService;
23
- url: string;
24
- }
25
- export interface CSFDCreators {
26
- directors: CSFDCreator[];
27
- writers: CSFDCreator[];
28
- cinematography: CSFDCreator[];
29
- music: CSFDCreator[];
30
- actors: CSFDCreator[];
31
- basedOn: CSFDCreator[];
32
- producers: CSFDCreator[];
33
- filmEditing: CSFDCreator[];
34
- costumeDesign: CSFDCreator[];
35
- productionDesign: CSFDCreator[];
36
- }
37
- export interface CSFDTitlesOther {
38
- country: string;
39
- title: string;
40
- }
41
- export interface CSFDCreator {
42
- /**
43
- * CSFD person ID.
44
- *
45
- * You can always assemble url from ID like this:
46
- *
47
- * `https://www.csfd.cz/tvurce/${id}`
48
- */
49
- id: number;
50
- name: string;
51
- url: string;
52
- }
53
- export interface CSFDMovieListItem {
54
- id: number;
55
- title: string;
56
- url: string;
57
- }
58
- export type CSFDGenres = 'Akční' | 'Animovaný' | 'Dobrodružný' | 'Dokumentární' | 'Drama' | 'Experimentální' | 'Fantasy' | 'Film-Noir' | 'Historický' | 'Horor' | 'Hudební' | 'IMAX' | 'Katastrofický' | 'Komedie' | 'Krátkometrážní' | 'Krimi' | 'Loutkový' | 'Muzikál' | 'Mysteriózní' | 'Naučný' | 'Podobenství' | 'Poetický' | 'Pohádka' | 'Povídkový' | 'Psychologický' | 'Publicistický' | 'Reality-TV' | 'Road movie' | 'Rodinný' | 'Romantický' | 'Sci-Fi' | 'Soutěžní' | 'Sportovní' | 'Stand-up' | 'Talk-show' | 'Taneční' | 'Telenovela' | 'Thriller' | 'Válečný' | 'Western' | 'Zábavný' | 'Životopisný';
59
- export type CSFDCreatorGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Produkce' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
60
- export interface CSFDPremiere {
61
- country: string;
62
- format: string;
63
- date: string;
64
- company: string;
65
- }
66
- export type CSFDBoxContent = 'Související' | 'Podobné';
@@ -1,27 +0,0 @@
1
- import { CSFDScreening } from './global';
2
- import { CSFDCreator } from './movie.interface';
3
- export interface CSFDSearch {
4
- movies: CSFDSearchMovie[];
5
- tvSeries: CSFDSearchMovie[];
6
- creators: CSFDSearchCreator[];
7
- users: CSFDSearchUser[];
8
- }
9
- export interface CSFDSearchMovie extends CSFDScreening {
10
- poster: string;
11
- origins: string[];
12
- creators: CSFDSearchCreators;
13
- }
14
- export interface CSFDSearchUser {
15
- id: number;
16
- user: string;
17
- userRealName: string;
18
- avatar: string;
19
- url: string;
20
- }
21
- export interface CSFDSearchCreator extends CSFDCreator {
22
- image: string;
23
- }
24
- export interface CSFDSearchCreators {
25
- directors: CSFDCreator[];
26
- actors: CSFDCreator[];
27
- }