Skip to content
Merged
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
33 changes: 0 additions & 33 deletions .eslintrc.json

This file was deleted.

19 changes: 19 additions & 0 deletions .oxlintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"$schema": "./node_modules/oxlint/configuration_schema.json",
"categories": {
"correctness": "error"
},
"rules": {
"no-unused-vars": [
"error",
{
"vars": "all",
"args": "after-used",
"ignoreRestSiblings": false,
"argsIgnorePattern": "^_",
"varsIgnorePattern": "^_"
}
]
},
"ignorePatterns": ["dist", "coverage", "docs", "examples"]
}
2 changes: 1 addition & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package.json
package-lock.json
yarn.lock
prettier.config.js
.eslintrc.js
.yarnrc.yml
dist
.vscode/*
tests/mocks/*.html
6 changes: 6 additions & 0 deletions .vscode/extensions.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"recommendations": [
"esbenp.prettier-vscode",
"typescriptteam.native-preview"
]
}
55 changes: 0 additions & 55 deletions eslint.config.mjs

This file was deleted.

47 changes: 31 additions & 16 deletions examples/server/cjs/server.js
Original file line number Diff line number Diff line change
@@ -1,20 +1,35 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var fs = require("fs");
var node_csfd_api_1 = require("node-csfd-api");
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var fs = require('fs');
var node_csfd_api_1 = require('node-csfd-api');
var TYPE = 'TypeScript CJS';
try {
var result_1;
node_csfd_api_1.csfd
.movie(2)
.then(function (res) {
result_1 = res;
var html = "\n <!DOCTYPE html>\n <html lang=\"en\">\n <head>\n <meta charset=\"UTF-8\">\n <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">\n <title>".concat(res.title, "</title>\n <style>\n body { font-family: sans-serif; background: #f9f9f9; padding: 40px; }\n h1 { color: #333; }\n </style>\n </head>\n <body>\n <h1>").concat(res.title, "</h1>\n <p>").concat(res.descriptions[0], "</p>\n <h3>").concat(TYPE, "</h3>\n <p><a href=\"").concat(res.url, "\" target=\"_blank\">Open</a></p>\n </body>\n </html>\n ");
fs.writeFileSync('index.html', html);
console.log("".concat(TYPE, ": \u2705 index.html has been created with title: ").concat(res.title));
var result_1;
node_csfd_api_1.csfd
.movie(2)
.then(function (res) {
result_1 = res;
var html =
'\n <!DOCTYPE html>\n <html lang="en">\n <head>\n <meta charset="UTF-8">\n <meta name="viewport" content="width=device-width, initial-scale=1.0">\n <title>'
.concat(
res.title,
'</title>\n <style>\n body { font-family: sans-serif; background: #f9f9f9; padding: 40px; }\n h1 { color: #333; }\n </style>\n </head>\n <body>\n <h1>'
)
.concat(res.title, '</h1>\n <p>')
.concat(res.descriptions[0], '</p>\n <h3>')
.concat(TYPE, '</h3>\n <p><a href="')
.concat(
res.url,
'" target="_blank">Open</a></p>\n </body>\n </html>\n '
);
fs.writeFileSync('index.html', html);
console.log(
''.concat(TYPE, ': \u2705 index.html has been created with title: ').concat(res.title)
);
})
.catch(function (err) { return console.error(err); });
}
catch (error) {
console.error("".concat(TYPE, ": \u274C Error:"), error);
.catch(function (err) {
return console.error(err);
});
} catch (error) {
console.error(''.concat(TYPE, ': \u274C Error:'), error);
}
13 changes: 6 additions & 7 deletions examples/server/esm/server.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ import fs from 'fs';
import { csfd } from 'node-csfd-api';
const TYPE = 'TypeScript ESM';
try {
const res = await csfd.movie(2);
const html = `
const res = await csfd.movie(2);
const html = `
<!DOCTYPE html>
<html lang="en">
<head>
Expand All @@ -23,9 +23,8 @@ try {
</body>
</html>
`;
fs.writeFileSync('index.html', html);
console.log(`${TYPE}: ✅ index.html has been created with title: ${res.title}`);
}
catch (error) {
console.error(`${TYPE}: ❌ Error:`, error);
fs.writeFileSync('index.html', html);
console.log(`${TYPE}: ✅ index.html has been created with title: ${res.title}`);
} catch (error) {
console.error(`${TYPE}: ❌ Error:`, error);
}
38 changes: 18 additions & 20 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"example:esm:js": "cd examples/server/esm && yarn build",
"letterboxd": "tsx examples/letterboxd/letterboxd-export.ts",
"examples": "yarn example:cjs:ts && yarn example:cjs:js && yarn example:esm:ts && yarn example:esm:js",
"lint": "eslint ./src/**/**/* --fix",
"lint": "oxlint --fix",
"docs": "typedoc",
"test": "vitest --watch=false",
"mock": "tsx tests/update-mocks.ts",
Expand All @@ -30,43 +30,38 @@
"release:patch": "git checkout master && npm version patch -m \"chore(update): patch release %s 🐛\"",
"release:minor": "git checkout master && npm version minor -m \"chore(update): release %s 🚀\"",
"release:major": "git checkout master && npm version major -m \"chore(update): major release %s 💥\"",
"prepare": "husky"
"prepare": "husky",
"lint:check": "oxlint",
"format": "prettier --write .",
"format:check": "prettier --check ."
},
"publishConfig": {
"access": "public",
"registry": "https://registry.npmjs.org"
},
"dependencies": {
"@modelcontextprotocol/sdk": "^1.29.0",
"@modelcontextprotocol/sdk": "^1.30.0",
"dotenv": "^17.4.2",
"express": "^5.2.1",
"node-html-parser": "^9.0.0",
"node-html-parser": "^9.0.1",
"zod": "^4.4.3"
},
"devDependencies": {
"@babel/preset-typescript": "^8.0.1",
"@eslint/eslintrc": "^3.3.5",
"@eslint/js": "^10.0.1",
"@types/express": "^5.0.6",
"@types/node": "^26.1.0",
"@typescript-eslint/eslint-plugin": "^8.63.0",
"@typescript-eslint/parser": "^8.63.0",
"@types/node": "^26.1.2",
"@vitest/coverage-istanbul": "^4.1.10",
"@vitest/ui": "^4.1.10",
"eslint": "^10.6.0",
"eslint-config-google": "^0.14.0",
"eslint-config-prettier": "^10.1.8",
"eslint-plugin-prettier": "^5.5.6",
"globals": "^17.7.0",
"husky": "^9.1.7",
"lint-staged": "^17.0.8",
"prettier": "^3.9.4",
"lint-staged": "^17.3.0",
"oxlint": "^1.77.0",
"prettier": "^3.9.6",
"rimraf": "^6.1.3",
"rolldown-plugin-dist-package": "^1.1.0",
"tsdown": "^0.22.3",
"tsx": "^4.23.0",
"tsdown": "^0.22.14",
"tsx": "^4.23.5",
"typedoc": "^0.28.20",
"typescript": "^6.0.3",
"typescript": "^7.0.2",
"vitest": "^4.1.10"
},
"repository": {
Expand Down Expand Up @@ -102,7 +97,10 @@
},
"license": "MIT",
"lint-staged": {
"*.ts": "eslint --cache --fix"
"*.ts": [
"oxlint --fix",
"prettier --write"
]
},
"type": "module",
"main": "./dist/index.cjs",
Expand Down
12 changes: 11 additions & 1 deletion src/bin/export-reviews.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,17 @@ export async function runReviewsExport(userId: number, options: ExportReviewsOpt
content = JSON.stringify(reviews, null, 2);
fileName = `${userId}-reviews.json`;
} else {
const headers = ['id', 'title', 'year', 'type', 'colorRating', 'userRating', 'date', 'url', 'text'];
const headers = [
'id',
'title',
'year',
'type',
'colorRating',
'userRating',
'date',
'url',
'text'
];
content = [
headers.join(','),
...reviews.map((r) =>
Expand Down
35 changes: 23 additions & 12 deletions src/bin/lookup-movie.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,22 @@ export async function runMovieLookup(movieId: number, json: boolean): Promise<vo

function printMovie(movie: CSFDMovie) {
const ratingColor =
movie.colorRating === 'good' ? c.green :
movie.colorRating === 'average' ? c.yellow :
movie.colorRating === 'bad' ? c.red : c.dim;
movie.colorRating === 'good'
? c.green
: movie.colorRating === 'average'
? c.yellow
: movie.colorRating === 'bad'
? c.red
: c.dim;

const row = (label: string, value: string) =>
value ? ` ${c.dim(label.padEnd(11))} ${value}` : '';

const names = (arr: { name: string }[], max = 5) =>
arr.slice(0, max).map((x) => x.name).join(', ');
arr
.slice(0, max)
.map((x) => x.name)
.join(', ');

const description = movie.descriptions?.[0]
? movie.descriptions[0].length > 160
Expand All @@ -35,18 +42,22 @@ function printMovie(movie: CSFDMovie) {
'',
c.bold(movie.title) + c.dim(` (${movie.year ?? '?'})`) + ' · ' + c.dim(movie.type ?? ''),
c.dim('─'.repeat(52)),
row('Rating', movie.rating != null
? ratingColor(c.bold(movie.rating + '%')) + c.dim(` (${movie.ratingCount?.toLocaleString()} ratings)`)
: c.dim('no rating')),
row('Genres', movie.genres?.join(', ') ?? ''),
row('Origins', movie.origins?.join(', ') ?? ''),
row('Duration', movie.duration ? movie.duration + ' min' : ''),
row(
'Rating',
movie.rating != null
? ratingColor(c.bold(movie.rating + '%')) +
c.dim(` (${movie.ratingCount?.toLocaleString()} ratings)`)
: c.dim('no rating')
),
row('Genres', movie.genres?.join(', ') ?? ''),
row('Origins', movie.origins?.join(', ') ?? ''),
row('Duration', movie.duration ? movie.duration + ' min' : ''),
row('Directors', names(movie.creators?.directors ?? [])),
row('Cast', names(movie.creators?.actors ?? [])),
row('Cast', names(movie.creators?.actors ?? [])),
description ? '\n ' + c.dim(description) : '',
vod ? '\n' + row('VOD', vod) : '',
row('URL', c.dim(movie.url ?? '')),
'',
''
].filter(Boolean);

console.log(lines.join('\n'));
Expand Down
Loading