Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"typescriptteam.native-preview"
"typescriptteam.native-preview",
"oxc.oxc-vscode"
]
}
10 changes: 8 additions & 2 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,19 @@
},
"editor.codeActionsOnSave": {
"source.organizeImports": "explicit",
"source.fixAll.eslint": "explicit"
// oxlint (requires the `oxc.oxc-vscode` extension)
"source.fixAll.oxc": "explicit"
},
"[html]": {
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": false
},
"editor.defaultFormatter": "esbenp.prettier-vscode",
"editor.formatOnSave": true,
"typescript.tsdk": "node_modules/typescript/lib"
// UI Setting:
// TypeScript 7 > Experimental: Use Tsgo
// (still experimental in VS Code 1.131; disables the built-in TS/JS
// language features so the native TypeScript 7 server takes over.
// The tsdk is resolved from `node_modules/typescript` automatically.)
"js/ts.experimental.useTsgo": true
}
2 changes: 0 additions & 2 deletions .yarnrc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@ approvedGitRepositories:
enableScripts: true

nodeLinker: node-modules

npmMinimalAgeGate: 0
2 changes: 1 addition & 1 deletion src/bin/export-ratings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { writeFile } from 'node:fs/promises';
import { csfd } from '..';
import { CSFDUserRatingConfig } from '../dto/user-ratings';
import type { CSFDUserRatingConfig } from '../dto/user-ratings';
import { escapeCsvField, renderProgress } from './utils';

export interface ExportRatingsOptions {
Expand Down
2 changes: 1 addition & 1 deletion src/bin/export-reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

import { writeFile } from 'node:fs/promises';
import { csfd } from '..';
import { CSFDUserReviewsConfig } from '../dto/user-reviews';
import type { CSFDUserReviewsConfig } from '../dto/user-reviews';
import { escapeCsvField, renderProgress } from './utils';

export interface ExportReviewsOptions {
Expand Down
7 changes: 4 additions & 3 deletions src/bin/server.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
import 'dotenv/config';
import express, { NextFunction, Request, Response } from 'express';
import type { NextFunction, Request, Response } from 'express';
import express from 'express';
import { csfd } from '..';
import packageJson from '../../package.json' with { type: 'json' };
import { CSFDFilmTypes } from '../dto/global';
import { CSFDLanguage } from '../types';
import type { CSFDFilmTypes } from '../dto/global';
import type { CSFDLanguage } from '../types';

const LOG_COLORS = {
info: '\x1b[36m', // cyan
Expand Down
2 changes: 1 addition & 1 deletion src/dto/cinema.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSFDMovieListItem } from './movie';
import type { CSFDMovieListItem } from './movie';

export interface CSFDCinema {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion src/dto/creator.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSFDScreening } from './global';
import type { CSFDScreening } from './global';

export interface CSFDCreator {
id: number;
Expand Down
2 changes: 1 addition & 1 deletion src/dto/movie.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSFDScreening } from './global';
import type { CSFDScreening } from './global';

export interface CSFDMovie extends CSFDScreening {
rating: number | null;
Expand Down
4 changes: 2 additions & 2 deletions src/dto/search.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSFDScreening } from './global';
import { CSFDMovieCreator } from './movie';
import type { CSFDScreening } from './global';
import type { CSFDMovieCreator } from './movie';

export interface CSFDSearch {
movies: CSFDSearchMovie[];
Expand Down
2 changes: 1 addition & 1 deletion src/dto/user-ratings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';
import type { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';

export interface CSFDUserRatings extends CSFDScreening {
userRating: CSFDStars;
Expand Down
2 changes: 1 addition & 1 deletion src/dto/user-reviews.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';
import type { CSFDFilmTypes, CSFDScreening, CSFDStars } from './global';

export interface CSFDUserReviews extends CSFDScreening {
userRating: CSFDStars;
Expand Down
3 changes: 3 additions & 0 deletions src/fetchers/fetch.polyfill.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
declare const window: { fetch?: typeof fetch };

// Check if `fetch` is available in global scope (nodejs 18+) or in window (browser).
export const fetchSafe =
(typeof fetch === 'function' && fetch) || // ServiceWorker fetch (Cloud Functions + Chrome extension)
(typeof global === 'object' && global.fetch) || // Node.js 18+ fetch
(typeof window !== 'undefined' && window.fetch); // Browser fetch

6 changes: 3 additions & 3 deletions src/helpers/cinema.helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTMLElement } from 'node-html-parser';
import { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from '../dto/cinema';
import { CSFDColorRating } from '../dto/global';
import { CSFDColors } from '../dto/user-ratings';
import type { CSFDCinemaGroupedFilmsByDate, CSFDCinemaMeta, CSFDCinemaMovie } from '../dto/cinema';
import type { CSFDColorRating } from '../dto/global';
import type { CSFDColors } from '../dto/user-ratings';
import { parseColor, parseIdFromUrl } from './global.helper';

export const getCinemaColorRating = (el: HTMLElement | null): CSFDColorRating => {
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/creator.helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTMLElement } from 'node-html-parser';
import { CSFDCreatorScreening } from '../dto/creator';
import { CSFDColorRating } from '../dto/global';
import { CSFDColors } from '../dto/user-ratings';
import type { CSFDCreatorScreening } from '../dto/creator';
import type { CSFDColorRating } from '../dto/global';
import type { CSFDColors } from '../dto/user-ratings';
import { addProtocol, parseColor, parseDate, parseIdFromUrl } from './global.helper';

const getCreatorColorRating = (el: HTMLElement | null): CSFDColorRating => {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/global.helper.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSFDColorRating, CSFDFilmTypes } from '../dto/global';
import { CSFDColors } from '../dto/user-ratings';
import type { CSFDColorRating, CSFDFilmTypes } from '../dto/global';
import type { CSFDColors } from '../dto/user-ratings';

const LANG_PREFIX_REGEX = /^[a-z]{2,3}$/;
const ISO8601_DURATION_REGEX =
Expand Down
6 changes: 3 additions & 3 deletions src/helpers/search.helper.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTMLElement } from 'node-html-parser';
import { CSFDColorRating, CSFDFilmTypes } from '../dto/global';
import { CSFDMovieCreator } from '../dto/movie';
import { CSFDColors } from '../dto/user-ratings';
import type { CSFDColorRating, CSFDFilmTypes } from '../dto/global';
import type { CSFDMovieCreator } from '../dto/movie';
import type { CSFDColors } from '../dto/user-ratings';
import { addProtocol, parseColor, parseFilmType, parseIdFromUrl } from './global.helper';

type Creator = 'Režie:' | 'Hrají:';
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/user-ratings.helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HTMLElement } from 'node-html-parser';
import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import { CSFDColors } from '../dto/user-ratings';
import type { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import type { CSFDColors } from '../dto/user-ratings';
import { parseColor, parseDate, parseFilmType, parseIdFromUrl } from './global.helper';

export const getUserRatingId = (el: HTMLElement): number => {
Expand Down
4 changes: 2 additions & 2 deletions src/helpers/user-reviews.helper.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HTMLElement } from 'node-html-parser';
import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import { CSFDColors } from '../dto/user-ratings';
import type { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import type { CSFDColors } from '../dto/user-ratings';
import { parseColor, parseDate, parseFilmType, parseIdFromUrl } from './global.helper';

export const getUserReviewId = (el: HTMLElement): number => {
Expand Down
14 changes: 7 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import { CSFDCinema, CSFDCinemaPeriod } from './dto/cinema';
import { CSFDCreator } from './dto/creator';
import { CSFDMovie } from './dto/movie';
import { CSFDSearch } from './dto/search';
import { CSFDUserRatingConfig, CSFDUserRatings } from './dto/user-ratings';
import { CSFDUserReviews, CSFDUserReviewsConfig } from './dto/user-reviews';
import type { CSFDCinema, CSFDCinemaPeriod } from './dto/cinema';
import type { CSFDCreator } from './dto/creator';
import type { CSFDMovie } from './dto/movie';
import type { CSFDSearch } from './dto/search';
import type { CSFDUserRatingConfig, CSFDUserRatings } from './dto/user-ratings';
import type { CSFDUserReviews, CSFDUserReviewsConfig } from './dto/user-reviews';
import { CinemaScraper } from './services/cinema.service';
import { CreatorScraper } from './services/creator.service';
import { MovieScraper } from './services/movie.service';
import { SearchScraper } from './services/search.service';
import { UserRatingsScraper } from './services/user-ratings.service';
import { UserReviewsScraper } from './services/user-reviews.service';
import { CSFDOptions } from './types';
import type { CSFDOptions } from './types';

export class Csfd {
private defaultOptions?: CSFDOptions;
Expand Down
4 changes: 2 additions & 2 deletions src/services/cinema.service.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { HTMLElement, parse } from 'node-html-parser';
import { CSFDCinema, CSFDCinemaPeriod } from '../dto/cinema';
import type { CSFDCinema, CSFDCinemaPeriod } from '../dto/cinema';
import { fetchPage } from '../fetchers';
import { CSFDOptions } from '../types';
import type { CSFDOptions } from '../types';
import { cinemasUrl } from '../vars';
import {
getCinemaCoords,
Expand Down
6 changes: 3 additions & 3 deletions src/services/creator.service.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
import { HTMLElement, parse } from 'node-html-parser';
import { CSFDCreator } from '../dto/creator';
import type { CSFDCreator } from '../dto/creator';
import { fetchPage } from '../fetchers';
import { extractId } from '../helpers/global.helper';
import {
getCreatorBio,
getCreatorBirthdayInfo,
getCreatorFilms,
getCreatorName,
getCreatorPhoto
} from '../helpers/creator.helper';
import { CSFDOptions } from '../types';
import { extractId } from '../helpers/global.helper';
import type { CSFDOptions } from '../types';
import { creatorUrl } from '../vars';

export class CreatorScraper {
Expand Down
6 changes: 3 additions & 3 deletions src/services/movie.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HTMLElement, parse } from 'node-html-parser';
import { CSFDFilmTypes } from '../dto/global';
import { CSFDMovie, MovieJsonLd } from '../dto/movie';
import type { CSFDFilmTypes } from '../dto/global';
import type { CSFDMovie, MovieJsonLd } from '../dto/movie';
import { fetchPage } from '../fetchers';
import { extractId } from '../helpers/global.helper';
import {
Expand Down Expand Up @@ -29,7 +29,7 @@ import {
getSeasonsOrEpisodes,
getSeriesAndSeasonTitle
} from '../helpers/movie.helper';
import { CSFDOptions } from '../types';
import type { CSFDOptions } from '../types';
import { LIB_PREFIX, movieUrl } from '../vars';

export class MovieScraper {
Expand Down
4 changes: 2 additions & 2 deletions src/services/search.service.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { HTMLElement, parse } from 'node-html-parser';
import { CSFDSearch, CSFDSearchCreator, CSFDSearchMovie, CSFDSearchUser } from '../dto/search';
import type { CSFDSearch, CSFDSearchCreator, CSFDSearchMovie, CSFDSearchUser } from '../dto/search';
import { fetchPage } from '../fetchers';
import { parseIdFromUrl } from '../helpers/global.helper';
import { getCreatorImage, getCreatorName, getCreatorUrl } from '../helpers/search-creator.helper';
Expand All @@ -14,7 +14,7 @@ import {
getSearchYear,
parseSearchPeople
} from '../helpers/search.helper';
import { CSFDLanguage, CSFDOptions } from '../types';
import type { CSFDLanguage, CSFDOptions } from '../types';
import { getUrlByLanguage, searchUrl } from '../vars';

export class SearchScraper {
Expand Down
6 changes: 3 additions & 3 deletions src/services/user-ratings.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HTMLElement, parse } from 'node-html-parser';
import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import { CSFDUserRatingConfig, CSFDUserRatings } from '../dto/user-ratings';
import type { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import type { CSFDUserRatingConfig, CSFDUserRatings } from '../dto/user-ratings';
import { fetchPage } from '../fetchers';
import { sleep } from '../helpers/global.helper';
import {
Expand All @@ -13,7 +13,7 @@ import {
getUserRatingUrl,
getUserRatingYear
} from '../helpers/user-ratings.helper';
import { CSFDOptions } from '../types';
import type { CSFDOptions } from '../types';
import { LIB_PREFIX, userRatingsUrl } from '../vars';

export class UserRatingsScraper {
Expand Down
6 changes: 3 additions & 3 deletions src/services/user-reviews.service.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { HTMLElement, parse } from 'node-html-parser';
import { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import { CSFDUserReviews, CSFDUserReviewsConfig } from '../dto/user-reviews';
import type { CSFDColorRating, CSFDFilmTypes, CSFDStars } from '../dto/global';
import type { CSFDUserReviews, CSFDUserReviewsConfig } from '../dto/user-reviews';
import { fetchPage } from '../fetchers';
import { sleep } from '../helpers/global.helper';
import {
Expand All @@ -15,7 +15,7 @@ import {
getUserReviewUrl,
getUserReviewYear
} from '../helpers/user-reviews.helper';
import { CSFDOptions } from '../types';
import type { CSFDOptions } from '../types';
import { LIB_PREFIX, userReviewsUrl } from '../vars';

export class UserReviewsScraper {
Expand Down
4 changes: 2 additions & 2 deletions src/vars.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { CSFDCinemaPeriod } from './dto/cinema';
import { CSFDLanguage } from './types';
import type { CSFDCinemaPeriod } from './dto/cinema';
import type { CSFDLanguage } from './types';

export const LIB_PREFIX = '[node-csfd-api]';

Expand Down
26 changes: 12 additions & 14 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,25 +1,23 @@
{
"compilerOptions": {
"target": "ES2022",
"lib": ["ES2022", "DOM"],
"target": "ES2023",
"lib": ["ES2023"],
"types": ["node"],
"esModuleInterop": true,

"module": "Preserve",
"moduleResolution": "Bundler",
"resolveJsonModule": true,
"isolatedModules": true,

"strict": true,
"strictNullChecks": false, // will be more strict in future releases
"allowSyntheticDefaultImports": true,
"noImplicitReturns": true,

"forceConsistentCasingInFileNames": true,
"sourceMap": false,
"outDir": "./dist",
"strict": true,
"declaration": true,
"pretty": true,
"skipLibCheck": true,
"alwaysStrict": true,
"noImplicitAny": true,
"noImplicitReturns": true

"noEmit": true
},
"include": ["src"],
"exclude": ["dist/**/*", "*/tests/**/*"]
}
"exclude": ["dist", "**/tests/**"]
}