node-csfd-api 1.8.3 → 1.10.1
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
CHANGED
|
@@ -58,6 +58,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
|
|
|
58
58
|
origins: [ 'USA', 'Kanada' ],
|
|
59
59
|
colorRating: 'good',
|
|
60
60
|
rating: 73,
|
|
61
|
+
ratingCount: 6654,
|
|
61
62
|
titlesOther: [
|
|
62
63
|
{ country: 'USA', title: 'Dragged Across Concrete' },
|
|
63
64
|
{ country: 'Kanada', title: 'Dragged Across Concrete' },
|
|
@@ -65,7 +66,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
|
|
|
65
66
|
{ country: 'Austrálie', title: 'Dragged Across Concrete' },
|
|
66
67
|
{ country: 'Velká Británie', title: 'Dragged Across Concrete' }
|
|
67
68
|
],
|
|
68
|
-
poster: '//
|
|
69
|
+
poster: '//image.pmgstatic.com/cache/resized/w1080/files/images/film/posters/163/579/163579352_bf8737.jpg',
|
|
69
70
|
creators: {
|
|
70
71
|
directors: [
|
|
71
72
|
{
|
|
@@ -7,6 +7,7 @@ export declare const getGenres: (el: HTMLElement) => CSFDGenres[];
|
|
|
7
7
|
export declare const getOrigins: (el: HTMLElement) => string[];
|
|
8
8
|
export declare const getColorRating: (bodyClasses: string[]) => CSFDColorRating;
|
|
9
9
|
export declare const getRating: (el: HTMLElement) => number;
|
|
10
|
+
export declare const getRatingCount: (el: HTMLElement) => number;
|
|
10
11
|
export declare const getYear: (el: HTMLElement) => string | number;
|
|
11
12
|
export declare const getDuration: (el: HTMLElement) => number;
|
|
12
13
|
export declare const getTitlesOther: (el: HTMLElement) => CSFDTitlesOther[];
|
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.getPoster = exports.getTitlesOther = exports.getDuration = exports.getYear = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0;
|
|
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;
|
|
@@ -12,12 +12,12 @@ const getTitle = (el) => {
|
|
|
12
12
|
};
|
|
13
13
|
exports.getTitle = getTitle;
|
|
14
14
|
const getGenres = (el) => {
|
|
15
|
-
const genresRaw = el.querySelector('.genres').
|
|
15
|
+
const genresRaw = el.querySelector('.genres').textContent;
|
|
16
16
|
return genresRaw.split(' / ');
|
|
17
17
|
};
|
|
18
18
|
exports.getGenres = getGenres;
|
|
19
19
|
const getOrigins = (el) => {
|
|
20
|
-
const originsRaw = el.querySelector('.origin').
|
|
20
|
+
const originsRaw = el.querySelector('.origin').textContent;
|
|
21
21
|
const origins = originsRaw.split(',')[0];
|
|
22
22
|
return origins.split(' / ');
|
|
23
23
|
};
|
|
@@ -27,7 +27,7 @@ const getColorRating = (bodyClasses) => {
|
|
|
27
27
|
};
|
|
28
28
|
exports.getColorRating = getColorRating;
|
|
29
29
|
const getRating = (el) => {
|
|
30
|
-
const ratingRaw = el.querySelector('.rating-average').
|
|
30
|
+
const ratingRaw = el.querySelector('.rating-average').textContent;
|
|
31
31
|
const rating = +(ratingRaw === null || ratingRaw === void 0 ? void 0 : ratingRaw.replace(/%/g, '').trim());
|
|
32
32
|
if (Number.isInteger(rating)) {
|
|
33
33
|
return rating;
|
|
@@ -37,6 +37,18 @@ const getRating = (el) => {
|
|
|
37
37
|
}
|
|
38
38
|
};
|
|
39
39
|
exports.getRating = getRating;
|
|
40
|
+
const getRatingCount = (el) => {
|
|
41
|
+
var _a;
|
|
42
|
+
const ratingCountRaw = (_a = el.querySelector('.box-rating-container .counter')) === null || _a === void 0 ? void 0 : _a.textContent;
|
|
43
|
+
const ratingCount = +(ratingCountRaw === null || ratingCountRaw === void 0 ? void 0 : ratingCountRaw.replace(/[(\s)]/g, ''));
|
|
44
|
+
if (Number.isInteger(ratingCount)) {
|
|
45
|
+
return ratingCount;
|
|
46
|
+
}
|
|
47
|
+
else {
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
exports.getRatingCount = getRatingCount;
|
|
40
52
|
const getYear = (el) => {
|
|
41
53
|
return el.querySelector('.origin span').innerText.replace(/[{()}]/g, '');
|
|
42
54
|
};
|
|
@@ -62,7 +74,7 @@ const getTitlesOther = (el) => {
|
|
|
62
74
|
const namesNode = el.querySelectorAll('.film-names li');
|
|
63
75
|
return namesNode.map((el) => {
|
|
64
76
|
const country = el.querySelector('img.flag').attributes.alt;
|
|
65
|
-
const title = el.
|
|
77
|
+
const title = el.textContent.trim().split('\n')[0];
|
|
66
78
|
if (country && title) {
|
|
67
79
|
return {
|
|
68
80
|
country,
|
|
@@ -84,7 +96,8 @@ const getPoster = (el) => {
|
|
|
84
96
|
}
|
|
85
97
|
else {
|
|
86
98
|
// Full sized image (not thumb)
|
|
87
|
-
|
|
99
|
+
const imageThumb = poster.attributes.src.split('?')[0];
|
|
100
|
+
return imageThumb.replace(/\/w140\//, '/w1080/');
|
|
88
101
|
}
|
|
89
102
|
};
|
|
90
103
|
exports.getPoster = getPoster;
|
|
@@ -92,7 +105,7 @@ const getDescriptions = (el) => {
|
|
|
92
105
|
var _a;
|
|
93
106
|
// TODO more plots
|
|
94
107
|
const plot = (_a = el
|
|
95
|
-
.querySelector('.body--plots .plot-preview p')) === null || _a === void 0 ? void 0 : _a.
|
|
108
|
+
.querySelector('.body--plots .plot-preview p')) === null || _a === void 0 ? void 0 : _a.textContent.trim().replace(/(\r\n|\n|\r|\t)/gm, '');
|
|
96
109
|
return plot ? [plot] : [];
|
|
97
110
|
};
|
|
98
111
|
exports.getDescriptions = getDescriptions;
|
|
@@ -118,7 +131,7 @@ const parsePeople = (el) => {
|
|
|
118
131
|
exports.parsePeople = parsePeople;
|
|
119
132
|
const getGroup = (el, group) => {
|
|
120
133
|
const creators = el.querySelectorAll('.creators h4');
|
|
121
|
-
const element = creators.filter((elem) => elem.
|
|
134
|
+
const element = creators.filter((elem) => elem.textContent.trim().includes(group))[0];
|
|
122
135
|
if (element === null || element === void 0 ? void 0 : element.parentNode) {
|
|
123
136
|
return (0, exports.parsePeople)(element.parentNode);
|
|
124
137
|
}
|
|
@@ -140,7 +153,7 @@ const getVods = (el) => {
|
|
|
140
153
|
const buttonsVod = buttons.filter((x) => !x.classNames.includes('button-social'));
|
|
141
154
|
vods = buttonsVod.map((btn) => {
|
|
142
155
|
return {
|
|
143
|
-
title: btn.
|
|
156
|
+
title: btn.textContent.trim(),
|
|
144
157
|
url: btn.attributes.href
|
|
145
158
|
};
|
|
146
159
|
});
|
|
@@ -152,7 +165,7 @@ exports.getVods = getVods;
|
|
|
152
165
|
const getBoxContent = (el, box) => {
|
|
153
166
|
var _a;
|
|
154
167
|
const headers = el.querySelectorAll('section.box .box-header');
|
|
155
|
-
return (_a = headers.find((header) => header.querySelector('h3').
|
|
168
|
+
return (_a = headers.find((header) => header.querySelector('h3').textContent.trim().includes(box))) === null || _a === void 0 ? void 0 : _a.parentNode;
|
|
156
169
|
};
|
|
157
170
|
exports.getBoxContent = getBoxContent;
|
|
158
171
|
const getBoxMovies = (el, boxName) => {
|
|
@@ -179,7 +192,7 @@ const getPremieres = (el) => {
|
|
|
179
192
|
const [date, ...company] = premiereNode.querySelector('p + span').attributes.title.split(' ');
|
|
180
193
|
premiere.push({
|
|
181
194
|
country: ((_a = premiereNode.querySelector('.flag')) === null || _a === void 0 ? void 0 : _a.attributes.title) || null,
|
|
182
|
-
format: premiereNode.querySelector('p').
|
|
195
|
+
format: premiereNode.querySelector('p').textContent.trim().split(' od')[0],
|
|
183
196
|
date,
|
|
184
197
|
company: company.join(' ')
|
|
185
198
|
});
|
|
@@ -189,6 +202,6 @@ const getPremieres = (el) => {
|
|
|
189
202
|
exports.getPremieres = getPremieres;
|
|
190
203
|
const getTags = (el) => {
|
|
191
204
|
const tagsRaw = el.querySelectorAll('.box-content a[href*="/podrobne-vyhledavani/?tag="]');
|
|
192
|
-
return tagsRaw.map((tag) => tag.
|
|
205
|
+
return tagsRaw.map((tag) => tag.textContent);
|
|
193
206
|
};
|
|
194
207
|
exports.getTags = getTags;
|
|
@@ -2,6 +2,7 @@ import { CSFDScreening } from './global';
|
|
|
2
2
|
export interface CSFDMovie extends CSFDScreening {
|
|
3
3
|
rating: number | null;
|
|
4
4
|
poster: string;
|
|
5
|
+
ratingCount: number | null;
|
|
5
6
|
duration: number | string;
|
|
6
7
|
titlesOther: CSFDTitlesOther[];
|
|
7
8
|
origins: string[];
|
|
@@ -15,7 +16,7 @@ export interface CSFDMovie extends CSFDScreening {
|
|
|
15
16
|
similar: CSFDMovieListItem[];
|
|
16
17
|
}
|
|
17
18
|
export interface CSFDVod {
|
|
18
|
-
title: 'Netflix' | 'hbogo' | '
|
|
19
|
+
title: 'Netflix' | 'hbogo' | 'Prime Video' | 'Apple TV+' | 'ivysilani' | 'Aerovod' | 'o2tv' | 'Voyo' | 'FILMY ČESKY A ZADARMO' | 'VAPET' | 'VOREL FILM' | string;
|
|
19
20
|
url: string;
|
|
20
21
|
}
|
|
21
22
|
export interface CSFDCreators {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "node-csfd-api",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.10.1",
|
|
4
4
|
"description": "Simple NPM library for scraping CSFD",
|
|
5
5
|
"main": "./index.js",
|
|
6
6
|
"author": "BART! <bart@bartweb.cz>",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
"test": "jest",
|
|
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
|
-
"release:beta": "npm version
|
|
18
|
+
"release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
|
|
19
19
|
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
|
|
20
20
|
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
|
|
21
21
|
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
|
|
@@ -29,6 +29,7 @@ class MovieScraper {
|
|
|
29
29
|
origins: (0, movie_helper_1.getOrigins)(el),
|
|
30
30
|
colorRating: (0, movie_helper_1.getColorRating)(pageClasses),
|
|
31
31
|
rating: (0, movie_helper_1.getRating)(asideEl),
|
|
32
|
+
ratingCount: (0, movie_helper_1.getRatingCount)(asideEl),
|
|
32
33
|
titlesOther: (0, movie_helper_1.getTitlesOther)(el),
|
|
33
34
|
poster: (0, movie_helper_1.getPoster)(el),
|
|
34
35
|
creators: {
|