node-csfd-api 3.0.0-next.2 → 3.0.0-next.3

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
@@ -3,7 +3,7 @@
3
3
  [![Build & Publish](https://github.com/bartholomej/node-csfd-api/workflows/Publish/badge.svg)](https://github.com/bartholomej/node-csfd-api/actions)
4
4
  [![codecov](https://codecov.io/gh/bartholomej/node-csfd-api/branch/master/graph/badge.svg?token=YQH9UoVrGP)](https://codecov.io/gh/bartholomej/node-csfd-api)
5
5
 
6
- # CSFD API 2022
6
+ # CSFD API 2023
7
7
 
8
8
  > JavaScript NPM library for scraping **Czech Movie Database (csfd.cz)**
9
9
  >
@@ -173,6 +173,19 @@ movies: [
173
173
  }
174
174
  }
175
175
  ],
176
+ tvSeries: [
177
+ {
178
+ id: 71924,
179
+ title: 'Království',
180
+ year: 1994,
181
+ url: 'https://www.csfd.cz/film/71924-kralovstvi/',
182
+ type: 'seriál',
183
+ colorRating: 'good',
184
+ poster: 'https://image.pmgstatic.com/cache/resized/w60h85/files/images/film/posters/166/708/166708064_2da697.jpg',
185
+ origins: ['Dánsko'],
186
+ creators: []
187
+ }
188
+ ],
176
189
  users: [
177
190
  {
178
191
  id: 912,
@@ -381,8 +394,8 @@ _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter
381
394
  - [ ] Search
382
395
  - [x] Movies
383
396
  - [x] Users
397
+ - [x] TV Series
384
398
  - [ ] Creators
385
- - [ ] TV Series
386
399
  - [x] Creators
387
400
  - [x] Bio
388
401
  - [x] Movies (TODO categories)
@@ -443,7 +456,7 @@ That's why, with node-csfd-api, what happens on your device stays on your device
443
456
 
444
457
  ## License
445
458
 
446
- Copyright © 2022 [Lukas Bartak](http://bartweb.cz)
459
+ Copyright © 2020 – 2023 [Lukas Bartak](http://bartweb.cz)
447
460
 
448
461
  Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)
449
462
 
@@ -1,5 +1,4 @@
1
1
  "use strict";
2
- // import fetch from 'cross-fetch';
3
2
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
4
3
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
5
4
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -9,8 +8,12 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
9
8
  step((generator = generator.apply(thisArg, _arguments || [])).next());
10
9
  });
11
10
  };
11
+ var __importDefault = (this && this.__importDefault) || function (mod) {
12
+ return (mod && mod.__esModule) ? mod : { "default": mod };
13
+ };
12
14
  Object.defineProperty(exports, "__esModule", { value: true });
13
15
  exports.fetchPage = void 0;
16
+ const cross_fetch_1 = __importDefault(require("cross-fetch"));
14
17
  const USER_AGENTS = [
15
18
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
16
19
  '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',
@@ -22,7 +25,7 @@ const headers = {
22
25
  };
23
26
  const fetchPage = (url) => __awaiter(void 0, void 0, void 0, function* () {
24
27
  try {
25
- const response = yield fetch(url, { headers });
28
+ const response = yield (0, cross_fetch_1.default)(url, { headers });
26
29
  if (response.status >= 400 && response.status < 600) {
27
30
  throw new Error(`node-csfd-api: Bad response ${response.status} for url: ${url}`);
28
31
  }
@@ -24,12 +24,14 @@ class SearchScraper {
24
24
  const html = (0, node_html_parser_1.parse)(response);
25
25
  const moviesNode = html.querySelectorAll('.main-movies article');
26
26
  const usersNode = html.querySelectorAll('.main-users article');
27
- return this.parseSearch(moviesNode, usersNode);
27
+ const tvSeriesNode = html.querySelectorAll('.main-series article');
28
+ return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
28
29
  });
29
30
  }
30
- parseSearch(moviesNode, usersNode) {
31
+ parseSearch(moviesNode, usersNode, tvSeriesNode) {
31
32
  const movies = [];
32
33
  const users = [];
34
+ const tvSeries = [];
33
35
  moviesNode.map((m) => {
34
36
  const url = (0, search_helper_1.getUrl)(m);
35
37
  const movie = {
@@ -59,10 +61,28 @@ class SearchScraper {
59
61
  };
60
62
  users.push(user);
61
63
  });
64
+ tvSeriesNode.map((m) => {
65
+ const url = (0, search_helper_1.getUrl)(m);
66
+ const user = {
67
+ id: (0, global_helper_1.parseIdFromUrl)(url),
68
+ title: (0, search_helper_1.getTitle)(m),
69
+ year: (0, search_helper_1.getYear)(m),
70
+ url: `https://www.csfd.cz${url}`,
71
+ type: (0, search_helper_1.getType)(m),
72
+ colorRating: (0, search_helper_1.getColorRating)(m),
73
+ poster: (0, search_helper_1.getPoster)(m),
74
+ origins: (0, search_helper_1.getOrigins)(m),
75
+ creators: {
76
+ directors: (0, search_helper_1.parsePeople)(m, 'directors'),
77
+ actors: (0, search_helper_1.parsePeople)(m, 'actors')
78
+ }
79
+ };
80
+ tvSeries.push(user);
81
+ });
62
82
  const search = {
63
83
  movies: movies,
64
84
  users: users,
65
- tvSeries: [],
85
+ tvSeries: tvSeries,
66
86
  creators: []
67
87
  };
68
88
  return search;
@@ -1,4 +1,3 @@
1
- // import fetch from 'cross-fetch';
2
1
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
2
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
3
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,6 +7,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
7
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
8
  });
10
9
  };
10
+ import fetch from 'cross-fetch';
11
11
  const USER_AGENTS = [
12
12
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
13
13
  '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',
@@ -21,12 +21,14 @@ export class SearchScraper {
21
21
  const html = parse(response);
22
22
  const moviesNode = html.querySelectorAll('.main-movies article');
23
23
  const usersNode = html.querySelectorAll('.main-users article');
24
- return this.parseSearch(moviesNode, usersNode);
24
+ const tvSeriesNode = html.querySelectorAll('.main-series article');
25
+ return this.parseSearch(moviesNode, usersNode, tvSeriesNode);
25
26
  });
26
27
  }
27
- parseSearch(moviesNode, usersNode) {
28
+ parseSearch(moviesNode, usersNode, tvSeriesNode) {
28
29
  const movies = [];
29
30
  const users = [];
31
+ const tvSeries = [];
30
32
  moviesNode.map((m) => {
31
33
  const url = getUrl(m);
32
34
  const movie = {
@@ -56,10 +58,28 @@ export class SearchScraper {
56
58
  };
57
59
  users.push(user);
58
60
  });
61
+ tvSeriesNode.map((m) => {
62
+ const url = getUrl(m);
63
+ const user = {
64
+ id: parseIdFromUrl(url),
65
+ title: getTitle(m),
66
+ year: getYear(m),
67
+ url: `https://www.csfd.cz${url}`,
68
+ type: getType(m),
69
+ colorRating: getColorRating(m),
70
+ poster: getPoster(m),
71
+ origins: getOrigins(m),
72
+ creators: {
73
+ directors: parsePeople(m, 'directors'),
74
+ actors: parsePeople(m, 'actors')
75
+ }
76
+ };
77
+ tvSeries.push(user);
78
+ });
59
79
  const search = {
60
80
  movies: movies,
61
81
  users: users,
62
- tvSeries: [],
82
+ tvSeries: tvSeries,
63
83
  creators: []
64
84
  };
65
85
  return search;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "3.0.0-next.2",
3
+ "version": "3.0.0-next.3",
4
4
  "description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)",
5
5
  "main": "./cjs/index.js",
6
6
  "author": "BART! <bart@bartweb.cz>",
@@ -15,7 +15,7 @@
15
15
  "lint": "eslint ./src/**/**/* --fix",
16
16
  "test": "jest",
17
17
  "fix-paths": "yarn json -I -f ./dist/package.json -e \"this.module='./esm/index.js';this.main='./cjs/index.js';this.types='./types/index.d.ts'\"",
18
- "publish:next": "yarn && yarn build && yarn test --coverage true && npm publish --folder dist --tag beta",
18
+ "publish:next": "yarn && yarn build && yarn test --coverage true && cd dist && npm publish --tag beta",
19
19
  "postversion": "git push && git push --follow-tags",
20
20
  "release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
21
21
  "prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
@@ -23,7 +23,12 @@
23
23
  "release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
24
24
  "release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
25
25
  },
26
+ "publishConfig": {
27
+ "access": "public",
28
+ "registry": "https://registry.npmjs.org"
29
+ },
26
30
  "dependencies": {
31
+ "cross-fetch": "^3.1.5",
27
32
  "node-html-parser": "^6.1.4"
28
33
  },
29
34
  "repository": {
@@ -48,7 +53,7 @@
48
53
  "api"
49
54
  ],
50
55
  "engines": {
51
- "node": ">= 12"
56
+ "node": ">= 14"
52
57
  },
53
58
  "license": "MIT",
54
59
  "module": "./esm/index.js",