node-csfd-api
Advanced tools
Comparing version 1.0.0-beta.3 to 1.0.0
@@ -9,5 +9,14 @@ "use strict"; | ||
const vars_1 = require("../vars"); | ||
const USER_AGENTS = [ | ||
'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.88 Safari/537.36', | ||
'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', | ||
'Mozilla/5.0 (Linux; Android 10; SM-A205U) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36', | ||
'Mozilla/5.0 (Linux; Android 10) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/87.0.4280.101 Mobile Safari/537.36' | ||
]; | ||
const headers = { | ||
'User-Agent': USER_AGENTS[Math.floor(Math.random() * USER_AGENTS.length)] | ||
}; | ||
const fetchUserRatings = async (user) => { | ||
const url = vars_1.userRatingsUrl(user); | ||
const response = await cross_fetch_1.default(url); | ||
const response = await cross_fetch_1.default(url, { headers }); | ||
return await response.text(); | ||
@@ -18,5 +27,5 @@ }; | ||
const url = vars_1.movieUrl(+movieId); | ||
const response = await cross_fetch_1.default(url); | ||
const response = await cross_fetch_1.default(url, { headers }); | ||
return await response.text(); | ||
}; | ||
exports.fetchMovie = fetchMovie; |
import { HTMLElement } from 'node-html-parser'; | ||
import { CSFDColorRating } from '../interfaces/global'; | ||
import { CSFDCreator, CSFDCreatorGroups, CSFDGenres, CSFDOtherTitles } from '../interfaces/movie.interface'; | ||
import { CSFDCreator, CSFDCreatorGroups, CSFDGenres, CSFDOtherTitles, CSFDVod } from '../interfaces/movie.interface'; | ||
export declare const getId: (el: HTMLElement) => number; | ||
@@ -19,1 +19,2 @@ export declare const getTitle: (el: HTMLElement) => string; | ||
export declare const getType: (el: HTMLElement) => string; | ||
export declare const getVods: (el: HTMLElement) => CSFDVod[]; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getOtherTitles = exports.getDuration = exports.getYear = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0; | ||
exports.getVods = exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getOtherTitles = exports.getDuration = exports.getYear = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0; | ||
const global_helper_1 = require("./global.helper"); | ||
@@ -147,2 +147,18 @@ const getId = (el) => { | ||
exports.getType = getType; | ||
const getVods = (el) => { | ||
let vods = []; | ||
if (el) { | ||
const buttons = el.querySelectorAll('.button'); | ||
// Filter out social buttons | ||
const buttonsVod = buttons.filter((x) => !x.classNames.includes('button-social')); | ||
vods = buttonsVod.map((btn) => { | ||
return { | ||
title: btn.text.trim(), | ||
url: btn.attributes.href | ||
}; | ||
}); | ||
} | ||
return vods.length ? vods : []; | ||
}; | ||
exports.getVods = getVods; | ||
// TODO tags | ||
@@ -149,0 +165,0 @@ // export const getBoxContent = (el: HTMLElement, box: string): HTMLElement => { |
@@ -11,3 +11,8 @@ import { CSFDScreening } from './global'; | ||
creators: CSFDCreators; | ||
vod: CSFDVod[]; | ||
} | ||
export interface CSFDVod { | ||
title: 'Netflix' | 'hbogo' | 'Primve Video' | 'Apple TV+' | 'ivysilani' | 'Aerovod' | 'o2tv' | 'Voyo' | 'FILMY ČESKY A ZADARMO' | 'VAPET' | 'VOREL FILM' | string; | ||
url: string; | ||
} | ||
export interface CSFDCreators { | ||
@@ -14,0 +19,0 @@ directors: CSFDCreator[]; |
{ | ||
"name": "node-csfd-api", | ||
"version": "1.0.0-beta.3", | ||
"version": "1.0.0", | ||
"description": "Simple NPM library for scraping CSFD", | ||
@@ -24,3 +24,3 @@ "main": "./index.js", | ||
"cross-fetch": "^3.0.6", | ||
"node-html-parser": "^2.0.0" | ||
"node-html-parser": "^2.0.1" | ||
}, | ||
@@ -27,0 +27,0 @@ "repository": { |
@@ -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 | ||
# CSFD API 2021 | ||
@@ -12,4 +12,4 @@ > Tiny NPM library for scraping CSFD | ||
> - Browser + Node.js (SSR) | ||
> - TypeScript | ||
> - ✅ Ready for CSFD 2021! [See instructions](#CSFD-2021-beta) | ||
> - TypeScript 100% | ||
> - ✅ Ready for CSFD 2021! | ||
@@ -143,6 +143,11 @@ ## Install | ||
### More | ||
#### Options | ||
Work in progress... | ||
| Option | Type | Default | Description | | ||
| ---------------- | ------------------------------------------------------------------------------------------------------------------------------------------ | ------- | --------------------------------------------------------- | | ||
| **includesOnly** | [CSFDFilmTypes[]](https://github.com/bartholomej/node-csfd-api/blob/8fa5f9cbc7e7f2b62b0bd2c2b5a24c9a63444f6a/src/interfaces/global.ts#L25) | null | Including only film types. eg. `['TV Seriál', 'koncert']` | | ||
| **exclude** | [CSFDFilmTypes[]](https://github.com/bartholomej/node-csfd-api/blob/8fa5f9cbc7e7f2b62b0bd2c2b5a24c9a63444f6a/src/interfaces/global.ts#L25) | null | Excluding film types eg. `['epizoda', 'série']` | | ||
_Note: You can not use both parameters 'includesOnly' and 'excludes'. Parameter 'includesOnly' has a priority._ | ||
## CSFD 2021 (beta) | ||
@@ -156,2 +161,7 @@ | ||
## Roadmap | ||
- [ ] Search: movies, tv series, users, creators... | ||
- [ ] Profiles of creators... | ||
## Development | ||
@@ -167,3 +177,3 @@ | ||
You can find and modify it in `./demo.ts` file | ||
You can find and modify it in [`./demo.ts`](https://raw.githubusercontent.com/bartholomej/node-csfd-api/search/demo.ts) file | ||
@@ -170,0 +180,0 @@ ```bash |
@@ -13,8 +13,9 @@ "use strict"; | ||
const pageClasses = movieHtml.querySelector('.page-content').classNames; | ||
const asideNode = movieHtml.querySelector('.box-rating-container'); | ||
// const asideNode = movieHtml.querySelector('.box-rating-container'); | ||
const movieNode = movieHtml.querySelector('.main-movie-profile'); | ||
this.buildMovie(+movieId, movieNode, asideNode, pageClasses); | ||
const buttonsNode = movieHtml.querySelectorAll('.box-buttons')[0]; | ||
this.buildMovie(+movieId, movieNode, buttonsNode, pageClasses); | ||
return this.film; | ||
} | ||
buildMovie(movieId, el, elAside, pageClasses) { | ||
buildMovie(movieId, el, elButtons, pageClasses) { | ||
this.film = { | ||
@@ -45,3 +46,4 @@ id: movieId, | ||
productionDesign: movie_helper_1.getGroup(el, 'Scénografie') | ||
} | ||
}, | ||
vod: movie_helper_1.getVods(elButtons) | ||
}; | ||
@@ -48,0 +50,0 @@ } |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
30354
553
0
206
Updatednode-html-parser@^2.0.1