node-csfd-api 2.3.0 → 2.4.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 CHANGED
@@ -60,6 +60,8 @@ csfd.movie(535121).then((movie) => console.log(movie));
60
60
  colorRating: 'good',
61
61
  rating: 73,
62
62
  ratingCount: 6654,
63
+ photo: '//image.pmgstatic.com/cache/resized/w1326/files/images/film/photos/162/980/162980090_bbffbb.jpg',
64
+ trivia: ['Když Henry (Tory Kittles) se svým mladším bratrem...', 'Ve filmu se střídají...'],
63
65
  titlesOther: [
64
66
  { country: 'USA', title: 'Dragged Across Concrete' },
65
67
  { country: 'Kanada', title: 'Dragged Across Concrete' },
@@ -372,7 +374,8 @@ _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter
372
374
  - [x] Premieres
373
375
  - [x] Related movies
374
376
  - [x] Similar movies
375
- - [ ] All images
377
+ - [x] Trivia
378
+ - [x] Photo from movie (random)
376
379
  - [ ] Reviews
377
380
  - [ ] OST
378
381
  - [ ] Search
@@ -2,9 +2,14 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseISO8601Duration = exports.addProtocol = exports.parseColor = exports.getColor = exports.parseIdFromUrl = void 0;
4
4
  const parseIdFromUrl = (url) => {
5
- const idSlug = url.split('/')[2];
6
- const id = idSlug.split('-')[0];
7
- return +id;
5
+ if (url) {
6
+ const idSlug = url === null || url === void 0 ? void 0 : url.split('/')[2];
7
+ const id = idSlug === null || idSlug === void 0 ? void 0 : idSlug.split('-')[0];
8
+ return +id || null;
9
+ }
10
+ else {
11
+ return null;
12
+ }
8
13
  };
9
14
  exports.parseIdFromUrl = parseIdFromUrl;
10
15
  const getColor = (cls) => {
@@ -12,6 +12,8 @@ export declare const getYear: (el: string) => number;
12
12
  export declare const getDuration: (jsonLdRaw: string, 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[];
15
17
  export declare const getDescriptions: (el: HTMLElement) => string[];
16
18
  export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
17
19
  export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
@@ -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.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;
3
+ exports.getTags = exports.getPremieres = exports.getBoxMovies = exports.getBoxContent = exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDescriptions = exports.getTrivia = exports.getRandomPhoto = 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;
@@ -125,6 +125,28 @@ const getPoster = (el) => {
125
125
  }
126
126
  };
127
127
  exports.getPoster = getPoster;
128
+ const getRandomPhoto = (el) => {
129
+ var _a;
130
+ const imageNode = el.querySelector('.gallery-item picture img');
131
+ const image = (_a = imageNode === null || imageNode === void 0 ? void 0 : imageNode.attributes) === null || _a === void 0 ? void 0 : _a.src;
132
+ if (image) {
133
+ return image.replace(/\/w663\//, '/w1326/');
134
+ }
135
+ else {
136
+ return null;
137
+ }
138
+ };
139
+ exports.getRandomPhoto = getRandomPhoto;
140
+ const getTrivia = (el) => {
141
+ const triviaNodes = el.querySelectorAll('.article-trivia ul li');
142
+ if (triviaNodes === null || triviaNodes === void 0 ? void 0 : triviaNodes.length) {
143
+ return triviaNodes.map((node) => node.textContent.trim().replace(/(\r\n|\n|\r|\t)/gm, ''));
144
+ }
145
+ else {
146
+ return null;
147
+ }
148
+ };
149
+ exports.getTrivia = getTrivia;
128
150
  const getDescriptions = (el) => {
129
151
  return el
130
152
  .querySelectorAll('.body--plots .plot-full p, .body--plots .plots .plots-item p')
@@ -2,11 +2,13 @@ import { CSFDScreening } from './global';
2
2
  export interface CSFDMovie extends CSFDScreening {
3
3
  rating: number | null;
4
4
  poster: string;
5
+ photo: string;
5
6
  ratingCount: number | null;
6
7
  duration: number | string;
7
8
  titlesOther: CSFDTitlesOther[];
8
9
  origins: string[];
9
10
  descriptions: string[];
11
+ trivia: string[];
10
12
  genres: CSFDGenres[] | string[];
11
13
  creators: CSFDCreators;
12
14
  vod: CSFDVod[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "2.3.0",
3
+ "version": "2.4.0",
4
4
  "description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
5
5
  "main": "./index.js",
6
6
  "author": "BART! <bart@bartweb.cz>",
@@ -16,13 +16,14 @@
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 β\"",
19
20
  "release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
20
21
  "release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
21
22
  "release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
22
23
  },
23
24
  "dependencies": {
24
25
  "cross-fetch": "^3.1.5",
25
- "node-html-parser": "^5.3.2"
26
+ "node-html-parser": "^5.3.3"
26
27
  },
27
28
  "repository": {
28
29
  "url": "git+https://github.com/bartholomej/node-csfd-api.git",
@@ -33,6 +33,8 @@ class MovieScraper {
33
33
  ratingCount: (0, movie_helper_1.getRatingCount)(asideEl),
34
34
  titlesOther: (0, movie_helper_1.getTitlesOther)(el),
35
35
  poster: (0, movie_helper_1.getPoster)(el),
36
+ photo: (0, movie_helper_1.getRandomPhoto)(el),
37
+ trivia: (0, movie_helper_1.getTrivia)(el),
36
38
  creators: {
37
39
  directors: (0, movie_helper_1.getGroup)(el, 'Režie'),
38
40
  writers: (0, movie_helper_1.getGroup)(el, 'Scénář'),
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)}/prehled/`;
7
7
  exports.movieUrl = movieUrl;
8
8
  const creatorUrl = (creator) => `https://www.csfd.cz/tvurce/${encodeURIComponent(creator)}`;
9
9
  exports.creatorUrl = creatorUrl;