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 0.5.0 to 0.6.0

11

helpers/movie.helper.d.ts

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

import { CSFDCreatoreGroups, CSFDCreators, CSFDGenres, CSFDOtherTitles } from 'interfaces/movie.interface';
import { CSFDColorRating } from 'interfaces/global';
import { CSFDCreator, CSFDCreatorGroups, CSFDGenres, CSFDOtherTitles } from 'interfaces/movie.interface';
import { HTMLElement } from 'node-html-parser';

@@ -7,2 +8,4 @@ export declare const getId: (el: HTMLElement) => number;

export declare const getOrigins: (el: HTMLElement) => string[];
export declare const getColorRating: (bodyClasses: string[]) => CSFDColorRating;
export declare const getRating: (el: HTMLElement) => number;
export declare const getYear: (el: HTMLElement) => string | number;

@@ -12,5 +15,5 @@ export declare const getOtherTitles: (el: HTMLElement) => CSFDOtherTitles[];

export declare const getDescriptions: (el: HTMLElement) => string[];
export declare const getDirectors: (el: HTMLElement) => CSFDCreators[];
export declare const parsePeople: (el: HTMLElement) => CSFDCreators[];
export declare const getGroup: (el: HTMLElement, group: CSFDCreatoreGroups) => CSFDCreators[];
export declare const getDirectors: (el: HTMLElement) => CSFDCreator[];
export declare const parsePeople: (el: HTMLElement) => CSFDCreator[];
export declare const getGroup: (el: HTMLElement, group: CSFDCreatorGroups) => CSFDCreator[];
export declare const getType: (el: HTMLElement) => string;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getOtherTitles = exports.getYear = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0;
exports.getType = exports.getGroup = exports.parsePeople = exports.getDirectors = exports.getDescriptions = exports.getPoster = exports.getOtherTitles = exports.getYear = exports.getRating = exports.getColorRating = exports.getOrigins = exports.getGenres = exports.getTitle = exports.getId = void 0;
const global_helper_1 = require("./global.helper");

@@ -21,2 +21,26 @@ exports.getId = (el) => {

};
exports.getColorRating = (bodyClasses) => {
const colorRatingClass = bodyClasses.find((cls) => cls.includes('th'));
switch (colorRatingClass) {
case 'th-0':
return 'unknown';
case 'th-1':
return 'good';
case 'th-2':
return 'average';
case 'th-3':
return 'bad';
default:
return 'unknown';
}
};
exports.getRating = (el) => {
const ratingRaw = el.querySelector('#rating .average').text;
if (ratingRaw !== '') {
return +ratingRaw.replace(/%/g, '');
}
else {
return null;
}
};
exports.getYear = (el) => {

@@ -23,0 +47,0 @@ return el.querySelector('.origin span').innerText;

import { CSFDScreening } from './global';
export interface CSFDMovie extends CSFDScreening {
rating: number | null;
poster: string;

@@ -7,10 +8,17 @@ otherTitles: CSFDOtherTitles[];

descriptions: string[];
directors: CSFDCreators[];
actors: CSFDCreators[];
basedOn: CSFDCreators[];
writers: CSFDCreators[];
music: CSFDCreators[];
producers: CSFDCreators[];
genres: CSFDGenres[] | string[];
creators: CSFDCreators;
}
export interface CSFDCreators {
directors: CSFDCreator[];
writers: CSFDCreator[];
cinematography: CSFDCreator[];
music: CSFDCreator[];
actors: CSFDCreator[];
basedOn: CSFDCreator[];
producers: CSFDCreator[];
filmEditing: CSFDCreator[];
costumeDesign: CSFDCreator[];
productionDesign: CSFDCreator[];
}
export interface CSFDOtherTitles {

@@ -20,3 +28,3 @@ country: string;

}
export interface CSFDCreators {
export interface CSFDCreator {
/**

@@ -34,2 +42,2 @@ * CSFD person ID.

export declare type CSFDGenres = 'Akční' | 'Animovaný' | 'Dobrodružný' | 'Dokumentární' | 'Drama' | 'Experimentální' | 'Fantasy' | 'Film-Noir' | 'Historický' | 'Horor' | 'Hudební' | 'IMAX' | 'Katastrofický' | 'Komedie' | 'Krátkometrážní' | 'Krimi' | 'Loutkový' | 'Muzikál' | 'Mysteriózní' | 'Naučný' | 'Podobenství' | 'Poetický' | 'Pohádka' | 'Povídkový' | 'Psychologický' | 'Publicistický' | 'Reality-TV' | 'Road movie' | 'Rodinný' | 'Romantický' | 'Sci-Fi' | 'Soutěžní' | 'Sportovní' | 'Stand-up' | 'Talk-show' | 'Taneční' | 'Telenovela' | 'Thriller' | 'Válečný' | 'Western' | 'Zábavný' | 'Životopisný';
export declare type CSFDCreatoreGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Producenti' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
export declare type CSFDCreatorGroups = 'Režie' | 'Scénář' | 'Kamera' | 'Hudba' | 'Hrají' | 'Producenti' | 'Střih' | 'Předloha' | 'Scénografie' | 'Kostýmy';
{
"name": "node-csfd-api",
"version": "0.5.0",
"version": "0.6.0",
"description": "Simple NPM library for scraping CSFD",

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

@@ -54,2 +54,3 @@ [![npm version](https://badge.fury.io/js/node-csfd-api.svg)](https://badge.fury.io/js/node-csfd-api)

colorRating: 'good',
rating: 73,
otherTitles: [

@@ -96,3 +97,3 @@ { country: 'USA', title: 'Dragged Across Concrete' },

{
id: 320006
id: 320006,
name: 'Sefton Fincham',

@@ -125,5 +126,5 @@ url: 'https://www.csfd.cz/tvurce/320006-sefton-fincham/'

url: 'https://www.csfd.cz/film/812944-david-attenborough-zivot-na-nasi-planete/',
colorRating: 'good'
colorRating: 'good',
userDate: '01.11.2020',
userRating: 5,
userRating: 5
},

@@ -135,5 +136,5 @@ {

url: 'https://www.csfd.cz/film/912552-coronation/',
colorRating: 'good'
colorRating: 'good',
userDate: '28.10.2020',
userRating: 4,
userRating: 4
}

@@ -140,0 +141,0 @@ ];

@@ -5,3 +5,3 @@ import { CSFDMovie } from 'interfaces/movie.interface';

movie(movie: string | number): Promise<CSFDMovie>;
private buildUserRatings;
private buildMovie;
}

@@ -13,6 +13,7 @@ "use strict";

const movieNode = movieHtml.querySelector('#pg-web-film');
this.buildUserRatings(movieNode, movie);
const bodyClasses = movieHtml.querySelector('body').classNames;
this.buildMovie(movieNode, movie, bodyClasses);
return this.film;
}
buildUserRatings(el, movie) {
buildMovie(el, movie, bodyClasses) {
this.film = {

@@ -27,11 +28,18 @@ id: movie_helper_1.getId(el),

origins: movie_helper_1.getOrigins(el),
colorRating: 'unknown',
colorRating: movie_helper_1.getColorRating(bodyClasses),
rating: movie_helper_1.getRating(el),
otherTitles: movie_helper_1.getOtherTitles(el),
poster: movie_helper_1.getPoster(el),
directors: movie_helper_1.getDirectors(el),
actors: movie_helper_1.getGroup(el, 'Hrají'),
basedOn: movie_helper_1.getGroup(el, 'Předloha'),
writers: movie_helper_1.getGroup(el, 'Scénář'),
music: movie_helper_1.getGroup(el, 'Hudba'),
producers: movie_helper_1.getGroup(el, 'Producenti')
creators: {
directors: movie_helper_1.getDirectors(el),
writers: movie_helper_1.getGroup(el, 'Scénář'),
cinematography: movie_helper_1.getGroup(el, 'Kamera'),
music: movie_helper_1.getGroup(el, 'Hudba'),
actors: movie_helper_1.getGroup(el, 'Hrají'),
basedOn: movie_helper_1.getGroup(el, 'Předloha'),
producers: movie_helper_1.getGroup(el, 'Producenti'),
filmEditing: movie_helper_1.getGroup(el, 'Střih'),
costumeDesign: movie_helper_1.getGroup(el, 'Kostýmy'),
productionDesign: movie_helper_1.getGroup(el, 'Scénografie')
}
};

@@ -38,0 +46,0 @@ }

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