node-csfd-api 1.11.0-beta.1 → 1.11.0-next.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/README.md +0 -3
- package/fetchers/index.js +2 -2
- package/helpers/movie.helper.d.ts +0 -2
- package/helpers/movie.helper.js +2 -24
- package/interfaces/movie.interface.d.ts +1 -3
- package/package.json +2 -3
- package/services/movie.service.js +0 -2
- package/test.d.ts +0 -0
- package/test.js +1 -0
- package/vars.js +1 -1
package/README.md
CHANGED
|
@@ -59,8 +59,6 @@ csfd.movie(535121).then((movie) => console.log(movie));
|
|
|
59
59
|
colorRating: 'good',
|
|
60
60
|
rating: 73,
|
|
61
61
|
ratingCount: 6654,
|
|
62
|
-
photo: '//image.pmgstatic.com/cache/resized/w1326/files/images/film/photos/162/980/162980090_bbffbb.jpg',
|
|
63
|
-
trivia: ['Když Henry (Tory Kittles) se svým mladším bratrem...', 'Ve filmu se střídají...'],
|
|
64
62
|
titlesOther: [
|
|
65
63
|
{ country: 'USA', title: 'Dragged Across Concrete' },
|
|
66
64
|
{ country: 'Kanada', title: 'Dragged Across Concrete' },
|
|
@@ -373,7 +371,6 @@ _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter
|
|
|
373
371
|
- [x] Premieres
|
|
374
372
|
- [x] Related movies
|
|
375
373
|
- [x] Similar movies
|
|
376
|
-
- [x] Trivia
|
|
377
374
|
- [ ] All images
|
|
378
375
|
- [ ] Reviews
|
|
379
376
|
- [ ] OST
|
package/fetchers/index.js
CHANGED
|
@@ -4,7 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.fetchPage = void 0;
|
|
7
|
-
const
|
|
7
|
+
const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
8
8
|
const USER_AGENTS = [
|
|
9
9
|
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
|
|
10
10
|
'Mozilla/5.0 (iPhone; CPU iPhone OS 14_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) CriOS/87.0.4280.77 Mobile/15E148 Safari/604.1',
|
|
@@ -16,7 +16,7 @@ const headers = {
|
|
|
16
16
|
};
|
|
17
17
|
const fetchPage = async (url) => {
|
|
18
18
|
try {
|
|
19
|
-
const response = await (0,
|
|
19
|
+
const response = await (0, node_fetch_1.default)(url, { headers });
|
|
20
20
|
if (response.status >= 400 && response.status < 600) {
|
|
21
21
|
throw new Error(`node-csfd-api: Bad response ${response.status} for url: ${url}`);
|
|
22
22
|
}
|
|
@@ -12,8 +12,6 @@ export declare const getYear: (el: HTMLElement) => string | number;
|
|
|
12
12
|
export declare const getDuration: (el: HTMLElement) => number;
|
|
13
13
|
export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
|
|
14
14
|
export declare const getPoster: (el: HTMLElement) => string;
|
|
15
|
-
export declare const getRandomPhoto: (el: HTMLElement) => string;
|
|
16
|
-
export declare const getTrivia: (el: HTMLElement) => string[];
|
|
17
15
|
export declare const getDescriptions: (el: HTMLElement) => string[];
|
|
18
16
|
export declare const getDirectors: (el: HTMLElement) => CSFDCreator[];
|
|
19
17
|
export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
|
package/helpers/movie.helper.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.
|
|
3
|
+
exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getTitlesOther = exports.getDuration = exports.getYear = exports.getRatingCount = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0;
|
|
4
4
|
const global_helper_1 = require("./global.helper");
|
|
5
5
|
const getId = (el) => {
|
|
6
6
|
const url = el.querySelector('.tabs .tab-nav-list a').attributes.href;
|
|
@@ -90,8 +90,8 @@ exports.getTitlesOther = getTitlesOther;
|
|
|
90
90
|
const getPoster = (el) => {
|
|
91
91
|
var _a;
|
|
92
92
|
const poster = el.querySelector('.film-posters img');
|
|
93
|
+
// Resolve empty image
|
|
93
94
|
if (poster) {
|
|
94
|
-
// Resolve empty image
|
|
95
95
|
if ((_a = poster.classNames) === null || _a === void 0 ? void 0 : _a.includes('empty-image')) {
|
|
96
96
|
return null;
|
|
97
97
|
}
|
|
@@ -106,28 +106,6 @@ const getPoster = (el) => {
|
|
|
106
106
|
}
|
|
107
107
|
};
|
|
108
108
|
exports.getPoster = getPoster;
|
|
109
|
-
const getRandomPhoto = (el) => {
|
|
110
|
-
var _a;
|
|
111
|
-
const imageNode = el.querySelector('.gallery-item picture img');
|
|
112
|
-
const image = (_a = imageNode === null || imageNode === void 0 ? void 0 : imageNode.attributes) === null || _a === void 0 ? void 0 : _a.src;
|
|
113
|
-
if (image) {
|
|
114
|
-
return image.replace(/\/w663\//, '/w1326/');
|
|
115
|
-
}
|
|
116
|
-
else {
|
|
117
|
-
return null;
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
exports.getRandomPhoto = getRandomPhoto;
|
|
121
|
-
const getTrivia = (el) => {
|
|
122
|
-
const triviaNodes = el.querySelectorAll('.article-trivia ul li');
|
|
123
|
-
if (triviaNodes === null || triviaNodes === void 0 ? void 0 : triviaNodes.length) {
|
|
124
|
-
return triviaNodes.map((node) => node.textContent.trim().replace(/(\r\n|\n|\r|\t)/gm, ''));
|
|
125
|
-
}
|
|
126
|
-
else {
|
|
127
|
-
return null;
|
|
128
|
-
}
|
|
129
|
-
};
|
|
130
|
-
exports.getTrivia = getTrivia;
|
|
131
109
|
const getDescriptions = (el) => {
|
|
132
110
|
var _a;
|
|
133
111
|
// TODO more plots
|
|
@@ -2,13 +2,11 @@ import { CSFDScreening } from './global';
|
|
|
2
2
|
export interface CSFDMovie extends CSFDScreening {
|
|
3
3
|
rating: number | null;
|
|
4
4
|
poster: string;
|
|
5
|
-
photo: string;
|
|
6
5
|
ratingCount: number | null;
|
|
7
6
|
duration: number | string;
|
|
8
7
|
titlesOther: CSFDTitlesOther[];
|
|
9
8
|
origins: string[];
|
|
10
9
|
descriptions: string[];
|
|
11
|
-
trivia: string[];
|
|
12
10
|
genres: CSFDGenres[] | string[];
|
|
13
11
|
creators: CSFDCreators;
|
|
14
12
|
vod: CSFDVod[];
|
|
@@ -18,7 +16,7 @@ export interface CSFDMovie extends CSFDScreening {
|
|
|
18
16
|
similar: CSFDMovieListItem[];
|
|
19
17
|
}
|
|
20
18
|
export interface CSFDVod {
|
|
21
|
-
title: 'Netflix' | 'hbogo' | '
|
|
19
|
+
title: 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'ivysilani' | 'Aerovod' | 'o2tv' | 'Voyo' | 'FILMY ČESKY A ZADARMO' | 'VAPET' | 'VOREL FILM' | string;
|
|
22
20
|
url: string;
|
|
23
21
|
}
|
|
24
22
|
export interface CSFDCreators {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "1.11.0-
|
|
3
|
+
"version": "1.11.0-next.0",
|
|
4
4
|
"description": "Simple NPM library for scraping CSFD",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"author": "BART! <bart@bartweb.cz>",
|
|
@@ -16,13 +16,12 @@
|
|
|
16
16
|
"publish:next": "yarn && yarn build && yarn test --coverage true && npm publish --folder dist --tag beta",
|
|
17
17
|
"postversion": "git push && git push --follow-tags",
|
|
18
18
|
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
19
|
-
"prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
|
|
20
19
|
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
|
|
21
20
|
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
|
|
22
21
|
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
|
|
23
22
|
},
|
|
24
23
|
"dependencies": {
|
|
25
|
-
"
|
|
24
|
+
"node-fetch": "cjs",
|
|
26
25
|
"node-html-parser": "^5.1.0"
|
|
27
26
|
},
|
|
28
27
|
"repository": {
|
|
@@ -32,8 +32,6 @@ class MovieScraper {
|
|
|
32
32
|
ratingCount: (0, movie_helper_1.getRatingCount)(asideEl),
|
|
33
33
|
titlesOther: (0, movie_helper_1.getTitlesOther)(el),
|
|
34
34
|
poster: (0, movie_helper_1.getPoster)(el),
|
|
35
|
-
photo: (0, movie_helper_1.getRandomPhoto)(el),
|
|
36
|
-
trivia: (0, movie_helper_1.getTrivia)(el),
|
|
37
35
|
creators: {
|
|
38
36
|
directors: (0, movie_helper_1.getDirectors)(el),
|
|
39
37
|
writers: (0, movie_helper_1.getGroup)(el, 'Scénář'),
|
package/test.d.ts
ADDED
|
File without changes
|
package/test.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";
|
package/vars.js
CHANGED
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.searchUrl = exports.creatorUrl = exports.movieUrl = exports.userRatingsUrl = void 0;
|
|
4
4
|
const userRatingsUrl = (user, page) => `https://www.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/${page ? '?page=' + page : ''}`;
|
|
5
5
|
exports.userRatingsUrl = userRatingsUrl;
|
|
6
|
-
const movieUrl = (movie) => `https://www.csfd.cz/film/${encodeURIComponent(movie)}
|
|
6
|
+
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;
|