node-csfd-api 2.6.0 → 2.7.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
@@ -3,20 +3,21 @@
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
  >
10
- > - Browser + Node.js (SSR)
11
10
  > - JavaScript / TypeScript
11
+ > - Browser + Node.js (SSR)
12
12
  > - Tested (~100% Code coverage)
13
13
  > - ✅ Ready for new ČSFD 2021!
14
14
  > - You can use in:
15
15
  > - Firebase function
16
16
  > - AWS λ (lambda function)
17
+ > - CloudFlare Worker
17
18
  > - Chrome extension
18
19
  > - React native app
19
- > - ...
20
+ > - Browsers (Pay attention to CORS)
20
21
 
21
22
  ## Install
22
23
 
@@ -138,7 +139,7 @@ csfd.movie(535121).then((movie) => console.log(movie));
138
139
 
139
140
  ### Search
140
141
 
141
- > Search movies and users
142
+ > Search movies, users and TV series
142
143
 
143
144
  ```javascript
144
145
  import { csfd } from 'node-csfd-api';
@@ -173,6 +174,19 @@ movies: [
173
174
  }
174
175
  }
175
176
  ],
177
+ tvSeries: [
178
+ {
179
+ id: 71924,
180
+ title: 'Království',
181
+ year: 1994,
182
+ url: 'https://www.csfd.cz/film/71924-kralovstvi/',
183
+ type: 'seriál',
184
+ colorRating: 'good',
185
+ poster: 'https://image.pmgstatic.com/cache/resized/w60h85/files/images/film/posters/166/708/166708064_2da697.jpg',
186
+ origins: ['Dánsko'],
187
+ creators: []
188
+ }
189
+ ],
176
190
  users: [
177
191
  {
178
192
  id: 912,
@@ -186,7 +200,7 @@ users: [
186
200
 
187
201
  ### Creators
188
202
 
189
- > Search creators and filmography
203
+ > Get creator info + filmography
190
204
 
191
205
  ```javascript
192
206
  import { csfd } from 'node-csfd-api';
@@ -338,9 +352,19 @@ _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter
338
352
 
339
353
  ## Used by
340
354
 
341
- - [Dafilms web extension](https://chrome.google.com/webstore/detail/dafilms/hgcgneddmgflnbmhkjnefiobjgobbmdm?hl=en) ([code](https://github.com/bartholomej/dafilms-ext)) – Parser for film ratings (web extension)
342
- - [bartweb.cz](https://bartweb.cz) – **Last seen** section (Firebase function)
343
- - KinoKlub Mobile application for AeroFilms (native Android + iOS application)
355
+ ### Web extensions
356
+
357
+ - [Netflix: chrome extension](https://chrome.google.com/webstore/detail/netflix-csfd/eomgekccbddnlpmehgdjmlphndjgnlni) ([code](https://github.com/bartholomej/netflix-csfd-ext))
358
+ - [Dafilms: chrome extension](https://chrome.google.com/webstore/detail/dafilms/hgcgneddmgflnbmhkjnefiobjgobbmdm) ([code](https://github.com/bartholomej/dafilms-ext))
359
+ - [Kviff.tv: chrome extension](https://chrome.google.com/webstore/detail/kvifftv-%20-csfd/ihpngekoejodiligajlppbeedofhnmfm) ([code](https://github.com/bartholomej/kviff-ext))
360
+
361
+ ### Web applications
362
+
363
+ - [bartweb.cz](https://bartweb.cz) – **Last seen** section (**Firebase function**)
364
+
365
+ ### Mobile applications
366
+
367
+ - KinoKlub – Mobile application for AeroFilms (React Native: Android + iOS application)
344
368
 
345
369
  ## Roadmap
346
370
 
@@ -381,8 +405,8 @@ _Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter
381
405
  - [ ] Search
382
406
  - [x] Movies
383
407
  - [x] Users
408
+ - [x] TV Series
384
409
  - [ ] Creators
385
- - [ ] TV Series
386
410
  - [x] Creators
387
411
  - [x] Bio
388
412
  - [x] Movies (TODO categories)
@@ -443,7 +467,7 @@ That's why, with node-csfd-api, what happens on your device stays on your device
443
467
 
444
468
  ## License
445
469
 
446
- Copyright © 2022 [Lukas Bartak](http://bartweb.cz)
470
+ Copyright © 2020 – 2023 [Lukas Bartak](http://bartweb.cz)
447
471
 
448
472
  Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;)
449
473
 
package/fetchers/index.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
2
  Object.defineProperty(exports, "__esModule", { value: true });
6
3
  exports.fetchPage = void 0;
7
- const cross_fetch_1 = __importDefault(require("cross-fetch"));
4
+ // Check if `fetch` is available in global scope (nodejs 18+) or in window (browser). If not, use cross-fetch polyfill.
5
+ const cross_fetch_1 = require("cross-fetch");
6
+ const fetchSafe = (typeof fetch === 'function' && fetch) || // ServiceWorker fetch (Cloud Functions + Chrome extension)
7
+ (typeof global === 'object' && global.fetch) || // Node.js 18+ fetch
8
+ (typeof window !== 'undefined' && window.fetch) || // Browser fetch
9
+ cross_fetch_1.fetch; // Polyfill fetch
8
10
  const USER_AGENTS = [
9
11
  'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36',
10
12
  '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 +18,7 @@ const headers = {
16
18
  };
17
19
  const fetchPage = async (url) => {
18
20
  try {
19
- const response = await (0, cross_fetch_1.default)(url, { headers });
21
+ const response = await fetchSafe(url, { headers });
20
22
  if (response.status >= 400 && response.status < 600) {
21
23
  throw new Error(`node-csfd-api: Bad response ${response.status} for url: ${url}`);
22
24
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "node-csfd-api",
3
- "version": "2.6.0",
3
+ "version": "2.7.1",
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>",
@@ -13,7 +13,7 @@
13
13
  "demo": "ts-node demo",
14
14
  "lint": "eslint ./src/**/**/* --fix",
15
15
  "test": "jest",
16
- "publish:next": "yarn && yarn build && yarn test --coverage true && npm publish --folder dist --tag beta",
16
+ "publish:next": "yarn && yarn build && yarn test --coverage true && cd dist && npm publish --tag next",
17
17
  "postversion": "git push && git push --follow-tags",
18
18
  "release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"",
19
19
  "prerelease:beta": "npm version prerelease --preid=beta -m \"chore(update): prelease %s β\"",
@@ -21,9 +21,13 @@
21
21
  "release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
22
22
  "release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\""
23
23
  },
24
+ "publishConfig": {
25
+ "access": "public",
26
+ "registry": "https://registry.npmjs.org"
27
+ },
24
28
  "dependencies": {
25
29
  "cross-fetch": "^3.1.5",
26
- "node-html-parser": "^6.1.4"
30
+ "node-html-parser": "^6.1.5"
27
31
  },
28
32
  "repository": {
29
33
  "url": "git+https://github.com/bartholomej/node-csfd-api.git",