fix: remove all linter errors
This commit is contained in:
@@ -8,7 +8,7 @@ import { DATA_DIR } from "@lib/env.ts";
|
||||
import { db } from "@lib/db/sqlite.ts";
|
||||
import { imageTable } from "@lib/db/schema.ts";
|
||||
import { eq } from "drizzle-orm";
|
||||
import sharp from "npm:sharp@next";
|
||||
import sharp from "sharp";
|
||||
|
||||
const log = createLogger("cache/image");
|
||||
|
||||
@@ -219,7 +219,11 @@ async function createThumbhash(
|
||||
.raw()
|
||||
.toBuffer();
|
||||
|
||||
const [hash, average] = generateThumbhash(resizedImage, 100, 100);
|
||||
const [hash, average] = generateThumbhash(
|
||||
new Uint8Array(resizedImage),
|
||||
100,
|
||||
100,
|
||||
);
|
||||
|
||||
return {
|
||||
hash: btoa(String.fromCharCode(...hash)),
|
||||
|
||||
@@ -8,7 +8,7 @@ import { articleMetadataSchema } from "./marka/schema.ts";
|
||||
|
||||
const openAI = OPENAI_API_KEY && new OpenAI({ apiKey: OPENAI_API_KEY });
|
||||
|
||||
interface MovieRecommendation {
|
||||
export interface MovieRecommendation {
|
||||
year: number;
|
||||
title: string;
|
||||
}
|
||||
@@ -181,14 +181,14 @@ respond with a plain unordered list each item starting with the year the movie w
|
||||
|
||||
if (!res) return;
|
||||
|
||||
const recommendations = res.split("\n").map((entry) => {
|
||||
const recommendations = res.split("\n").map((entry: string) => {
|
||||
const [year, ...title] = entry.split("-");
|
||||
|
||||
return {
|
||||
year: parseInt(year.trim()),
|
||||
title: title.join(" ").replaceAll('"', "").trim(),
|
||||
};
|
||||
}).filter((y) => !Number.isNaN(y.year));
|
||||
}).filter((y: { year: number }) => !Number.isNaN(y.year));
|
||||
|
||||
cache.set(cacheId, recommendations);
|
||||
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
/**
|
||||
* Interface zur Beschreibung eines eingereihten Promises in der `PromiseQueue`.
|
||||
*/
|
||||
interface QueuedPromise<T = any> {
|
||||
interface QueuedPromise<T = unknown> {
|
||||
promise: () => Promise<T>;
|
||||
resolve: (value: T) => void;
|
||||
reject: (reason?: any) => void;
|
||||
resolve: (value: T | PromiseLike<T>) => void;
|
||||
reject: (reason?: unknown) => void;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -18,7 +18,7 @@ export class PromiseQueue {
|
||||
/**
|
||||
* Eingereihte Promises.
|
||||
*/
|
||||
private queue: QueuedPromise[] = [];
|
||||
private queue: QueuedPromise<unknown>[] = [];
|
||||
|
||||
/**
|
||||
* Indikator, dass aktuell ein Promise abgearbeitet wird.
|
||||
@@ -36,7 +36,7 @@ export class PromiseQueue {
|
||||
return new Promise((resolve, reject) => {
|
||||
this.queue.push({
|
||||
promise,
|
||||
resolve,
|
||||
resolve: resolve as (value: unknown) => void,
|
||||
reject,
|
||||
});
|
||||
this.dequeue();
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
import * as openai from "@lib/openai.ts";
|
||||
import { type MovieRecommendation } from "@lib/openai.ts";
|
||||
import * as tmdb from "@lib/tmdb.ts";
|
||||
import { parseRating } from "@lib/helpers.ts";
|
||||
import { createCache } from "@lib/cache.ts";
|
||||
@@ -83,10 +84,12 @@ export async function getSimilarMovies(id: string) {
|
||||
);
|
||||
if (!recommendations) return;
|
||||
|
||||
const movies = await Promise.all(recommendations.map(async (rec) => {
|
||||
const m = await tmdb.searchMovie(rec.title, rec.year);
|
||||
return m?.results?.[0];
|
||||
}));
|
||||
const movies = await Promise.all(
|
||||
recommendations.map(async (rec: MovieRecommendation) => {
|
||||
const m = await tmdb.searchMovie(rec.title, rec.year);
|
||||
return m?.results?.[0];
|
||||
}),
|
||||
);
|
||||
|
||||
return movies.filter(Boolean);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,10 @@
|
||||
import * as thumbhash from "thumbhash";
|
||||
|
||||
export function generateThumbhash(buffer: Uint8Array, w: number, h: number) {
|
||||
export function generateThumbhash(
|
||||
buffer: ArrayLike<number>,
|
||||
w: number,
|
||||
h: number,
|
||||
) {
|
||||
const hash = thumbhash.rgbaToThumbHash(w, h, buffer);
|
||||
return [hash, thumbhash.thumbHashToAverageRGBA(hash)] as const;
|
||||
}
|
||||
|
||||
@@ -47,7 +47,7 @@ export function absolutizeDomUrls(dom: JSDOM, domain: string): void {
|
||||
|
||||
document
|
||||
.querySelectorAll("img[srcset], source[srcset]")
|
||||
.forEach((el: HTMLImageElement) => {
|
||||
.forEach((el) => {
|
||||
const v = el.getAttribute("srcset");
|
||||
if (!v) return;
|
||||
const abs = absolutizeSrcset(v, base);
|
||||
@@ -55,7 +55,7 @@ export function absolutizeDomUrls(dom: JSDOM, domain: string): void {
|
||||
});
|
||||
|
||||
document.querySelectorAll("[style]").forEach(
|
||||
(el: HTMLElement) => {
|
||||
(el) => {
|
||||
const v = el.getAttribute("style");
|
||||
if (!v) return;
|
||||
const abs = absolutizeCssUrls(v, base);
|
||||
@@ -73,7 +73,7 @@ export function absolutizeDomUrls(dom: JSDOM, domain: string): void {
|
||||
|
||||
document
|
||||
.querySelectorAll('meta[http-equiv="refresh" i][content]')
|
||||
.forEach((meta: HTMLMetaElement) => {
|
||||
.forEach((meta) => {
|
||||
const content = meta.getAttribute("content") || "";
|
||||
const abs = absolutizeMetaRefresh(content, base);
|
||||
if (abs !== content) meta.setAttribute("content", abs);
|
||||
@@ -168,10 +168,20 @@ function absolutizeMetaRefresh(content: string, base: string): string {
|
||||
|
||||
const turndownService = new TurndownService();
|
||||
|
||||
export interface WebScrapeResult {
|
||||
title?: string;
|
||||
image?: string;
|
||||
published?: string;
|
||||
content: string;
|
||||
schemaOrgData?: { author?: { name?: string } };
|
||||
markdown: string;
|
||||
dom: JSDOM["window"]["document"];
|
||||
}
|
||||
|
||||
export async function webScrape(
|
||||
url: string,
|
||||
streamResponse: ReturnType<typeof createStreamResponse>,
|
||||
): JSDOM {
|
||||
) {
|
||||
const u = new URL(url);
|
||||
const html = await fetchHtmlWithPlaywright(url, streamResponse);
|
||||
const dom = new JSDOM(html);
|
||||
|
||||
@@ -56,12 +56,10 @@ export interface ContentDetails {
|
||||
definition: string;
|
||||
caption: string;
|
||||
licensedContent: boolean;
|
||||
contentRating: ContentRating;
|
||||
contentRating: Record<string, unknown>;
|
||||
projection: string;
|
||||
}
|
||||
|
||||
export interface ContentRating {}
|
||||
|
||||
export interface Statistics {
|
||||
viewCount: string;
|
||||
likeCount: string;
|
||||
|
||||
Reference in New Issue
Block a user