node-csfd-api 3.0.0-next.18 → 3.0.0-next.19
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/cjs/helpers/cinema.helper.js +7 -1
- package/cjs/index.js +2 -2
- package/cjs/services/cinema.service.js +3 -2
- package/cjs/vars.js +1 -1
- package/esm/helpers/cinema.helper.js +5 -0
- package/esm/index.js +2 -2
- package/esm/services/cinema.service.js +4 -3
- package/esm/vars.js +1 -1
- package/package.json +1 -1
- package/types/helpers/cinema.helper.d.ts +3 -2
- package/types/index.d.ts +2 -2
- package/types/interfaces/cinema.interface.d.ts +7 -1
- package/types/services/cinema.service.d.ts +2 -2
- package/types/vars.d.ts +2 -1
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.parseMeta = exports.getFilms = exports.getGroupedFilmsByDate = exports.parseCinema = exports.getCinemaUrl = exports.getCoords = exports.getName = exports.getId = exports.getColorRating = void 0;
|
|
3
|
+
exports.parseMeta = exports.getFilms = exports.getGroupedFilmsByDate = exports.parseCinema = exports.getCinemaUrl = exports.getCoords = exports.getName = exports.getId = exports.getCinemaId = exports.getColorRating = void 0;
|
|
4
4
|
const global_helper_1 = require("./global.helper");
|
|
5
5
|
const getColorRating = (el) => {
|
|
6
6
|
return (0, global_helper_1.parseColor)(el === null || el === void 0 ? void 0 : el.classNames.split(' ').pop());
|
|
7
7
|
};
|
|
8
8
|
exports.getColorRating = getColorRating;
|
|
9
|
+
const getCinemaId = (el) => {
|
|
10
|
+
var _a;
|
|
11
|
+
const id = (_a = el === null || el === void 0 ? void 0 : el.id) === null || _a === void 0 ? void 0 : _a.split('-')[1];
|
|
12
|
+
return +id;
|
|
13
|
+
};
|
|
14
|
+
exports.getCinemaId = getCinemaId;
|
|
9
15
|
const getId = (url) => {
|
|
10
16
|
if (url) {
|
|
11
17
|
return (0, global_helper_1.parseIdFromUrl)(url);
|
package/cjs/index.js
CHANGED
|
@@ -43,9 +43,9 @@ class Csfd {
|
|
|
43
43
|
return this.searchService.search(text);
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
-
cinema(district) {
|
|
46
|
+
cinema(district, period) {
|
|
47
47
|
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
-
return this.cinemaService.cinemas(+district);
|
|
48
|
+
return this.cinemaService.cinemas(+district, period);
|
|
49
49
|
});
|
|
50
50
|
}
|
|
51
51
|
}
|
|
@@ -15,9 +15,9 @@ const fetchers_1 = require("../fetchers");
|
|
|
15
15
|
const vars_1 = require("../vars");
|
|
16
16
|
const cinema_helper_1 = require("./../helpers/cinema.helper");
|
|
17
17
|
class CinemaScraper {
|
|
18
|
-
cinemas(district) {
|
|
18
|
+
cinemas(district = 1, period = 'today') {
|
|
19
19
|
return __awaiter(this, void 0, void 0, function* () {
|
|
20
|
-
const url = (0, vars_1.cinemasUrl)(district,
|
|
20
|
+
const url = (0, vars_1.cinemasUrl)(district, period);
|
|
21
21
|
const response = yield (0, fetchers_1.fetchPage)(url);
|
|
22
22
|
const cinemasHtml = (0, node_html_parser_1.parse)(response);
|
|
23
23
|
const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
|
|
@@ -30,6 +30,7 @@ class CinemaScraper {
|
|
|
30
30
|
contentNode.map((x) => {
|
|
31
31
|
var _a, _b;
|
|
32
32
|
const cinema = {
|
|
33
|
+
id: (0, cinema_helper_1.getCinemaId)(x),
|
|
33
34
|
name: (_a = (0, cinema_helper_1.parseCinema)(x)) === null || _a === void 0 ? void 0 : _a.name,
|
|
34
35
|
city: (_b = (0, cinema_helper_1.parseCinema)(x)) === null || _b === void 0 ? void 0 : _b.city,
|
|
35
36
|
url: (0, cinema_helper_1.getCinemaUrl)(x),
|
package/cjs/vars.js
CHANGED
|
@@ -7,7 +7,7 @@ const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie
|
|
|
7
7
|
exports.movieUrl = movieUrl;
|
|
8
8
|
const creatorUrl = (creator) => `https://www.csfd.cz/tvurce/${encodeURIComponent(creator)}`;
|
|
9
9
|
exports.creatorUrl = creatorUrl;
|
|
10
|
-
const cinemasUrl = (district
|
|
10
|
+
const cinemasUrl = (district, period) => {
|
|
11
11
|
return `https://www.csfd.cz/kino/?period=${period}&district=${district}`;
|
|
12
12
|
};
|
|
13
13
|
exports.cinemasUrl = cinemasUrl;
|
|
@@ -2,6 +2,11 @@ import { parseColor, parseIdFromUrl } from './global.helper';
|
|
|
2
2
|
export const getColorRating = (el) => {
|
|
3
3
|
return parseColor(el === null || el === void 0 ? void 0 : el.classNames.split(' ').pop());
|
|
4
4
|
};
|
|
5
|
+
export const getCinemaId = (el) => {
|
|
6
|
+
var _a;
|
|
7
|
+
const id = (_a = el === null || el === void 0 ? void 0 : el.id) === null || _a === void 0 ? void 0 : _a.split('-')[1];
|
|
8
|
+
return +id;
|
|
9
|
+
};
|
|
5
10
|
export const getId = (url) => {
|
|
6
11
|
if (url) {
|
|
7
12
|
return parseIdFromUrl(url);
|
package/esm/index.js
CHANGED
|
@@ -40,9 +40,9 @@ export class Csfd {
|
|
|
40
40
|
return this.searchService.search(text);
|
|
41
41
|
});
|
|
42
42
|
}
|
|
43
|
-
cinema(district) {
|
|
43
|
+
cinema(district, period) {
|
|
44
44
|
return __awaiter(this, void 0, void 0, function* () {
|
|
45
|
-
return this.cinemaService.cinemas(+district);
|
|
45
|
+
return this.cinemaService.cinemas(+district, period);
|
|
46
46
|
});
|
|
47
47
|
}
|
|
48
48
|
}
|
|
@@ -10,11 +10,11 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
10
10
|
import { parse } from 'node-html-parser';
|
|
11
11
|
import { fetchPage } from '../fetchers';
|
|
12
12
|
import { cinemasUrl } from '../vars';
|
|
13
|
-
import { getCinemaUrl, getCoords, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
|
|
13
|
+
import { getCinemaId, getCinemaUrl, getCoords, getGroupedFilmsByDate, parseCinema } from './../helpers/cinema.helper';
|
|
14
14
|
export class CinemaScraper {
|
|
15
|
-
cinemas(district) {
|
|
15
|
+
cinemas(district = 1, period = 'today') {
|
|
16
16
|
return __awaiter(this, void 0, void 0, function* () {
|
|
17
|
-
const url = cinemasUrl(district,
|
|
17
|
+
const url = cinemasUrl(district, period);
|
|
18
18
|
const response = yield fetchPage(url);
|
|
19
19
|
const cinemasHtml = parse(response);
|
|
20
20
|
const contentNode = cinemasHtml.querySelectorAll('#snippet--cinemas section.box');
|
|
@@ -27,6 +27,7 @@ export class CinemaScraper {
|
|
|
27
27
|
contentNode.map((x) => {
|
|
28
28
|
var _a, _b;
|
|
29
29
|
const cinema = {
|
|
30
|
+
id: getCinemaId(x),
|
|
30
31
|
name: (_a = parseCinema(x)) === null || _a === void 0 ? void 0 : _a.name,
|
|
31
32
|
city: (_b = parseCinema(x)) === null || _b === void 0 ? void 0 : _b.city,
|
|
32
33
|
url: getCinemaUrl(x),
|
package/esm/vars.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const userRatingsUrl = (user, page) => `https://www.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/${page ? '?page=' + page : ''}`;
|
|
2
2
|
export const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}/prehled/`;
|
|
3
3
|
export const creatorUrl = (creator) => `https://www.csfd.cz/tvurce/${encodeURIComponent(creator)}`;
|
|
4
|
-
export const cinemasUrl = (district
|
|
4
|
+
export const cinemasUrl = (district, period) => {
|
|
5
5
|
return `https://www.csfd.cz/kino/?period=${period}&district=${district}`;
|
|
6
6
|
};
|
|
7
7
|
export const searchUrl = (text) => `https://www.csfd.cz/hledat/?q=${encodeURIComponent(text)}`;
|
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { CSFDCinemaMeta, CSFDCinemaMovie } from 'interfaces/cinema.interface';
|
|
1
|
+
import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from 'interfaces/cinema.interface';
|
|
2
2
|
import { HTMLElement } from 'node-html-parser';
|
|
3
3
|
import { CSFDColorRating } from '../interfaces/global';
|
|
4
4
|
export declare const getColorRating: (el: HTMLElement) => CSFDColorRating;
|
|
5
|
+
export declare const getCinemaId: (el: HTMLElement | null) => number;
|
|
5
6
|
export declare const getId: (url: string) => number;
|
|
6
7
|
export declare const getName: (el: HTMLElement | null) => string;
|
|
7
8
|
export declare const getCoords: (el: HTMLElement | null) => {
|
|
@@ -13,6 +14,6 @@ export declare const parseCinema: (el: HTMLElement | null) => {
|
|
|
13
14
|
city: string;
|
|
14
15
|
name: string;
|
|
15
16
|
};
|
|
16
|
-
export declare const getGroupedFilmsByDate: (el: HTMLElement | null) =>
|
|
17
|
+
export declare const getGroupedFilmsByDate: (el: HTMLElement | null) => CSFDCinemaGroupedFilmsByDate[];
|
|
17
18
|
export declare const getFilms: (date: string, el: HTMLElement | null) => CSFDCinemaMovie[];
|
|
18
19
|
export declare const parseMeta: (meta: string[]) => CSFDCinemaMeta[];
|
package/types/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CSFDCinema } from 'interfaces/cinema.interface';
|
|
1
|
+
import { CSFDCinema, CSFDCinemaPeriod } from 'interfaces/cinema.interface';
|
|
2
2
|
import { CSFDCreator } from './interfaces/creator.interface';
|
|
3
3
|
import { CSFDMovie } from './interfaces/movie.interface';
|
|
4
4
|
import { CSFDSearch } from './interfaces/search.interface';
|
|
@@ -19,6 +19,6 @@ export declare class Csfd {
|
|
|
19
19
|
movie(movie: number): Promise<CSFDMovie>;
|
|
20
20
|
creator(creator: number): Promise<CSFDCreator>;
|
|
21
21
|
search(text: string): Promise<CSFDSearch>;
|
|
22
|
-
cinema(district: number): Promise<CSFDCinema[]>;
|
|
22
|
+
cinema(district: number, period: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
|
|
23
23
|
}
|
|
24
24
|
export declare const csfd: Csfd;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { CSFDMovieListItem } from './movie.interface';
|
|
2
2
|
export interface CSFDCinema {
|
|
3
|
+
id: number;
|
|
3
4
|
name: string;
|
|
4
5
|
city: string;
|
|
5
6
|
url: string;
|
|
@@ -8,10 +9,15 @@ export interface CSFDCinema {
|
|
|
8
9
|
lng: number;
|
|
9
10
|
};
|
|
10
11
|
region?: string;
|
|
11
|
-
screenings:
|
|
12
|
+
screenings: CSFDCinemaGroupedFilmsByDate[];
|
|
13
|
+
}
|
|
14
|
+
export interface CSFDCinemaGroupedFilmsByDate {
|
|
15
|
+
date: string;
|
|
16
|
+
films: CSFDCinemaMovie[];
|
|
12
17
|
}
|
|
13
18
|
export interface CSFDCinemaMovie extends CSFDMovieListItem {
|
|
14
19
|
meta: CSFDCinemaMeta[];
|
|
15
20
|
showTimes: string[];
|
|
16
21
|
}
|
|
17
22
|
export type CSFDCinemaMeta = 'dubbing' | '3D' | 'subtitles' | string;
|
|
23
|
+
export type CSFDCinemaPeriod = 'today' | 'weekend' | 'week' | 'tomorrow' | 'month';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { CSFDCinema } from '../interfaces/cinema.interface';
|
|
1
|
+
import { CSFDCinema, CSFDCinemaPeriod } from '../interfaces/cinema.interface';
|
|
2
2
|
export declare class CinemaScraper {
|
|
3
3
|
private cinema;
|
|
4
|
-
cinemas(district
|
|
4
|
+
cinemas(district?: number, period?: CSFDCinemaPeriod): Promise<CSFDCinema[]>;
|
|
5
5
|
private buildCinemas;
|
|
6
6
|
}
|
package/types/vars.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { CSFDCinemaPeriod } from 'interfaces/cinema.interface';
|
|
1
2
|
export declare const userRatingsUrl: (user: string | number, page?: number) => string;
|
|
2
3
|
export declare const movieUrl: (movie: number) => string;
|
|
3
4
|
export declare const creatorUrl: (creator: number | string) => string;
|
|
4
|
-
export declare const cinemasUrl: (district
|
|
5
|
+
export declare const cinemasUrl: (district: number | string, period: CSFDCinemaPeriod) => string;
|
|
5
6
|
export declare const searchUrl: (text: string) => string;
|