node-csfd-api 3.0.0-next.21 → 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.
Files changed (50) hide show
  1. package/esm/fetchers/fetch.polyfill.js +6 -0
  2. package/esm/fetchers/index.js +23 -0
  3. package/esm/helpers/cinema.helper.js +93 -0
  4. package/esm/helpers/creator.helper.js +74 -0
  5. package/esm/helpers/global.helper.js +59 -0
  6. package/esm/helpers/movie.helper.js +228 -0
  7. package/esm/helpers/search-user.helper.js +15 -0
  8. package/esm/helpers/search.helper.js +51 -0
  9. package/esm/helpers/user-ratings.helper.js +48 -0
  10. package/esm/index.js +35 -0
  11. package/esm/interfaces/cinema.interface.js +1 -0
  12. package/esm/interfaces/creator.interface.js +1 -0
  13. package/esm/interfaces/global.js +1 -0
  14. package/esm/interfaces/movie.interface.js +1 -0
  15. package/esm/interfaces/search.interface.js +1 -0
  16. package/esm/interfaces/user-ratings.interface.js +1 -0
  17. package/esm/services/cinema.service.js +30 -0
  18. package/esm/services/creator.service.js +28 -0
  19. package/esm/services/movie.service.js +54 -0
  20. package/esm/services/search.service.js +76 -0
  21. package/esm/services/user-ratings.service.js +80 -0
  22. package/esm/types/fetchers/fetch.polyfill.d.ts +1 -0
  23. package/esm/types/fetchers/index.d.ts +1 -0
  24. package/esm/types/helpers/cinema.helper.d.ts +18 -0
  25. package/esm/types/helpers/creator.helper.d.ts +17 -0
  26. package/esm/types/helpers/global.helper.d.ts +17 -0
  27. package/esm/types/helpers/movie.helper.d.ts +25 -0
  28. package/esm/types/helpers/search-user.helper.d.ts +5 -0
  29. package/esm/types/helpers/search.helper.d.ts +11 -0
  30. package/esm/types/helpers/user-ratings.helper.d.ts +13 -0
  31. package/esm/types/index.d.ts +24 -0
  32. package/esm/types/interfaces/cinema.interface.d.ts +23 -0
  33. package/esm/types/interfaces/creator.interface.d.ts +12 -0
  34. package/esm/types/interfaces/global.d.ts +22 -0
  35. package/esm/types/interfaces/movie.interface.d.ts +66 -0
  36. package/esm/types/interfaces/search.interface.d.ts +27 -0
  37. package/esm/types/interfaces/user-ratings.interface.d.ts +18 -0
  38. package/esm/types/services/cinema.service.d.ts +6 -0
  39. package/esm/types/services/creator.service.d.ts +6 -0
  40. package/esm/types/services/movie.service.d.ts +6 -0
  41. package/esm/types/services/search.service.d.ts +5 -0
  42. package/esm/types/services/user-ratings.service.d.ts +7 -0
  43. package/esm/types/vars.d.ts +6 -0
  44. package/esm/vars.js +7 -0
  45. package/helpers/cinema.helper.d.ts +2 -3
  46. package/helpers/cinema.helper.js +6 -6
  47. package/index.d.ts +1 -1
  48. package/package.json +14 -6
  49. package/services/cinema.service.js +4 -4
  50. package/services/search.service.js +3 -3
@@ -0,0 +1,30 @@
1
+ import { parse } from 'node-html-parser';
2
+ import { fetchPage } from '../fetchers';
3
+ import { cinemasUrl } from '../vars';
4
+ import { getCinemaId, getCinemaUrl, getCoords, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
5
+ 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;
13
+ }
14
+ buildCinemas(contentNode) {
15
+ const cinemas = [];
16
+ contentNode.forEach((x) => {
17
+ const cinemaInfo = parseCinema(x);
18
+ const cinema = {
19
+ id: getCinemaId(x),
20
+ name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
21
+ city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
22
+ url: getCinemaUrl(x),
23
+ coords: getCoords(x),
24
+ screenings: getGroupedFilmsByDate(x)
25
+ };
26
+ cinemas.push(cinema);
27
+ });
28
+ this.cinema = cinemas;
29
+ }
30
+ }
@@ -0,0 +1,28 @@
1
+ import { parse } from 'node-html-parser';
2
+ import { fetchPage } from '../fetchers';
3
+ import { getBio, getBirthdayInfo, getFilms, getName, getPhoto } from '../helpers/creator.helper';
4
+ import { creatorUrl } from '../vars';
5
+ 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;
14
+ }
15
+ buildCreator(id, asideEl, filmsNode) {
16
+ var _a, _b, _c;
17
+ this.person = {
18
+ 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)
26
+ };
27
+ }
28
+ }
@@ -0,0 +1,54 @@
1
+ import { parse } from 'node-html-parser';
2
+ 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';
4
+ import { movieUrl } from '../vars';
5
+ 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;
16
+ }
17
+ buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
18
+ this.film = {
19
+ 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),
26
+ 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),
35
+ 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')
46
+ },
47
+ vod: getVods(asideEl),
48
+ tags: getTags(asideEl),
49
+ premieres: getPremieres(asideEl),
50
+ related: getBoxMovies(asideEl, 'Související'),
51
+ similar: getBoxMovies(asideEl, 'Podobné')
52
+ };
53
+ }
54
+ }
@@ -0,0 +1,76 @@
1
+ import { parse } from 'node-html-parser';
2
+ import { fetchPage } from '../fetchers';
3
+ import { parseIdFromUrl } from '../helpers/global.helper';
4
+ import { getAvatar, getUser, getUserRealName, getUserUrl } from '../helpers/search-user.helper';
5
+ import { getColorRating, getOrigins, getPoster, getTitle, getType, getUrl, getYear, parsePeople } from '../helpers/search.helper';
6
+ import { searchUrl } from '../vars';
7
+ 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);
16
+ }
17
+ parseSearch(moviesNode, usersNode, tvSeriesNode) {
18
+ const movies = [];
19
+ const users = [];
20
+ const tvSeries = [];
21
+ moviesNode.forEach((m) => {
22
+ const url = getUrl(m);
23
+ const movie = {
24
+ id: parseIdFromUrl(url),
25
+ title: getTitle(m),
26
+ year: getYear(m),
27
+ url: `https://www.csfd.cz${url}`,
28
+ type: getType(m),
29
+ colorRating: getColorRating(m),
30
+ poster: getPoster(m),
31
+ origins: getOrigins(m),
32
+ creators: {
33
+ directors: parsePeople(m, 'directors'),
34
+ actors: parsePeople(m, 'actors')
35
+ }
36
+ };
37
+ movies.push(movie);
38
+ });
39
+ usersNode.forEach((m) => {
40
+ const url = getUserUrl(m);
41
+ const user = {
42
+ id: parseIdFromUrl(url),
43
+ user: getUser(m),
44
+ userRealName: getUserRealName(m),
45
+ avatar: getAvatar(m),
46
+ url: `https://www.csfd.cz${url}`
47
+ };
48
+ users.push(user);
49
+ });
50
+ tvSeriesNode.forEach((m) => {
51
+ const url = getUrl(m);
52
+ const user = {
53
+ id: parseIdFromUrl(url),
54
+ title: getTitle(m),
55
+ year: getYear(m),
56
+ url: `https://www.csfd.cz${url}`,
57
+ type: getType(m),
58
+ colorRating: getColorRating(m),
59
+ poster: getPoster(m),
60
+ origins: getOrigins(m),
61
+ creators: {
62
+ directors: parsePeople(m, 'directors'),
63
+ actors: parsePeople(m, 'actors')
64
+ }
65
+ };
66
+ tvSeries.push(user);
67
+ });
68
+ const search = {
69
+ movies: movies,
70
+ users: users,
71
+ tvSeries: tvSeries,
72
+ creators: []
73
+ };
74
+ return search;
75
+ }
76
+ }
@@ -0,0 +1,80 @@
1
+ import { parse } from 'node-html-parser';
2
+ import { fetchPage } from '../fetchers';
3
+ import { getColorRating, getDate, getId, getTitle, getType, getUrl, getUserRating, getYear, sleep } from '../helpers/user-ratings.helper';
4
+ import { userRatingsUrl } from '../vars';
5
+ export class UserRatingsScraper {
6
+ constructor() {
7
+ this.films = [];
8
+ }
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);
32
+ }
33
+ }
34
+ return allMovies;
35
+ }
36
+ return allMovies;
37
+ }
38
+ getPage(config, movies) {
39
+ var _a, _b, _c, _d;
40
+ if (config) {
41
+ if (((_a = config.includesOnly) === null || _a === void 0 ? void 0 : _a.length) && ((_b = config.excludes) === null || _b === void 0 ? void 0 : _b.length)) {
42
+ console.warn(`node-csfd-api:
43
+ You can not use both parameters 'includesOnly' and 'excludes'.
44
+ Parameter 'includesOnly' will be used now:`, config.includesOnly);
45
+ }
46
+ }
47
+ for (const el of movies) {
48
+ const type = getType(el);
49
+ // Filtering includesOnly
50
+ if ((_c = config === null || config === void 0 ? void 0 : config.includesOnly) === null || _c === void 0 ? void 0 : _c.length) {
51
+ if (config.includesOnly.some((include) => type === include)) {
52
+ this.buildUserRatings(el);
53
+ }
54
+ // Filter exludes
55
+ }
56
+ else if ((_d = config === null || config === void 0 ? void 0 : config.excludes) === null || _d === void 0 ? void 0 : _d.length) {
57
+ if (!config.excludes.some((exclude) => type === exclude)) {
58
+ this.buildUserRatings(el);
59
+ }
60
+ }
61
+ else {
62
+ // Without filtering
63
+ this.buildUserRatings(el);
64
+ }
65
+ }
66
+ return this.films;
67
+ }
68
+ buildUserRatings(el) {
69
+ 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),
77
+ userRating: getUserRating(el)
78
+ });
79
+ }
80
+ }
@@ -0,0 +1 @@
1
+ export declare const fetchSafe: typeof fetch;
@@ -0,0 +1 @@
1
+ export declare const fetchPage: (url: string) => Promise<string>;
@@ -0,0 +1,18 @@
1
+ import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from 'interfaces/cinema.interface';
2
+ import { HTMLElement } from 'node-html-parser';
3
+ import { CSFDColorRating } from '../interfaces/global';
4
+ export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
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) => {
8
+ lat: number;
9
+ lng: number;
10
+ } | null;
11
+ export declare const getCinemaUrl: (el: HTMLElement | null) => string;
12
+ export declare const parseCinema: (el: HTMLElement | null) => {
13
+ city: string;
14
+ name: string;
15
+ };
16
+ export declare const getGroupedFilmsByDate: (el: HTMLElement | null) => CSFDCinemaGroupedFilmsByDate[];
17
+ export declare const getFilms: (date: string, el: HTMLElement | null) => CSFDCinemaMovie[];
18
+ export declare const parseMeta: (meta: string[]) => CSFDCinemaMeta[];
@@ -0,0 +1,17 @@
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[];
@@ -0,0 +1,17 @@
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 getDuration: (matches: any[]) => {
8
+ sign: string;
9
+ years: any;
10
+ months: any;
11
+ weeks: any;
12
+ days: any;
13
+ hours: any;
14
+ minutes: any;
15
+ seconds: any;
16
+ };
17
+ export declare const parseISO8601Duration: (iso: string) => number;
@@ -0,0 +1,25 @@
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[];
@@ -0,0 +1,5 @@
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;
@@ -0,0 +1,11 @@
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[];
@@ -0,0 +1,13 @@
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>;
@@ -0,0 +1,24 @@
1
+ import { CSFDCinema, CSFDCinemaPeriod } from 'interfaces/cinema.interface';
2
+ import { CSFDCreator } from './interfaces/creator.interface';
3
+ import { CSFDMovie } from './interfaces/movie.interface';
4
+ import { CSFDSearch } from './interfaces/search.interface';
5
+ import { CSFDUserRatingConfig, CSFDUserRatings } from './interfaces/user-ratings.interface';
6
+ import { CinemaScraper } from './services/cinema.service';
7
+ import { CreatorScraper } from './services/creator.service';
8
+ import { MovieScraper } from './services/movie.service';
9
+ import { SearchScraper } from './services/search.service';
10
+ import { UserRatingsScraper } from './services/user-ratings.service';
11
+ export declare class Csfd {
12
+ private userRatingsService;
13
+ private movieService;
14
+ private creatorService;
15
+ private searchService;
16
+ private cinemaService;
17
+ constructor(userRatingsService: UserRatingsScraper, movieService: MovieScraper, creatorService: CreatorScraper, searchService: SearchScraper, cinemaService: CinemaScraper);
18
+ userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
19
+ movie(movie: number): Promise<CSFDMovie>;
20
+ creator(creator: number): Promise<CSFDCreator>;
21
+ search(text: string): Promise<CSFDSearch>;
22
+ cinema(district: number | string, period: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
23
+ }
24
+ export declare const csfd: Csfd;
@@ -0,0 +1,23 @@
1
+ import { CSFDMovieListItem } from './movie.interface';
2
+ export interface CSFDCinema {
3
+ id: number;
4
+ name: string;
5
+ city: string;
6
+ url: string;
7
+ coords: {
8
+ lat: number;
9
+ lng: number;
10
+ };
11
+ region?: string;
12
+ screenings: CSFDCinemaGroupedFilmsByDate[];
13
+ }
14
+ export interface CSFDCinemaGroupedFilmsByDate {
15
+ date: string;
16
+ films: CSFDCinemaMovie[];
17
+ }
18
+ export interface CSFDCinemaMovie extends CSFDMovieListItem {
19
+ meta: CSFDCinemaMeta[];
20
+ showTimes: string[];
21
+ }
22
+ export type CSFDCinemaMeta = 'dubbing' | '3D' | 'subtitles' | string;
23
+ export type CSFDCinemaPeriod = 'today' | 'weekend' | 'week' | 'tomorrow' | 'month';
@@ -0,0 +1,12 @@
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'>;
@@ -0,0 +1,22 @@
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';
@@ -0,0 +1,66 @@
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é';
@@ -0,0 +1,27 @@
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
+ }
@@ -0,0 +1,18 @@
1
+ import { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';
2
+ export interface CSFDUserRatings extends CSFDScreening {
3
+ userRating: CSFDStars;
4
+ userDate: string;
5
+ }
6
+ export interface CSFDUserRatingConfig {
7
+ includesOnly?: CSFDFilmTypes[];
8
+ excludes?: CSFDFilmTypes[];
9
+ /**
10
+ * Fetch all ratings. (Warning: Use it wisely. Can be detected and banned. Consider using it together with `allPagesDelay` attribute)
11
+ */
12
+ allPages?: boolean;
13
+ /**
14
+ * Delay on each page request. In milliseconds
15
+ */
16
+ allPagesDelay?: number;
17
+ }
18
+ export type Colors = 'lightgrey' | 'blue' | 'red' | 'grey';
@@ -0,0 +1,6 @@
1
+ import { CSFDCinema, CSFDCinemaPeriod } from '../interfaces/cinema.interface';
2
+ export declare class CinemaScraper {
3
+ private cinema;
4
+ cinemas(district?: number, period?: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
5
+ private buildCinemas;
6
+ }
@@ -0,0 +1,6 @@
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
+ }
@@ -0,0 +1,6 @@
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
+ }
@@ -0,0 +1,5 @@
1
+ import { CSFDSearch } from '../interfaces/search.interface';
2
+ export declare class SearchScraper {
3
+ search(text: string): Promise<CSFDSearch>;
4
+ private parseSearch;
5
+ }
@@ -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
+ }
@@ -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/esm/vars.js ADDED
@@ -0,0 +1,7 @@
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 cinemasUrl = (district, period) => {
5
+ return `https://www.csfd.cz/kino/?period=${period}&district=${district}`;
6
+ };
7
+ export const searchUrl = (text) => `https://www.csfd.cz/hledat/?q=${encodeURIComponent(text)}`;