node-csfd-api-racintom 1.0.0 → 1.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/fetchers/fetch.polyfill.d.ts +1 -0
- package/fetchers/fetch.polyfill.js +9 -0
- package/fetchers/index.d.ts +1 -0
- package/fetchers/index.js +27 -0
- package/helpers/creator.helper.d.ts +17 -0
- package/helpers/creator.helper.js +87 -0
- package/helpers/global.helper.d.ts +17 -0
- package/helpers/global.helper.js +68 -0
- package/helpers/movie.helper.d.ts +26 -0
- package/helpers/movie.helper.js +270 -0
- package/helpers/search-user.helper.d.ts +5 -0
- package/helpers/search-user.helper.js +22 -0
- package/helpers/search.helper.d.ts +11 -0
- package/helpers/search.helper.js +62 -0
- package/helpers/user-ratings.helper.d.ts +13 -0
- package/helpers/user-ratings.helper.js +61 -0
- package/index.d.ts +20 -0
- package/index.js +33 -0
- package/interfaces/creator.interface.d.ts +12 -0
- package/interfaces/creator.interface.js +2 -0
- package/interfaces/global.d.ts +22 -0
- package/interfaces/global.js +2 -0
- package/interfaces/movie.interface.d.ts +73 -0
- package/interfaces/movie.interface.js +2 -0
- package/interfaces/search.interface.d.ts +27 -0
- package/interfaces/search.interface.js +2 -0
- package/interfaces/user-ratings.interface.d.ts +18 -0
- package/interfaces/user-ratings.interface.js +2 -0
- package/package.json +62 -86
- package/services/creator.service.d.ts +6 -0
- package/services/creator.service.js +32 -0
- package/services/movie.service.d.ts +6 -0
- package/services/movie.service.js +59 -0
- package/services/search.service.d.ts +5 -0
- package/services/search.service.js +80 -0
- package/services/user-ratings.service.d.ts +7 -0
- package/services/user-ratings.service.js +84 -0
- package/vars.d.ts +4 -0
- package/vars.js +11 -0
- package/.editorconfig +0 -13
- package/.eslintrc.json +0 -33
- package/.gitattributes +0 -2
- package/.github/FUNDING.yml +0 -8
- package/.github/pull_request_template.md +0 -19
- package/.github/workflows/main.yml +0 -40
- package/.github/workflows/publish.yml +0 -73
- package/.github/workflows/test.yml +0 -43
- package/.husky/pre-commit +0 -1
- package/.idea/codeStyles/Project.xml +0 -72
- package/.idea/codeStyles/codeStyleConfig.xml +0 -5
- package/.idea/inspectionProfiles/Project_Default.xml +0 -6
- package/.idea/misc.xml +0 -6
- package/.idea/modules.xml +0 -8
- package/.idea/node-csfd-api.iml +0 -9
- package/.idea/prettier.xml +0 -6
- package/.idea/vcs.xml +0 -7
- package/.nvmrc +0 -1
- package/.prettierignore +0 -8
- package/.prettierrc +0 -10
- package/.vscode/settings.json +0 -16
- package/Dockerfile +0 -19
- package/demo.ts +0 -35
- package/eslint.config.mjs +0 -55
- package/server.ts +0 -66
- package/src/fetchers/fetch.polyfill.ts +0 -7
- package/src/fetchers/index.ts +0 -25
- package/src/helpers/creator.helper.ts +0 -95
- package/src/helpers/global.helper.ts +0 -70
- package/src/helpers/movie.helper.ts +0 -276
- package/src/helpers/search-user.helper.ts +0 -19
- package/src/helpers/search.helper.ts +0 -66
- package/src/helpers/user-ratings.helper.ts +0 -62
- package/src/index.ts +0 -42
- package/src/interfaces/creator.interface.ts +0 -14
- package/src/interfaces/global.ts +0 -36
- package/src/interfaces/movie.interface.ts +0 -157
- package/src/interfaces/search.interface.ts +0 -32
- package/src/interfaces/user-ratings.interface.ts +0 -21
- package/src/services/creator.service.ts +0 -34
- package/src/services/movie.service.ts +0 -89
- package/src/services/search.service.ts +0 -101
- package/src/services/user-ratings.service.ts +0 -106
- package/src/vars.ts +0 -13
- package/tests/creator.test.ts +0 -182
- package/tests/fetchers.test.ts +0 -109
- package/tests/global.test.ts +0 -35
- package/tests/helpers.test.ts +0 -59
- package/tests/mocks/creator-actor.html.ts +0 -2244
- package/tests/mocks/creator-composer-empty.html.ts +0 -683
- package/tests/mocks/creator-director.html.ts +0 -3407
- package/tests/mocks/movie1.html.ts +0 -1430
- package/tests/mocks/movie2.html.ts +0 -740
- package/tests/mocks/movie3.html.ts +0 -1843
- package/tests/mocks/movie4.html.ts +0 -1568
- package/tests/mocks/search.html.ts +0 -838
- package/tests/mocks/series1.html.ts +0 -1540
- package/tests/mocks/userRatings.html.ts +0 -1354
- package/tests/movie.test.ts +0 -606
- package/tests/search.test.ts +0 -379
- package/tests/services.test.ts +0 -106
- package/tests/user-ratings.test.ts +0 -142
- package/tests/vars.test.ts +0 -34
- package/tsconfig.json +0 -23
- package/vitest.config.mts +0 -10
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.sleep = exports.parseColor = exports.getUrl = exports.getDate = exports.getColorRating = exports.getYear = exports.getTitle = exports.getType = exports.getUserRating = exports.getId = void 0;
|
|
4
|
+
const global_helper_1 = require("./global.helper");
|
|
5
|
+
const getId = (el) => {
|
|
6
|
+
const url = el.querySelector('td.name .film-title-name').attributes.href;
|
|
7
|
+
return (0, global_helper_1.parseIdFromUrl)(url);
|
|
8
|
+
};
|
|
9
|
+
exports.getId = getId;
|
|
10
|
+
const getUserRating = (el) => {
|
|
11
|
+
const ratingText = el.querySelector('td.star-rating-only .stars').classNames.split(' ').pop();
|
|
12
|
+
const rating = ratingText.includes('stars-') ? +ratingText.split('-').pop() : 0;
|
|
13
|
+
return rating;
|
|
14
|
+
};
|
|
15
|
+
exports.getUserRating = getUserRating;
|
|
16
|
+
const getType = (el) => {
|
|
17
|
+
const typeText = el.querySelectorAll('td.name .film-title-info .info');
|
|
18
|
+
return (typeText.length > 1 ? typeText[1].text.slice(1, -1) : 'film');
|
|
19
|
+
};
|
|
20
|
+
exports.getType = getType;
|
|
21
|
+
const getTitle = (el) => {
|
|
22
|
+
return el.querySelector('td.name .film-title-name').text;
|
|
23
|
+
};
|
|
24
|
+
exports.getTitle = getTitle;
|
|
25
|
+
const getYear = (el) => {
|
|
26
|
+
var _a;
|
|
27
|
+
return +((_a = el.querySelectorAll('td.name .film-title-info .info')[0]) === null || _a === void 0 ? void 0 : _a.text.slice(1, -1)) || null;
|
|
28
|
+
};
|
|
29
|
+
exports.getYear = getYear;
|
|
30
|
+
const getColorRating = (el) => {
|
|
31
|
+
const color = (0, exports.parseColor)(el.querySelector('td.name .icon').classNames.split(' ').pop());
|
|
32
|
+
return color;
|
|
33
|
+
};
|
|
34
|
+
exports.getColorRating = getColorRating;
|
|
35
|
+
const getDate = (el) => {
|
|
36
|
+
return el.querySelector('td.date-only').text.trim();
|
|
37
|
+
};
|
|
38
|
+
exports.getDate = getDate;
|
|
39
|
+
const getUrl = (el) => {
|
|
40
|
+
const url = el.querySelector('td.name .film-title-name').attributes.href;
|
|
41
|
+
return `https://www.csfd.cz${url}`;
|
|
42
|
+
};
|
|
43
|
+
exports.getUrl = getUrl;
|
|
44
|
+
const parseColor = (quality) => {
|
|
45
|
+
switch (quality) {
|
|
46
|
+
case 'lightgrey':
|
|
47
|
+
return 'unknown';
|
|
48
|
+
case 'red':
|
|
49
|
+
return 'good';
|
|
50
|
+
case 'blue':
|
|
51
|
+
return 'average';
|
|
52
|
+
case 'grey':
|
|
53
|
+
return 'bad';
|
|
54
|
+
default:
|
|
55
|
+
return 'unknown';
|
|
56
|
+
}
|
|
57
|
+
};
|
|
58
|
+
exports.parseColor = parseColor;
|
|
59
|
+
// Sleep in loop
|
|
60
|
+
const sleep = (ms) => new Promise((res) => setTimeout(res, ms));
|
|
61
|
+
exports.sleep = sleep;
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
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/index.js
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.csfd = exports.Csfd = void 0;
|
|
4
|
+
const creator_service_1 = require("./services/creator.service");
|
|
5
|
+
const movie_service_1 = require("./services/movie.service");
|
|
6
|
+
const search_service_1 = require("./services/search.service");
|
|
7
|
+
const user_ratings_service_1 = require("./services/user-ratings.service");
|
|
8
|
+
class Csfd {
|
|
9
|
+
constructor(userRatingsService, movieService, creatorService, searchService) {
|
|
10
|
+
this.userRatingsService = userRatingsService;
|
|
11
|
+
this.movieService = movieService;
|
|
12
|
+
this.creatorService = creatorService;
|
|
13
|
+
this.searchService = searchService;
|
|
14
|
+
}
|
|
15
|
+
async userRatings(user, config) {
|
|
16
|
+
return this.userRatingsService.userRatings(user, config);
|
|
17
|
+
}
|
|
18
|
+
async movie(movie) {
|
|
19
|
+
return this.movieService.movie(+movie);
|
|
20
|
+
}
|
|
21
|
+
async creator(creator) {
|
|
22
|
+
return this.creatorService.creator(+creator);
|
|
23
|
+
}
|
|
24
|
+
async search(text) {
|
|
25
|
+
return this.searchService.search(text);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
exports.Csfd = Csfd;
|
|
29
|
+
const movieScraper = new movie_service_1.MovieScraper();
|
|
30
|
+
const userRatingsScraper = new user_ratings_service_1.UserRatingsScraper();
|
|
31
|
+
const creatorScraper = new creator_service_1.CreatorScraper();
|
|
32
|
+
const searchScraper = new search_service_1.SearchScraper();
|
|
33
|
+
exports.csfd = new Csfd(userRatingsScraper, movieScraper, creatorScraper, searchScraper);
|
|
@@ -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,73 @@
|
|
|
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
|
+
seasons: CSFDSeasons | null;
|
|
20
|
+
}
|
|
21
|
+
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';
|
|
22
|
+
export interface CSFDVod {
|
|
23
|
+
title: CSFDVodService;
|
|
24
|
+
url: string;
|
|
25
|
+
}
|
|
26
|
+
export interface CSFDCreators {
|
|
27
|
+
directors: CSFDCreator[];
|
|
28
|
+
writers: CSFDCreator[];
|
|
29
|
+
cinematography: CSFDCreator[];
|
|
30
|
+
music: CSFDCreator[];
|
|
31
|
+
actors: CSFDCreator[];
|
|
32
|
+
basedOn: CSFDCreator[];
|
|
33
|
+
producers: CSFDCreator[];
|
|
34
|
+
filmEditing: CSFDCreator[];
|
|
35
|
+
costumeDesign: CSFDCreator[];
|
|
36
|
+
productionDesign: CSFDCreator[];
|
|
37
|
+
}
|
|
38
|
+
export interface CSFDTitlesOther {
|
|
39
|
+
country: string;
|
|
40
|
+
title: string;
|
|
41
|
+
}
|
|
42
|
+
export interface CSFDCreator {
|
|
43
|
+
/**
|
|
44
|
+
* CSFD person ID.
|
|
45
|
+
*
|
|
46
|
+
* You can always assemble url from ID like this:
|
|
47
|
+
*
|
|
48
|
+
* `https://www.csfd.cz/tvurce/${id}`
|
|
49
|
+
*/
|
|
50
|
+
id: number;
|
|
51
|
+
name: string;
|
|
52
|
+
url: string;
|
|
53
|
+
}
|
|
54
|
+
export interface CSFDMovieListItem {
|
|
55
|
+
id: number;
|
|
56
|
+
title: string;
|
|
57
|
+
url: string;
|
|
58
|
+
}
|
|
59
|
+
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ý';
|
|
60
|
+
export type CSFDCreatorGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Produkce' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
|
|
61
|
+
export interface CSFDPremiere {
|
|
62
|
+
country: string;
|
|
63
|
+
format: string;
|
|
64
|
+
date: string;
|
|
65
|
+
company: string;
|
|
66
|
+
}
|
|
67
|
+
export type CSFDBoxContent = 'Související' | 'Podobné';
|
|
68
|
+
export type CSFDSeasons = CSFDSeasonInfo[];
|
|
69
|
+
export interface CSFDSeasonInfo {
|
|
70
|
+
name: string;
|
|
71
|
+
linkToDetail: string;
|
|
72
|
+
additionalInfo: string;
|
|
73
|
+
}
|
|
@@ -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';
|
package/package.json
CHANGED
|
@@ -1,86 +1,62 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "node-csfd-api-racintom",
|
|
3
|
-
"version": "1.
|
|
4
|
-
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
|
|
5
|
-
"main": "index.js",
|
|
6
|
-
"author": "sergeras@seznam.cz",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"start": "tsc -w",
|
|
9
|
-
"prebuild": "rimraf dist",
|
|
10
|
-
"build": "tsc",
|
|
11
|
-
"postbuild": "npm-prepare-dist -s postinstall -s prepare",
|
|
12
|
-
"tsc": "tsc",
|
|
13
|
-
"demo": "tsx demo",
|
|
14
|
-
"lint": "eslint ./src/**/**/* --fix",
|
|
15
|
-
"test": "vitest",
|
|
16
|
-
"test:coverage": "yarn test run --coverage",
|
|
17
|
-
"publish:next": "yarn && yarn build && yarn test:coverage && cd dist && yarn publish --tag next",
|
|
18
|
-
"postversion": "git push && git push --follow-tags",
|
|
19
|
-
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
20
|
-
"prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
|
|
21
|
-
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
|
|
22
|
-
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
|
|
23
|
-
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
"
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
"
|
|
42
|
-
"
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
"url": "https://github.com/racintom/node-csfd-api/issues"
|
|
64
|
-
},
|
|
65
|
-
"homepage": "https://github.com/racintom/node-csfd-api#readme",
|
|
66
|
-
"keywords": [
|
|
67
|
-
"csfd",
|
|
68
|
-
"čsfd",
|
|
69
|
-
"ratings",
|
|
70
|
-
"movies",
|
|
71
|
-
"films",
|
|
72
|
-
"nodejs",
|
|
73
|
-
"node",
|
|
74
|
-
"typescript",
|
|
75
|
-
"scraper",
|
|
76
|
-
"parser",
|
|
77
|
-
"api"
|
|
78
|
-
],
|
|
79
|
-
"engines": {
|
|
80
|
-
"node": ">= 18"
|
|
81
|
-
},
|
|
82
|
-
"license": "MIT",
|
|
83
|
-
"lint-staged": {
|
|
84
|
-
"*.ts": "eslint --cache --fix"
|
|
85
|
-
}
|
|
86
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "node-csfd-api-racintom",
|
|
3
|
+
"version": "1.1.0",
|
|
4
|
+
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
|
|
5
|
+
"main": "./index.js",
|
|
6
|
+
"author": "sergeras@seznam.cz",
|
|
7
|
+
"scripts": {
|
|
8
|
+
"start": "tsc -w",
|
|
9
|
+
"prebuild": "rimraf dist",
|
|
10
|
+
"build": "tsc",
|
|
11
|
+
"postbuild": "npm-prepare-dist -s postinstall -s prepare",
|
|
12
|
+
"tsc": "tsc",
|
|
13
|
+
"demo": "tsx demo",
|
|
14
|
+
"lint": "eslint ./src/**/**/* --fix",
|
|
15
|
+
"test": "vitest",
|
|
16
|
+
"test:coverage": "yarn test run --coverage",
|
|
17
|
+
"publish:next": "yarn && yarn build && yarn test:coverage && cd dist && yarn publish --tag next",
|
|
18
|
+
"postversion": "git push && git push --follow-tags",
|
|
19
|
+
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
20
|
+
"prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
|
|
21
|
+
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
|
|
22
|
+
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
|
|
23
|
+
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
|
|
24
|
+
},
|
|
25
|
+
"publishConfig": {
|
|
26
|
+
"access": "public"
|
|
27
|
+
},
|
|
28
|
+
"dependencies": {
|
|
29
|
+
"cross-fetch": "^4.1.0",
|
|
30
|
+
"node-html-parser": "^7.0.1"
|
|
31
|
+
},
|
|
32
|
+
"repository": {
|
|
33
|
+
"url": "https://github.com/racintom/node-csfd-api.git",
|
|
34
|
+
"type": "git"
|
|
35
|
+
},
|
|
36
|
+
"bugs": {
|
|
37
|
+
"url": "https://github.com/racintom/node-csfd-api/issues"
|
|
38
|
+
},
|
|
39
|
+
"homepage": "https://github.com/racintom/node-csfd-api#readme",
|
|
40
|
+
"keywords": [
|
|
41
|
+
"csfd",
|
|
42
|
+
"čsfd",
|
|
43
|
+
"ratings",
|
|
44
|
+
"movies",
|
|
45
|
+
"films",
|
|
46
|
+
"nodejs",
|
|
47
|
+
"node",
|
|
48
|
+
"typescript",
|
|
49
|
+
"scraper",
|
|
50
|
+
"parser",
|
|
51
|
+
"api"
|
|
52
|
+
],
|
|
53
|
+
"engines": {
|
|
54
|
+
"node": ">= 18"
|
|
55
|
+
},
|
|
56
|
+
"license": "MIT",
|
|
57
|
+
"lint-staged": {
|
|
58
|
+
"*.ts": "eslint --cache --fix"
|
|
59
|
+
},
|
|
60
|
+
"module": "./index.js",
|
|
61
|
+
"types": "./index.d.ts"
|
|
62
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreatorScraper = void 0;
|
|
4
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
+
const fetchers_1 = require("../fetchers");
|
|
6
|
+
const creator_helper_1 = require("../helpers/creator.helper");
|
|
7
|
+
const vars_1 = require("../vars");
|
|
8
|
+
class CreatorScraper {
|
|
9
|
+
async creator(creatorId) {
|
|
10
|
+
const url = (0, vars_1.creatorUrl)(+creatorId);
|
|
11
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
12
|
+
const creatorHtml = (0, node_html_parser_1.parse)(response);
|
|
13
|
+
const asideNode = creatorHtml.querySelector('.creator-about');
|
|
14
|
+
const filmsNode = creatorHtml.querySelector('.creator-filmography');
|
|
15
|
+
this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
16
|
+
return this.person;
|
|
17
|
+
}
|
|
18
|
+
buildCreator(id, asideEl, filmsNode) {
|
|
19
|
+
var _a, _b, _c;
|
|
20
|
+
this.person = {
|
|
21
|
+
id,
|
|
22
|
+
name: (0, creator_helper_1.getName)(asideEl),
|
|
23
|
+
birthday: (_a = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
|
|
24
|
+
birthplace: (_b = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
|
|
25
|
+
photo: (0, creator_helper_1.getPhoto)(asideEl),
|
|
26
|
+
age: ((_c = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
|
|
27
|
+
bio: (0, creator_helper_1.getBio)(asideEl),
|
|
28
|
+
films: (0, creator_helper_1.getFilms)(filmsNode)
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
exports.CreatorScraper = CreatorScraper;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MovieScraper = void 0;
|
|
4
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
+
const fetchers_1 = require("../fetchers");
|
|
6
|
+
const movie_helper_1 = require("../helpers/movie.helper");
|
|
7
|
+
const vars_1 = require("../vars");
|
|
8
|
+
class MovieScraper {
|
|
9
|
+
async movie(movieId) {
|
|
10
|
+
const url = (0, vars_1.movieUrl)(+movieId);
|
|
11
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
12
|
+
const movieHtml = (0, node_html_parser_1.parse)(response);
|
|
13
|
+
const pageClasses = movieHtml.querySelector('.page-content').classNames.split(' ');
|
|
14
|
+
const asideNode = movieHtml.querySelector('.aside-movie-profile');
|
|
15
|
+
const movieNode = movieHtml.querySelector('.main-movie-profile');
|
|
16
|
+
const jsonLd = movieHtml.querySelector('script[type="application/ld+json"]').innerText;
|
|
17
|
+
this.buildMovie(+movieId, movieNode, asideNode, pageClasses, jsonLd);
|
|
18
|
+
return this.film;
|
|
19
|
+
}
|
|
20
|
+
buildMovie(movieId, el, asideEl, pageClasses, jsonLd) {
|
|
21
|
+
this.film = {
|
|
22
|
+
id: movieId,
|
|
23
|
+
title: (0, movie_helper_1.getTitle)(el),
|
|
24
|
+
year: (0, movie_helper_1.getYear)(jsonLd),
|
|
25
|
+
duration: (0, movie_helper_1.getDuration)(jsonLd, el),
|
|
26
|
+
descriptions: (0, movie_helper_1.getDescriptions)(el),
|
|
27
|
+
genres: (0, movie_helper_1.getGenres)(el),
|
|
28
|
+
type: (0, movie_helper_1.getType)(el),
|
|
29
|
+
url: (0, vars_1.movieUrl)(movieId),
|
|
30
|
+
origins: (0, movie_helper_1.getOrigins)(el),
|
|
31
|
+
colorRating: (0, movie_helper_1.getColorRating)(pageClasses),
|
|
32
|
+
rating: (0, movie_helper_1.getRating)(asideEl),
|
|
33
|
+
ratingCount: (0, movie_helper_1.getRatingCount)(asideEl),
|
|
34
|
+
titlesOther: (0, movie_helper_1.getTitlesOther)(el),
|
|
35
|
+
poster: (0, movie_helper_1.getPoster)(el),
|
|
36
|
+
photo: (0, movie_helper_1.getRandomPhoto)(el),
|
|
37
|
+
trivia: (0, movie_helper_1.getTrivia)(el),
|
|
38
|
+
creators: {
|
|
39
|
+
directors: (0, movie_helper_1.getGroup)(el, 'Režie'),
|
|
40
|
+
writers: (0, movie_helper_1.getGroup)(el, 'Scénář'),
|
|
41
|
+
cinematography: (0, movie_helper_1.getGroup)(el, 'Kamera'),
|
|
42
|
+
music: (0, movie_helper_1.getGroup)(el, 'Hudba'),
|
|
43
|
+
actors: (0, movie_helper_1.getGroup)(el, 'Hrají'),
|
|
44
|
+
basedOn: (0, movie_helper_1.getGroup)(el, 'Předloha'),
|
|
45
|
+
producers: (0, movie_helper_1.getGroup)(el, 'Produkce'),
|
|
46
|
+
filmEditing: (0, movie_helper_1.getGroup)(el, 'Střih'),
|
|
47
|
+
costumeDesign: (0, movie_helper_1.getGroup)(el, 'Kostýmy'),
|
|
48
|
+
productionDesign: (0, movie_helper_1.getGroup)(el, 'Scénografie')
|
|
49
|
+
},
|
|
50
|
+
vod: (0, movie_helper_1.getVods)(asideEl),
|
|
51
|
+
tags: (0, movie_helper_1.getTags)(asideEl),
|
|
52
|
+
premieres: (0, movie_helper_1.getPremieres)(asideEl),
|
|
53
|
+
related: (0, movie_helper_1.getBoxMovies)(asideEl, 'Související'),
|
|
54
|
+
similar: (0, movie_helper_1.getBoxMovies)(asideEl, 'Podobné'),
|
|
55
|
+
seasons: (0, movie_helper_1.getSeasonsInfo)(el)
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.MovieScraper = MovieScraper;
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SearchScraper = void 0;
|
|
4
|
+
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
+
const fetchers_1 = require("../fetchers");
|
|
6
|
+
const global_helper_1 = require("../helpers/global.helper");
|
|
7
|
+
const search_user_helper_1 = require("../helpers/search-user.helper");
|
|
8
|
+
const search_helper_1 = require("../helpers/search.helper");
|
|
9
|
+
const vars_1 = require("../vars");
|
|
10
|
+
class SearchScraper {
|
|
11
|
+
async search(text) {
|
|
12
|
+
const url = (0, vars_1.searchUrl)(text);
|
|
13
|
+
const response = await (0, fetchers_1.fetchPage)(url);
|
|
14
|
+
const html = (0, node_html_parser_1.parse)(response);
|
|
15
|
+
const moviesNode = html.querySelectorAll('.main-movies article');
|
|
16
|
+
const usersNode = html.querySelectorAll('.main-users article');
|
|
17
|
+
const tvSeriesNode = html.querySelectorAll('.main-series article');
|
|
18
|
+
return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
|
|
19
|
+
}
|
|
20
|
+
parseSearch(moviesNode, usersNode, tvSeriesNode) {
|
|
21
|
+
const movies = [];
|
|
22
|
+
const users = [];
|
|
23
|
+
const tvSeries = [];
|
|
24
|
+
moviesNode.map((m) => {
|
|
25
|
+
const url = (0, search_helper_1.getUrl)(m);
|
|
26
|
+
const movie = {
|
|
27
|
+
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
28
|
+
title: (0, search_helper_1.getTitle)(m),
|
|
29
|
+
year: (0, search_helper_1.getYear)(m),
|
|
30
|
+
url: `https://www.csfd.cz${url}`,
|
|
31
|
+
type: (0, search_helper_1.getType)(m),
|
|
32
|
+
colorRating: (0, search_helper_1.getColorRating)(m),
|
|
33
|
+
poster: (0, search_helper_1.getPoster)(m),
|
|
34
|
+
origins: (0, search_helper_1.getOrigins)(m),
|
|
35
|
+
creators: {
|
|
36
|
+
directors: (0, search_helper_1.parsePeople)(m, 'directors'),
|
|
37
|
+
actors: (0, search_helper_1.parsePeople)(m, 'actors')
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
movies.push(movie);
|
|
41
|
+
});
|
|
42
|
+
usersNode.map((m) => {
|
|
43
|
+
const url = (0, search_user_helper_1.getUserUrl)(m);
|
|
44
|
+
const user = {
|
|
45
|
+
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
46
|
+
user: (0, search_user_helper_1.getUser)(m),
|
|
47
|
+
userRealName: (0, search_user_helper_1.getUserRealName)(m),
|
|
48
|
+
avatar: (0, search_user_helper_1.getAvatar)(m),
|
|
49
|
+
url: `https://www.csfd.cz${url}`
|
|
50
|
+
};
|
|
51
|
+
users.push(user);
|
|
52
|
+
});
|
|
53
|
+
tvSeriesNode.map((m) => {
|
|
54
|
+
const url = (0, search_helper_1.getUrl)(m);
|
|
55
|
+
const user = {
|
|
56
|
+
id: (0, global_helper_1.parseIdFromUrl)(url),
|
|
57
|
+
title: (0, search_helper_1.getTitle)(m),
|
|
58
|
+
year: (0, search_helper_1.getYear)(m),
|
|
59
|
+
url: `https://www.csfd.cz${url}`,
|
|
60
|
+
type: (0, search_helper_1.getType)(m),
|
|
61
|
+
colorRating: (0, search_helper_1.getColorRating)(m),
|
|
62
|
+
poster: (0, search_helper_1.getPoster)(m),
|
|
63
|
+
origins: (0, search_helper_1.getOrigins)(m),
|
|
64
|
+
creators: {
|
|
65
|
+
directors: (0, search_helper_1.parsePeople)(m, 'directors'),
|
|
66
|
+
actors: (0, search_helper_1.parsePeople)(m, 'actors')
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
tvSeries.push(user);
|
|
70
|
+
});
|
|
71
|
+
const search = {
|
|
72
|
+
movies: movies,
|
|
73
|
+
users: users,
|
|
74
|
+
tvSeries: tvSeries,
|
|
75
|
+
creators: []
|
|
76
|
+
};
|
|
77
|
+
return search;
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.SearchScraper = SearchScraper;
|
|
@@ -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
|
+
}
|