node-csfd-api 3.0.0-next.22 → 3.0.0-next.23
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 → cjs/fetchers}/index.js +13 -4
- package/cjs/index.js +58 -0
- package/cjs/services/cinema.service.js +45 -0
- package/cjs/services/creator.service.js +43 -0
- package/{services → cjs/services}/movie.service.js +21 -10
- package/{services → cjs/services}/search.service.js +19 -8
- package/{services → cjs/services}/user-ratings.service.js +36 -25
- package/esm/fetchers/index.js +13 -4
- package/esm/index.js +29 -10
- package/esm/services/cinema.service.js +18 -7
- package/esm/services/creator.service.js +19 -8
- package/esm/services/movie.service.js +21 -10
- package/esm/services/search.service.js +19 -8
- package/esm/services/user-ratings.service.js +36 -25
- package/package.json +11 -17
- package/types/index.ts +26 -0
- package/fetchers/fetch.polyfill.d.ts +0 -1
- package/fetchers/index.d.ts +0 -1
- package/helpers/cinema.helper.d.ts +0 -18
- package/helpers/creator.helper.d.ts +0 -17
- package/helpers/global.helper.d.ts +0 -17
- package/helpers/movie.helper.d.ts +0 -25
- package/helpers/search-user.helper.d.ts +0 -5
- package/helpers/search.helper.d.ts +0 -11
- package/helpers/user-ratings.helper.d.ts +0 -13
- package/index.d.ts +0 -24
- package/index.js +0 -39
- package/interfaces/cinema.interface.d.ts +0 -23
- package/interfaces/creator.interface.d.ts +0 -12
- package/interfaces/global.d.ts +0 -22
- package/interfaces/movie.interface.d.ts +0 -66
- package/interfaces/search.interface.d.ts +0 -27
- package/interfaces/user-ratings.interface.d.ts +0 -18
- package/services/cinema.service.d.ts +0 -6
- package/services/cinema.service.js +0 -34
- package/services/creator.service.d.ts +0 -6
- package/services/creator.service.js +0 -32
- package/services/movie.service.d.ts +0 -6
- package/services/search.service.d.ts +0 -5
- package/services/user-ratings.service.d.ts +0 -7
- package/vars.d.ts +0 -6
- /package/{fetchers → cjs/fetchers}/fetch.polyfill.js +0 -0
- /package/{helpers → cjs/helpers}/cinema.helper.js +0 -0
- /package/{helpers → cjs/helpers}/creator.helper.js +0 -0
- /package/{helpers → cjs/helpers}/global.helper.js +0 -0
- /package/{helpers → cjs/helpers}/movie.helper.js +0 -0
- /package/{helpers → cjs/helpers}/search-user.helper.js +0 -0
- /package/{helpers → cjs/helpers}/search.helper.js +0 -0
- /package/{helpers → cjs/helpers}/user-ratings.helper.js +0 -0
- /package/{interfaces → cjs/interfaces}/cinema.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/creator.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/global.js +0 -0
- /package/{interfaces → cjs/interfaces}/movie.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/search.interface.js +0 -0
- /package/{interfaces → cjs/interfaces}/user-ratings.interface.js +0 -0
- /package/{vars.js → cjs/vars.js} +0 -0
- /package/{esm/types → types}/fetchers/fetch.polyfill.d.ts +0 -0
- /package/{esm/types → types}/fetchers/index.d.ts +0 -0
- /package/{esm/types → types}/helpers/cinema.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/creator.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/global.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/movie.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/search-user.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/search.helper.d.ts +0 -0
- /package/{esm/types → types}/helpers/user-ratings.helper.d.ts +0 -0
- /package/{esm/types → types}/index.d.ts +0 -0
- /package/{esm/types → types}/interfaces/cinema.interface.d.ts +0 -0
- /package/{esm/types → types}/interfaces/creator.interface.d.ts +0 -0
- /package/{esm/types → types}/interfaces/global.d.ts +0 -0
- /package/{esm/types → types}/interfaces/movie.interface.d.ts +0 -0
- /package/{esm/types → types}/interfaces/search.interface.d.ts +0 -0
- /package/{esm/types → types}/interfaces/user-ratings.interface.d.ts +0 -0
- /package/{esm/types → types}/services/cinema.service.d.ts +0 -0
- /package/{esm/types → types}/services/creator.service.d.ts +0 -0
- /package/{esm/types → types}/services/movie.service.d.ts +0 -0
- /package/{esm/types → types}/services/search.service.d.ts +0 -0
- /package/{esm/types → types}/services/user-ratings.service.d.ts +0 -0
- /package/{esm/types → types}/vars.d.ts +0 -0
|
@@ -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 { parse } from 'node-html-parser';
|
|
2
11
|
import { fetchPage } from '../fetchers';
|
|
3
12
|
import { getColorRating, getDate, getId, getTitle, getType, getUrl, getUserRating, getYear, sleep } from '../helpers/user-ratings.helper';
|
|
@@ -6,34 +15,36 @@ export class UserRatingsScraper {
|
|
|
6
15
|
constructor() {
|
|
7
16
|
this.films = [];
|
|
8
17
|
}
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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;
|
package/package.json
CHANGED
|
@@ -1,29 +1,21 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.23",
|
|
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
|
|
18
|
-
"build
|
|
19
|
-
"
|
|
20
|
-
"
|
|
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='./cjs/index.d.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": "./cjs/index.d.ts"
|
|
65
|
+
}
|
package/types/index.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file Automatically generated by barrelsby.
|
|
3
|
+
*/
|
|
4
|
+
|
|
5
|
+
export * from "./index";
|
|
6
|
+
export * from "./vars";
|
|
7
|
+
export * from "./fetchers/fetch.polyfill";
|
|
8
|
+
export * from "./fetchers/index";
|
|
9
|
+
export * from "./helpers/cinema.helper";
|
|
10
|
+
export * from "./helpers/creator.helper";
|
|
11
|
+
export * from "./helpers/global.helper";
|
|
12
|
+
export * from "./helpers/movie.helper";
|
|
13
|
+
export * from "./helpers/search-user.helper";
|
|
14
|
+
export * from "./helpers/search.helper";
|
|
15
|
+
export * from "./helpers/user-ratings.helper";
|
|
16
|
+
export * from "./interfaces/cinema.interface";
|
|
17
|
+
export * from "./interfaces/creator.interface";
|
|
18
|
+
export * from "./interfaces/global";
|
|
19
|
+
export * from "./interfaces/movie.interface";
|
|
20
|
+
export * from "./interfaces/search.interface";
|
|
21
|
+
export * from "./interfaces/user-ratings.interface";
|
|
22
|
+
export * from "./services/cinema.service";
|
|
23
|
+
export * from "./services/creator.service";
|
|
24
|
+
export * from "./services/movie.service";
|
|
25
|
+
export * from "./services/search.service";
|
|
26
|
+
export * from "./services/user-ratings.service";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetchSafe: typeof fetch;
|
package/fetchers/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const fetchPage: (url: string) => Promise<string>;
|
|
@@ -1,18 +0,0 @@
|
|
|
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[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { HTMLElement } from 'node-html-parser';
|
|
2
|
-
import { CSFDCreatorScreening } from '../interfaces/creator.interface';
|
|
3
|
-
import { CSFDColorRating } from '../interfaces/global';
|
|
4
|
-
export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
|
|
5
|
-
export declare const getId: (url: string) => number;
|
|
6
|
-
export declare const getName: (el: HTMLElement | null) => string;
|
|
7
|
-
export declare const getBirthdayInfo: (el: HTMLElement | null) => {
|
|
8
|
-
birthday: string;
|
|
9
|
-
age: number;
|
|
10
|
-
birthPlace: string;
|
|
11
|
-
};
|
|
12
|
-
export declare const getBio: (el: HTMLElement | null) => string;
|
|
13
|
-
export declare const getPhoto: (el: HTMLElement | null) => string;
|
|
14
|
-
export declare const parseBirthday: (text: string) => any;
|
|
15
|
-
export declare const parseAge: (text: string) => any;
|
|
16
|
-
export declare const parseBirthPlace: (text: string) => any;
|
|
17
|
-
export declare const getFilms: (el: HTMLElement | null) => CSFDCreatorScreening[];
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { CSFDColorRating } from '../interfaces/global';
|
|
2
|
-
import { Colors } from '../interfaces/user-ratings.interface';
|
|
3
|
-
export declare const parseIdFromUrl: (url: string) => number;
|
|
4
|
-
export declare const getColor: (cls: string) => CSFDColorRating;
|
|
5
|
-
export declare const parseColor: (quality: Colors) => CSFDColorRating;
|
|
6
|
-
export declare const addProtocol: (url: string) => string;
|
|
7
|
-
export declare const 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;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { HTMLElement } from 'node-html-parser';
|
|
2
|
-
import { CSFDColorRating } from '../interfaces/global';
|
|
3
|
-
import { CSFDBoxContent, CSFDCreator, CSFDCreatorGroups, CSFDGenres, CSFDMovieListItem, CSFDPremiere, CSFDTitlesOther, CSFDVod } from '../interfaces/movie.interface';
|
|
4
|
-
export declare const getId: (el: HTMLElement) => number;
|
|
5
|
-
export declare const getTitle: (el: HTMLElement) => string;
|
|
6
|
-
export declare const getGenres: (el: HTMLElement) => CSFDGenres[];
|
|
7
|
-
export declare const getOrigins: (el: HTMLElement) => string[];
|
|
8
|
-
export declare const getColorRating: (bodyClasses: string[]) => CSFDColorRating;
|
|
9
|
-
export declare const getRating: (el: HTMLElement) => number;
|
|
10
|
-
export declare const getRatingCount: (el: HTMLElement) => number;
|
|
11
|
-
export declare const getYear: (el: string) => number;
|
|
12
|
-
export declare const getDuration: (jsonLdRaw: string, el: HTMLElement) => number;
|
|
13
|
-
export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
|
|
14
|
-
export declare const getPoster: (el: HTMLElement | null) => string;
|
|
15
|
-
export declare const getRandomPhoto: (el: HTMLElement | null) => string;
|
|
16
|
-
export declare const getTrivia: (el: HTMLElement | null) => string[];
|
|
17
|
-
export declare const getDescriptions: (el: HTMLElement) => string[];
|
|
18
|
-
export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
|
|
19
|
-
export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
|
|
20
|
-
export declare const getType: (el: HTMLElement) => string;
|
|
21
|
-
export declare const getVods: (el: HTMLElement | null) => CSFDVod[];
|
|
22
|
-
export declare const getBoxContent: (el: HTMLElement, box: string) => HTMLElement;
|
|
23
|
-
export declare const getBoxMovies: (el: HTMLElement, boxName: CSFDBoxContent) => CSFDMovieListItem[];
|
|
24
|
-
export declare const getPremieres: (el: HTMLElement) => CSFDPremiere[];
|
|
25
|
-
export declare const getTags: (el: HTMLElement) => string[];
|
|
@@ -1,5 +0,0 @@
|
|
|
1
|
-
import { HTMLElement } from 'node-html-parser';
|
|
2
|
-
export declare const getUser: (el: HTMLElement) => string;
|
|
3
|
-
export declare const getUserRealName: (el: HTMLElement) => string;
|
|
4
|
-
export declare const getAvatar: (el: HTMLElement) => string;
|
|
5
|
-
export declare const getUserUrl: (el: HTMLElement) => string;
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { HTMLElement } from 'node-html-parser';
|
|
2
|
-
import { CSFDColorRating, CSFDFilmTypes } from '../interfaces/global';
|
|
3
|
-
import { CSFDCreator } from '../interfaces/movie.interface';
|
|
4
|
-
export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
|
|
5
|
-
export declare const getTitle: (el: HTMLElement) => string;
|
|
6
|
-
export declare const getYear: (el: HTMLElement) => number;
|
|
7
|
-
export declare const getUrl: (el: HTMLElement) => string;
|
|
8
|
-
export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
|
|
9
|
-
export declare const getPoster: (el: HTMLElement) => string;
|
|
10
|
-
export declare const getOrigins: (el: HTMLElement) => string[];
|
|
11
|
-
export declare const parsePeople: (el: HTMLElement, type: "directors" | "actors") => CSFDCreator[];
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { HTMLElement } from 'node-html-parser';
|
|
2
|
-
import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../interfaces/global';
|
|
3
|
-
import { Colors } from '../interfaces/user-ratings.interface';
|
|
4
|
-
export declare const getId: (el: HTMLElement) => number;
|
|
5
|
-
export declare const getUserRating: (el: HTMLElement) => CSFDStars;
|
|
6
|
-
export declare const getType: (el: HTMLElement) => CSFDFilmTypes;
|
|
7
|
-
export declare const getTitle: (el: HTMLElement) => string;
|
|
8
|
-
export declare const getYear: (el: HTMLElement) => number;
|
|
9
|
-
export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
|
|
10
|
-
export declare const getDate: (el: HTMLElement) => string;
|
|
11
|
-
export declare const getUrl: (el: HTMLElement) => string;
|
|
12
|
-
export declare const parseColor: (quality: Colors) => CSFDColorRating;
|
|
13
|
-
export declare const sleep: (ms: number) => Promise<unknown>;
|
package/index.d.ts
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
package/index.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.csfd = exports.Csfd = void 0;
|
|
4
|
-
const cinema_service_1 = require("./services/cinema.service");
|
|
5
|
-
const creator_service_1 = require("./services/creator.service");
|
|
6
|
-
const movie_service_1 = require("./services/movie.service");
|
|
7
|
-
const search_service_1 = require("./services/search.service");
|
|
8
|
-
const user_ratings_service_1 = require("./services/user-ratings.service");
|
|
9
|
-
class Csfd {
|
|
10
|
-
constructor(userRatingsService, movieService, creatorService, searchService, cinemaService) {
|
|
11
|
-
this.userRatingsService = userRatingsService;
|
|
12
|
-
this.movieService = movieService;
|
|
13
|
-
this.creatorService = creatorService;
|
|
14
|
-
this.searchService = searchService;
|
|
15
|
-
this.cinemaService = cinemaService;
|
|
16
|
-
}
|
|
17
|
-
async userRatings(user, config) {
|
|
18
|
-
return this.userRatingsService.userRatings(user, config);
|
|
19
|
-
}
|
|
20
|
-
async movie(movie) {
|
|
21
|
-
return this.movieService.movie(+movie);
|
|
22
|
-
}
|
|
23
|
-
async creator(creator) {
|
|
24
|
-
return this.creatorService.creator(+creator);
|
|
25
|
-
}
|
|
26
|
-
async search(text) {
|
|
27
|
-
return this.searchService.search(text);
|
|
28
|
-
}
|
|
29
|
-
async cinema(district, period) {
|
|
30
|
-
return this.cinemaService.cinemas(+district, period);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
exports.Csfd = Csfd;
|
|
34
|
-
const movieScraper = new movie_service_1.MovieScraper();
|
|
35
|
-
const userRatingsScraper = new user_ratings_service_1.UserRatingsScraper();
|
|
36
|
-
const cinemaScraper = new cinema_service_1.CinemaScraper();
|
|
37
|
-
const creatorScraper = new creator_service_1.CreatorScraper();
|
|
38
|
-
const searchScraper = new search_service_1.SearchScraper();
|
|
39
|
-
exports.csfd = new Csfd(userRatingsScraper, movieScraper, creatorScraper, searchScraper, cinemaScraper);
|
|
@@ -1,23 +0,0 @@
|
|
|
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';
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import { CSFDScreening } from './global';
|
|
2
|
-
export interface CSFDCreator {
|
|
3
|
-
id: number;
|
|
4
|
-
name: string;
|
|
5
|
-
birthday: string;
|
|
6
|
-
birthplace: string;
|
|
7
|
-
photo: string;
|
|
8
|
-
age: number | string;
|
|
9
|
-
bio: string;
|
|
10
|
-
films: CSFDCreatorScreening[];
|
|
11
|
-
}
|
|
12
|
-
export type CSFDCreatorScreening = Omit<CSFDScreening, 'url' | 'type'>;
|
package/interfaces/global.d.ts
DELETED
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
export interface CSFDScreening {
|
|
2
|
-
id: number;
|
|
3
|
-
title: string;
|
|
4
|
-
year: number;
|
|
5
|
-
url: string;
|
|
6
|
-
type: CSFDFilmTypes;
|
|
7
|
-
/**
|
|
8
|
-
* Overall aggregated rating. (On the web usually represented by colors).
|
|
9
|
-
*
|
|
10
|
-
* 'unknown': unknown (gray color)
|
|
11
|
-
*
|
|
12
|
-
* 'good': 70% – 100 % (red color)
|
|
13
|
-
*
|
|
14
|
-
* 'average': 30% - 69% (blue color)
|
|
15
|
-
*
|
|
16
|
-
* 'bad': 0% - 29% (black color)
|
|
17
|
-
*/
|
|
18
|
-
colorRating: CSFDColorRating;
|
|
19
|
-
}
|
|
20
|
-
export type CSFDColorRating = 'bad' | 'average' | 'good' | 'unknown';
|
|
21
|
-
export type CSFDStars = 0 | 1 | 2 | 3 | 4 | 5;
|
|
22
|
-
export type CSFDFilmTypes = 'film' | 'TV film' | 'pořad' | 'seriál' | 'divadelní záznam' | 'koncert' | 'série' | 'studentský film' | 'amatérský film' | 'hudební videoklip' | 'epizoda';
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { CSFDScreening } from './global';
|
|
2
|
-
export interface CSFDMovie extends CSFDScreening {
|
|
3
|
-
rating: number | null;
|
|
4
|
-
poster: string;
|
|
5
|
-
photo: string;
|
|
6
|
-
ratingCount: number | null;
|
|
7
|
-
duration: number | string;
|
|
8
|
-
titlesOther: CSFDTitlesOther[];
|
|
9
|
-
origins: string[];
|
|
10
|
-
descriptions: string[];
|
|
11
|
-
trivia: string[];
|
|
12
|
-
genres: CSFDGenres[] | string[];
|
|
13
|
-
creators: CSFDCreators;
|
|
14
|
-
vod: CSFDVod[];
|
|
15
|
-
tags: string[];
|
|
16
|
-
premieres: CSFDPremiere[];
|
|
17
|
-
related: CSFDMovieListItem[];
|
|
18
|
-
similar: CSFDMovieListItem[];
|
|
19
|
-
}
|
|
20
|
-
export type CSFDVodService = 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'iTunes' | 'KVIFF.TV' | 'Edisonline' | 'o2tv' | 'SledovaniTV' | 'Starmax' | 'DAFilms' | 'FILMY ČESKY A ZADARMO' | 'Youtube Česká filmová klasika' | 'VAPET' | 'VOREL FILM' | 'ivysilani' | 'Google Play' | 'Voyo' | 'DVD';
|
|
21
|
-
export interface CSFDVod {
|
|
22
|
-
title: CSFDVodService;
|
|
23
|
-
url: string;
|
|
24
|
-
}
|
|
25
|
-
export interface CSFDCreators {
|
|
26
|
-
directors: CSFDCreator[];
|
|
27
|
-
writers: CSFDCreator[];
|
|
28
|
-
cinematography: CSFDCreator[];
|
|
29
|
-
music: CSFDCreator[];
|
|
30
|
-
actors: CSFDCreator[];
|
|
31
|
-
basedOn: CSFDCreator[];
|
|
32
|
-
producers: CSFDCreator[];
|
|
33
|
-
filmEditing: CSFDCreator[];
|
|
34
|
-
costumeDesign: CSFDCreator[];
|
|
35
|
-
productionDesign: CSFDCreator[];
|
|
36
|
-
}
|
|
37
|
-
export interface CSFDTitlesOther {
|
|
38
|
-
country: string;
|
|
39
|
-
title: string;
|
|
40
|
-
}
|
|
41
|
-
export interface CSFDCreator {
|
|
42
|
-
/**
|
|
43
|
-
* CSFD person ID.
|
|
44
|
-
*
|
|
45
|
-
* You can always assemble url from ID like this:
|
|
46
|
-
*
|
|
47
|
-
* `https://www.csfd.cz/tvurce/${id}`
|
|
48
|
-
*/
|
|
49
|
-
id: number;
|
|
50
|
-
name: string;
|
|
51
|
-
url: string;
|
|
52
|
-
}
|
|
53
|
-
export interface CSFDMovieListItem {
|
|
54
|
-
id: number;
|
|
55
|
-
title: string;
|
|
56
|
-
url: string;
|
|
57
|
-
}
|
|
58
|
-
export type CSFDGenres = 'Akční' | 'Animovaný' | 'Dobrodružný' | 'Dokumentární' | 'Drama' | 'Experimentální' | 'Fantasy' | 'Film-Noir' | 'Historický' | 'Horor' | 'Hudební' | 'IMAX' | 'Katastrofický' | 'Komedie' | 'Krátkometrážní' | 'Krimi' | 'Loutkový' | 'Muzikál' | 'Mysteriózní' | 'Naučný' | 'Podobenství' | 'Poetický' | 'Pohádka' | 'Povídkový' | 'Psychologický' | 'Publicistický' | 'Reality-TV' | 'Road movie' | 'Rodinný' | 'Romantický' | 'Sci-Fi' | 'Soutěžní' | 'Sportovní' | 'Stand-up' | 'Talk-show' | 'Taneční' | 'Telenovela' | 'Thriller' | 'Válečný' | 'Western' | 'Zábavný' | 'Životopisný';
|
|
59
|
-
export type CSFDCreatorGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Produkce' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
|
|
60
|
-
export interface CSFDPremiere {
|
|
61
|
-
country: string;
|
|
62
|
-
format: string;
|
|
63
|
-
date: string;
|
|
64
|
-
company: string;
|
|
65
|
-
}
|
|
66
|
-
export type CSFDBoxContent = 'Související' | 'Podobné';
|
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
import { CSFDScreening } from './global';
|
|
2
|
-
import { CSFDCreator } from './movie.interface';
|
|
3
|
-
export interface CSFDSearch {
|
|
4
|
-
movies: CSFDSearchMovie[];
|
|
5
|
-
tvSeries: CSFDSearchMovie[];
|
|
6
|
-
creators: CSFDSearchCreator[];
|
|
7
|
-
users: CSFDSearchUser[];
|
|
8
|
-
}
|
|
9
|
-
export interface CSFDSearchMovie extends CSFDScreening {
|
|
10
|
-
poster: string;
|
|
11
|
-
origins: string[];
|
|
12
|
-
creators: CSFDSearchCreators;
|
|
13
|
-
}
|
|
14
|
-
export interface CSFDSearchUser {
|
|
15
|
-
id: number;
|
|
16
|
-
user: string;
|
|
17
|
-
userRealName: string;
|
|
18
|
-
avatar: string;
|
|
19
|
-
url: string;
|
|
20
|
-
}
|
|
21
|
-
export interface CSFDSearchCreator extends CSFDCreator {
|
|
22
|
-
image: string;
|
|
23
|
-
}
|
|
24
|
-
export interface CSFDSearchCreators {
|
|
25
|
-
directors: CSFDCreator[];
|
|
26
|
-
actors: CSFDCreator[];
|
|
27
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
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';
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CinemaScraper = void 0;
|
|
4
|
-
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
-
const fetchers_1 = require("../fetchers");
|
|
6
|
-
const vars_1 = require("../vars");
|
|
7
|
-
const cinema_helper_1 = require("./../helpers/cinema.helper");
|
|
8
|
-
class CinemaScraper {
|
|
9
|
-
async cinemas(district = 1, period = 'today') {
|
|
10
|
-
const url = (0, vars_1.cinemasUrl)(district, period);
|
|
11
|
-
const response = await (0, fetchers_1.fetchPage)(url);
|
|
12
|
-
const cinemasHtml = (0, node_html_parser_1.parse)(response);
|
|
13
|
-
const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
|
|
14
|
-
this.buildCinemas(contentNode);
|
|
15
|
-
return this.cinema;
|
|
16
|
-
}
|
|
17
|
-
buildCinemas(contentNode) {
|
|
18
|
-
const cinemas = [];
|
|
19
|
-
contentNode.forEach((x) => {
|
|
20
|
-
const cinemaInfo = (0, cinema_helper_1.parseCinema)(x);
|
|
21
|
-
const cinema = {
|
|
22
|
-
id: (0, cinema_helper_1.getCinemaId)(x),
|
|
23
|
-
name: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.name,
|
|
24
|
-
city: cinemaInfo === null || cinemaInfo === void 0 ? void 0 : cinemaInfo.city,
|
|
25
|
-
url: (0, cinema_helper_1.getCinemaUrl)(x),
|
|
26
|
-
coords: (0, cinema_helper_1.getCoords)(x),
|
|
27
|
-
screenings: (0, cinema_helper_1.getGroupedFilmsByDate)(x)
|
|
28
|
-
};
|
|
29
|
-
cinemas.push(cinema);
|
|
30
|
-
});
|
|
31
|
-
this.cinema = cinemas;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
exports.CinemaScraper = CinemaScraper;
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CreatorScraper = void 0;
|
|
4
|
-
const node_html_parser_1 = require("node-html-parser");
|
|
5
|
-
const fetchers_1 = require("../fetchers");
|
|
6
|
-
const creator_helper_1 = require("../helpers/creator.helper");
|
|
7
|
-
const vars_1 = require("../vars");
|
|
8
|
-
class CreatorScraper {
|
|
9
|
-
async creator(creatorId) {
|
|
10
|
-
const url = (0, vars_1.creatorUrl)(+creatorId);
|
|
11
|
-
const response = await (0, fetchers_1.fetchPage)(url);
|
|
12
|
-
const creatorHtml = (0, node_html_parser_1.parse)(response);
|
|
13
|
-
const asideNode = creatorHtml.querySelector('.creator-about');
|
|
14
|
-
const filmsNode = creatorHtml.querySelector('.creator-filmography');
|
|
15
|
-
this.buildCreator(+creatorId, asideNode, filmsNode);
|
|
16
|
-
return this.person;
|
|
17
|
-
}
|
|
18
|
-
buildCreator(id, asideEl, filmsNode) {
|
|
19
|
-
var _a, _b, _c;
|
|
20
|
-
this.person = {
|
|
21
|
-
id,
|
|
22
|
-
name: (0, creator_helper_1.getName)(asideEl),
|
|
23
|
-
birthday: (_a = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _a === void 0 ? void 0 : _a.birthday,
|
|
24
|
-
birthplace: (_b = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _b === void 0 ? void 0 : _b.birthPlace,
|
|
25
|
-
photo: (0, creator_helper_1.getPhoto)(asideEl),
|
|
26
|
-
age: ((_c = (0, creator_helper_1.getBirthdayInfo)(asideEl)) === null || _c === void 0 ? void 0 : _c.age) || null,
|
|
27
|
-
bio: (0, creator_helper_1.getBio)(asideEl),
|
|
28
|
-
films: (0, creator_helper_1.getFilms)(filmsNode)
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
exports.CreatorScraper = CreatorScraper;
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
import { CSFDUserRatingConfig, CSFDUserRatings } from '../interfaces/user-ratings.interface';
|
|
2
|
-
export declare class UserRatingsScraper {
|
|
3
|
-
private films;
|
|
4
|
-
userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
|
|
5
|
-
private getPage;
|
|
6
|
-
private buildUserRatings;
|
|
7
|
-
}
|
package/vars.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
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;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|