Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-csfd-api

Package Overview
Dependencies
Maintainers
1
Versions
104
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-csfd-api - npm Package Compare versions

Comparing version 1.0.0-beta.3 to 1.1.0-alpha.1

2

fetchers/index.d.ts

@@ -1,2 +0,2 @@

export declare const fetchUserRatings: (user: string | number) => Promise<string>;
export declare const fetchUserRatings: (user: string | number, page?: number) => Promise<string>;
export declare const fetchMovie: (movieId: number) => Promise<string>;

@@ -9,4 +9,4 @@ "use strict";

const vars_1 = require("../vars");
const fetchUserRatings = async (user) => {
const url = vars_1.userRatingsUrl(user);
const fetchUserRatings = async (user, page) => {
const url = vars_1.userRatingsUrl(user, page);
const response = await cross_fetch_1.default(url);

@@ -13,0 +13,0 @@ return await response.text();

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 => {

@@ -1,4 +0,3 @@

import { CSFDFilmTypes } from './interfaces/global';
import { CSFDMovie } from './interfaces/movie.interface';
import { CSFDUserRatings } from './interfaces/user-ratings.interface';
import { CSFDUserRatingConfig, CSFDUserRatings } from './interfaces/user-ratings.interface';
import { MovieScraper } from './services/movie.service';

@@ -10,8 +9,5 @@ import { UserRatingsScraper } from './services/user-ratings.service';

constructor(userRatingsService: UserRatingsScraper, movieService: MovieScraper);
userRatings(user: string | number, config?: {
includesOnly?: CSFDFilmTypes[];
excludes?: CSFDFilmTypes[];
}): Promise<CSFDUserRatings[]>;
userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
movie(movie: number): Promise<CSFDMovie>;
}
export declare const csfd: Csfd;

@@ -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[];

@@ -1,2 +0,2 @@

import { CSFDScreening, CSFDStars } from './global';
import { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';
export interface CSFDUserRatings extends CSFDScreening {

@@ -6,2 +6,7 @@ userRating: CSFDStars;

}
export interface CSFDUserRatingConfig {
includesOnly?: CSFDFilmTypes[];
excludes?: CSFDFilmTypes[];
allPages?: boolean;
}
export declare type Colors = 'lightgrey' | 'blue' | 'red' | 'grey';
{
"name": "node-csfd-api",
"version": "1.0.0-beta.3",
"version": "1.1.0-alpha.1",
"description": "Simple NPM library for scraping CSFD",

@@ -5,0 +5,0 @@ "main": "./index.js",

@@ -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 @@ }

@@ -1,10 +0,7 @@

import { CSFDFilmTypes } from '../interfaces/global';
import { CSFDUserRatings } from '../interfaces/user-ratings.interface';
import { CSFDUserRatingConfig, CSFDUserRatings } from '../interfaces/user-ratings.interface';
export declare class UserRatingsScraper {
private films;
userRatings(user: string | number, config?: {
includesOnly?: CSFDFilmTypes[];
excludes?: CSFDFilmTypes[];
}): Promise<CSFDUserRatings[]>;
userRatings(user: string | number, config?: CSFDUserRatingConfig): Promise<CSFDUserRatings[]>;
private getPage;
private buildUserRatings;
}

@@ -12,6 +12,25 @@ "use strict";

async userRatings(user, config) {
var _a, _b, _c, _d;
let allMovies = [];
const response = await fetchers_1.fetchUserRatings(user);
const items = node_html_parser_1.parse(response);
const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
// Get number of pages
const pagesNode = items.querySelector('.pagination');
const pages = +(pagesNode === null || pagesNode === void 0 ? void 0 : pagesNode.childNodes[pagesNode.childNodes.length - 4].rawText) || 1;
allMovies = this.getPage(config, movies);
if (config === null || config === void 0 ? void 0 : config.allPages) {
console.log('Fetching all pages', pages);
for (let i = 1; i <= pages; i++) {
console.log('Fetching page', i, 'out of', pages, '...');
const response = await fetchers_1.fetchUserRatings(user, i);
const items = node_html_parser_1.parse(response);
const movies = items.querySelectorAll('.box-user-rating .table-container tbody tr');
allMovies = [...allMovies, ...this.getPage(config, movies)];
}
return allMovies;
}
return allMovies;
}
getPage(config, movies) {
var _a, _b, _c, _d;
if (config) {

@@ -18,0 +37,0 @@ if (((_a = config.includesOnly) === null || _a === void 0 ? void 0 : _a.length) && ((_b = config.excludes) === null || _b === void 0 ? void 0 : _b.length)) {

@@ -1,2 +0,2 @@

export declare const userRatingsUrl: (user: string | number) => string;
export declare const userRatingsUrl: (user: string | number, page?: number) => string;
export declare const movieUrl: (movie: number) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.movieUrl = exports.userRatingsUrl = void 0;
const userRatingsUrl = (user) => `https://new.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/`;
const userRatingsUrl = (user, page) => `https://new.csfd.cz/uzivatel/${encodeURIComponent(user)}/hodnoceni/${page ? '?page=' + page : ''}`;
exports.userRatingsUrl = userRatingsUrl;
const movieUrl = (movie) => `https://new.csfd.cz/film/${encodeURIComponent(movie)}`;
exports.movieUrl = movieUrl;
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc