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,26 +1,26 @@
1
1
  import { addProtocol, parseColor, parseIdFromUrl } from './global.helper';
2
- export const getType = (el) => {
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 getTitle = (el) => {
6
+ export const getSearchTitle = (el) => {
7
7
  return el.querySelector('.film-title-name').text;
8
8
  };
9
- export const getYear = (el) => {
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 getUrl = (el) => {
13
+ export const getSearchUrl = (el) => {
14
14
  return el.querySelector('.film-title-name').attributes.href;
15
15
  };
16
- export const getColorRating = (el) => {
16
+ export const getSearchColorRating = (el) => {
17
17
  return parseColor(el.querySelector('.article-header i.icon').classNames.split(' ').pop());
18
18
  };
19
- export const getPoster = (el) => {
19
+ export const getSearchPoster = (el) => {
20
20
  const image = el.querySelector('img').attributes.src;
21
21
  return addProtocol(image);
22
22
  };
23
- export const getOrigins = (el) => {
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 parsePeople = (el, type) => {
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 getId = (el) => {
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 getType = (el) => {
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 getTitle = (el) => {
15
+ export const getUserRatingTitle = (el) => {
16
16
  return el.querySelector('td.name .film-title-name').text;
17
17
  };
18
- export const getYear = (el) => {
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 getColorRating = (el) => {
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 getDate = (el) => {
26
+ export const getUserRatingDate = (el) => {
27
27
  return el.querySelector('td.date-only').text.trim();
28
28
  };
29
- export const getUrl = (el) => {
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
- export const parseColor = (quality) => {
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
- async userRatings(user, config) {
15
- return this.userRatingsService.userRatings(user, config);
23
+ userRatings(user, config) {
24
+ return __awaiter(this, void 0, void 0, function* () {
25
+ return this.userRatingsService.userRatings(user, config);
26
+ });
16
27
  }
17
- async movie(movie) {
18
- return this.movieService.movie(+movie);
28
+ movie(movie) {
29
+ return __awaiter(this, void 0, void 0, function* () {
30
+ return this.movieService.movie(+movie);
31
+ });
19
32
  }
20
- async creator(creator) {
21
- return this.creatorService.creator(+creator);
33
+ creator(creator) {
34
+ return __awaiter(this, void 0, void 0, function* () {
35
+ return this.creatorService.creator(+creator);
36
+ });
22
37
  }
23
- async search(text) {
24
- return this.searchService.search(text);
38
+ search(text) {
39
+ return __awaiter(this, void 0, void 0, function* () {
40
+ return this.searchService.search(text);
41
+ });
25
42
  }
26
- async cinema(district, period) {
27
- return this.cinemaService.cinemas(+district, period);
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, getCoords, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
13
+ import { getCinemaCoords, getCinemaId, getCinemaUrl, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
5
14
  export class CinemaScraper {
6
- async cinemas(district = 1, period = 'today') {
7
- const url = cinemasUrl(district, period);
8
- const response = await fetchPage(url);
9
- const cinemasHtml = parse(response);
10
- const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
11
- this.buildCinemas(contentNode);
12
- return this.cinema;
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: getCoords(x),
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 { getBio, getBirthdayInfo, getFilms, getName, getPhoto } from '../helpers/creator.helper';
12
+ import { getCreatorBio, getCreatorBirthdayInfo, getCreatorFilms, getCreatorName, getCreatorPhoto } from '../helpers/creator.helper';
4
13
  import { creatorUrl } from '../vars';
5
14
  export class CreatorScraper {
6
- async creator(creatorId) {
7
- const url = creatorUrl(+creatorId);
8
- const response = await fetchPage(url);
9
- const creatorHtml = parse(response);
10
- const asideNode = creatorHtml.querySelector('.creator-about');
11
- const filmsNode = creatorHtml.querySelector('.creator-filmography');
12
- this.buildCreator(+creatorId, asideNode, filmsNode);
13
- return this.person;
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: getName(asideEl),
20
- birthday: (_a = getBirthdayInfo(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
21
- birthplace: (_b = getBirthdayInfo(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
22
- photo: getPhoto(asideEl),
23
- age: ((_c = getBirthdayInfo(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
24
- bio: getBio(asideEl),
25
- films: getFilms(filmsNode)
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 { getBoxMovies, getColorRating, getDescriptions, getDuration, getGenres, getGroup, getOrigins, getPoster, getPremieres, getRandomPhoto, getRating, getRatingCount, getTags, getTitle, getTitlesOther, getTrivia, getType, getVods, getYear } from '../helpers/movie.helper';
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
- async movie(movieId) {
7
- const url = movieUrl(+movieId);
8
- const response = await fetchPage(url);
9
- const movieHtml = parse(response);
10
- const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');
11
- const asideNode = movieHtml.querySelector('.aside-movie-profile');
12
- const movieNode = movieHtml.querySelector('.main-movie-profile');
13
- const jsonLd = movieHtml.querySelector('script[type="application/ld+json"]').innerText;
14
- this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
15
- return this.film;
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: getTitle(el),
21
- year: getYear(jsonLd),
22
- duration: getDuration(jsonLd, el),
23
- descriptions: getDescriptions(el),
24
- genres: getGenres(el),
25
- type: getType(el),
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: getOrigins(el),
28
- colorRating: getColorRating(pageClasses),
29
- rating: getRating(asideEl),
30
- ratingCount: getRatingCount(asideEl),
31
- titlesOther: getTitlesOther(el),
32
- poster: getPoster(el),
33
- photo: getRandomPhoto(el),
34
- trivia: getTrivia(el),
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: getGroup(el, 'Režie'),
37
- writers: getGroup(el, 'Scénář'),
38
- cinematography: getGroup(el, 'Kamera'),
39
- music: getGroup(el, 'Hudba'),
40
- actors: getGroup(el, 'Hrají'),
41
- basedOn: getGroup(el, 'Předloha'),
42
- producers: getGroup(el, 'Produkce'),
43
- filmEditing: getGroup(el, 'Střih'),
44
- costumeDesign: getGroup(el, 'Kostýmy'),
45
- productionDesign: getGroup(el, 'Scénografie')
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: getVods(asideEl),
48
- tags: getTags(asideEl),
49
- premieres: getPremieres(asideEl),
50
- related: getBoxMovies(asideEl, 'Související'),
51
- similar: getBoxMovies(asideEl, 'Podobné')
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 { getColorRating, getOrigins, getPoster, getTitle, getType, getUrl, getYear, parsePeople } from '../helpers/search.helper';
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
- async search(text) {
9
- const url = searchUrl(text);
10
- const response = await fetchPage(url);
11
- const html = parse(response);
12
- const moviesNode = html.querySelectorAll('.main-movies article');
13
- const usersNode = html.querySelectorAll('.main-users article');
14
- const tvSeriesNode = html.querySelectorAll('.main-series article');
15
- return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
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 = getUrl(m);
33
+ const url = getSearchUrl(m);
23
34
  const movie = {
24
35
  id: parseIdFromUrl(url),
25
- title: getTitle(m),
26
- year: getYear(m),
36
+ title: getSearchTitle(m),
37
+ year: getSearchYear(m),
27
38
  url: `https://www.csfd.cz${url}`,
28
- type: getType(m),
29
- colorRating: getColorRating(m),
30
- poster: getPoster(m),
31
- origins: getOrigins(m),
39
+ type: getSearchType(m),
40
+ colorRating: getSearchColorRating(m),
41
+ poster: getSearchPoster(m),
42
+ origins: getSearchOrigins(m),
32
43
  creators: {
33
- directors: parsePeople(m, 'directors'),
34
- actors: parsePeople(m, '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 = getUrl(m);
62
+ const url = getSearchUrl(m);
52
63
  const user = {
53
64
  id: parseIdFromUrl(url),
54
- title: getTitle(m),
55
- year: getYear(m),
65
+ title: getSearchTitle(m),
66
+ year: getSearchYear(m),
56
67
  url: `https://www.csfd.cz${url}`,
57
- type: getType(m),
58
- colorRating: getColorRating(m),
59
- poster: getPoster(m),
60
- origins: getOrigins(m),
68
+ type: getSearchType(m),
69
+ colorRating: getSearchColorRating(m),
70
+ poster: getSearchPoster(m),
71
+ origins: getSearchOrigins(m),
61
72
  creators: {
62
- directors: parsePeople(m, 'directors'),
63
- actors: parsePeople(m, '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 { getColorRating, getDate, getId, getTitle, getType, getUrl, getUserRating, getYear, sleep } from '../helpers/user-ratings.helper';
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
- async userRatings(user, config) {
10
- let allMovies = [];
11
- const url = userRatingsUrl(user);
12
- const response = await fetchPage(url);
13
- const items = parse(response);
14
- const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
15
- // Get number of pages
16
- const pagesNode = items.querySelector('.pagination');
17
- const pages = +(pagesNode === null || pagesNode === void 0 ? void 0 : pagesNode.childNodes[pagesNode.childNodes.length - 4].rawText) || 1;
18
- allMovies = this.getPage(config, movies);
19
- if (config === null || config === void 0 ? void 0 : config.allPages) {
20
- console.log('User', user, url);
21
- console.log('Fetching all pages', pages);
22
- for (let i = 2; i <= pages; i++) {
23
- console.log('Fetching page', i, 'out of', pages, '...');
24
- const url = userRatingsUrl(user, i);
25
- const response = await fetchPage(url);
26
- const items = parse(response);
27
- const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
28
- allMovies = [...this.getPage(config, movies)];
29
- // Sleep
30
- if (config.allPagesDelay) {
31
- await sleep(config.allPagesDelay);
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 = getType(el);
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: getId(el),
71
- title: getTitle(el),
72
- year: getYear(el),
73
- type: getType(el),
74
- url: getUrl(el),
75
- colorRating: getColorRating(el),
76
- userDate: getDate(el),
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.22",
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 dist/esm dist/cjs",
18
- "build:cjs": "tsc --project tsconfig.json",
19
- "build:esm": "tsc --project tsconfig.esm.json",
20
- "build": "npm run build:cjs && npm run build:esm",
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
- export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
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 getId: (url: string) => number | null;
7
- export declare const getCoords: (el: HTMLElement | null) => {
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 getFilms: (date: string, el: HTMLElement | null) => CSFDCinemaMovie[];
17
+ export declare const getCinemaFilms: (date: string, el: HTMLElement | null) => CSFDCinemaMovie[];
18
18
  export declare const parseMeta: (meta: string[]) => CSFDCinemaMeta[];