node-csfd-api
Advanced tools
Comparing version 3.0.0-next.2 to 3.0.0-next.3
"use strict"; | ||
// import fetch from 'cross-fetch'; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -12,4 +11,8 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
var __importDefault = (this && this.__importDefault) || function (mod) { | ||
return (mod && mod.__esModule) ? mod : { "default": mod }; | ||
}; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.fetchPage = void 0; | ||
const cross_fetch_1 = __importDefault(require("cross-fetch")); | ||
const USER_AGENTS = [ | ||
@@ -26,3 +29,3 @@ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36', | ||
try { | ||
const response = yield fetch(url, { headers }); | ||
const response = yield (0, cross_fetch_1.default)(url, { headers }); | ||
if (response.status >= 400 && response.status < 600) { | ||
@@ -29,0 +32,0 @@ throw new Error(`node-csfd-api: Bad response ${response.status} for url: ${url}`); |
@@ -27,8 +27,10 @@ "use strict"; | ||
const usersNode = html.querySelectorAll('.main-users article'); | ||
return this.parseSearch(moviesNode, usersNode); | ||
const tvSeriesNode = html.querySelectorAll('.main-series article'); | ||
return this.parseSearch(moviesNode, usersNode, tvSeriesNode); | ||
}); | ||
} | ||
parseSearch(moviesNode, usersNode) { | ||
parseSearch(moviesNode, usersNode, tvSeriesNode) { | ||
const movies = []; | ||
const users = []; | ||
const tvSeries = []; | ||
moviesNode.map((m) => { | ||
@@ -63,6 +65,24 @@ const url = (0, search_helper_1.getUrl)(m); | ||
}); | ||
tvSeriesNode.map((m) => { | ||
const url = (0, search_helper_1.getUrl)(m); | ||
const user = { | ||
id: (0, global_helper_1.parseIdFromUrl)(url), | ||
title: (0, search_helper_1.getTitle)(m), | ||
year: (0, search_helper_1.getYear)(m), | ||
url: `https://www.csfd.cz${url}`, | ||
type: (0, search_helper_1.getType)(m), | ||
colorRating: (0, search_helper_1.getColorRating)(m), | ||
poster: (0, search_helper_1.getPoster)(m), | ||
origins: (0, search_helper_1.getOrigins)(m), | ||
creators: { | ||
directors: (0, search_helper_1.parsePeople)(m, 'directors'), | ||
actors: (0, search_helper_1.parsePeople)(m, 'actors') | ||
} | ||
}; | ||
tvSeries.push(user); | ||
}); | ||
const search = { | ||
movies: movies, | ||
users: users, | ||
tvSeries: [], | ||
tvSeries: tvSeries, | ||
creators: [] | ||
@@ -69,0 +89,0 @@ }; |
@@ -1,2 +0,1 @@ | ||
// import fetch from 'cross-fetch'; | ||
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
@@ -11,2 +10,3 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } | ||
}; | ||
import fetch from 'cross-fetch'; | ||
const USER_AGENTS = [ | ||
@@ -13,0 +13,0 @@ 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36', |
@@ -24,8 +24,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const usersNode = html.querySelectorAll('.main-users article'); | ||
return this.parseSearch(moviesNode, usersNode); | ||
const tvSeriesNode = html.querySelectorAll('.main-series article'); | ||
return this.parseSearch(moviesNode, usersNode, tvSeriesNode); | ||
}); | ||
} | ||
parseSearch(moviesNode, usersNode) { | ||
parseSearch(moviesNode, usersNode, tvSeriesNode) { | ||
const movies = []; | ||
const users = []; | ||
const tvSeries = []; | ||
moviesNode.map((m) => { | ||
@@ -60,6 +62,24 @@ const url = getUrl(m); | ||
}); | ||
tvSeriesNode.map((m) => { | ||
const url = getUrl(m); | ||
const user = { | ||
id: parseIdFromUrl(url), | ||
title: getTitle(m), | ||
year: getYear(m), | ||
url: `https://www.csfd.cz${url}`, | ||
type: getType(m), | ||
colorRating: getColorRating(m), | ||
poster: getPoster(m), | ||
origins: getOrigins(m), | ||
creators: { | ||
directors: parsePeople(m, 'directors'), | ||
actors: parsePeople(m, 'actors') | ||
} | ||
}; | ||
tvSeries.push(user); | ||
}); | ||
const search = { | ||
movies: movies, | ||
users: users, | ||
tvSeries: [], | ||
tvSeries: tvSeries, | ||
creators: [] | ||
@@ -66,0 +86,0 @@ }; |
{ | ||
"name": "node-csfd-api", | ||
"version": "3.0.0-next.2", | ||
"version": "3.0.0-next.3", | ||
"description": "ČSFD API in JavaScript. Amazing NPM library for scrapping csfd.cz :)", | ||
@@ -18,3 +18,3 @@ "main": "./cjs/index.js", | ||
"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'\"", | ||
"publish:next": "yarn && yarn build && yarn test --coverage true && npm publish --folder dist --tag beta", | ||
"publish:next": "yarn && yarn build && yarn test --coverage true && cd dist && npm publish --tag beta", | ||
"postversion": "git push && git push --follow-tags", | ||
@@ -27,3 +27,8 @@ "release:beta": "npm version preminor --preid=beta -m \"chore(update): prelease %s β\"", | ||
}, | ||
"publishConfig": { | ||
"access": "public", | ||
"registry": "https://registry.npmjs.org" | ||
}, | ||
"dependencies": { | ||
"cross-fetch": "^3.1.5", | ||
"node-html-parser": "^6.1.4" | ||
@@ -53,3 +58,3 @@ }, | ||
"engines": { | ||
"node": ">= 12" | ||
"node": ">= 14" | ||
}, | ||
@@ -56,0 +61,0 @@ "license": "MIT", |
@@ -6,3 +6,3 @@ [![npm version](https://badge.fury.io/js/node-csfd-api.svg)](https://badge.fury.io/js/node-csfd-api) | ||
# CSFD API 2022 | ||
# CSFD API 2023 | ||
@@ -177,2 +177,15 @@ > JavaScript NPM library for scraping **Czech Movie Database (csfd.cz)** | ||
], | ||
tvSeries: [ | ||
{ | ||
id: 71924, | ||
title: 'Království', | ||
year: 1994, | ||
url: 'https://www.csfd.cz/film/71924-kralovstvi/', | ||
type: 'seriál', | ||
colorRating: 'good', | ||
poster: 'https://image.pmgstatic.com/cache/resized/w60h85/files/images/film/posters/166/708/166708064_2da697.jpg', | ||
origins: ['Dánsko'], | ||
creators: [] | ||
} | ||
], | ||
users: [ | ||
@@ -386,4 +399,4 @@ { | ||
- [x] Users | ||
- [x] TV Series | ||
- [ ] Creators | ||
- [ ] TV Series | ||
- [x] Creators | ||
@@ -449,3 +462,3 @@ - [x] Bio | ||
Copyright © 2022 [Lukas Bartak](http://bartweb.cz) | ||
Copyright © 2020 – 2023 [Lukas Bartak](http://bartweb.cz) | ||
@@ -452,0 +465,0 @@ Proudly powered by nature 🗻, wind 💨, tea 🍵 and beer 🍺 ;) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
104468
2076
466
1
2
+ Addedcross-fetch@^3.1.5
+ Addedcross-fetch@3.1.8(transitive)
+ Addednode-fetch@2.7.0(transitive)
+ Addedtr46@0.0.3(transitive)
+ Addedwebidl-conversions@3.0.1(transitive)
+ Addedwhatwg-url@5.0.0(transitive)