refactor(extractor): add return type to all extract methods

This commit is contained in:
WebStreamr 2025-06-10 15:15:52 +00:00
parent 2d615ce582
commit 4da121d094
No known key found for this signature in database
6 changed files with 12 additions and 12 deletions

View file

@ -2,7 +2,7 @@ import randomstring from 'randomstring';
import * as cheerio from 'cheerio';
import { Extractor } from './types';
import { Fetcher } from '../utils';
import { Context, Meta } from '../types';
import { Context, Meta, UrlResult } from '../types';
import { NotFoundError } from '../error';
export class DoodStream implements Extractor {
@ -26,7 +26,7 @@ export class DoodStream implements Extractor {
return new URL(`http://dood.to/e/${videoId}`);
};
readonly extract = async (ctx: Context, url: URL, meta: Meta) => {
readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> => {
const html = await this.fetcher.text(ctx, new URL(url));
const passMd5Match = html.match(/\/pass_md5\/[\w-]+\/([\w-]+)/);

View file

@ -2,7 +2,7 @@ import bytes from 'bytes';
import * as cheerio from 'cheerio';
import { Extractor } from './types';
import { extractUrlFromPacked, Fetcher } from '../utils';
import { Context, Meta } from '../types';
import { Context, Meta, UrlResult } from '../types';
import { NotFoundError } from '../error';
export class Dropload implements Extractor {
@ -22,7 +22,7 @@ export class Dropload implements Extractor {
readonly normalize = (url: URL): URL => new URL(url.href.replace('/e/', '/').replace('/embed-', '/'));
readonly extract = async (ctx: Context, url: URL, meta: Meta) => {
readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> => {
const html = await this.fetcher.text(ctx, url);
if (html.includes('File Not Found')) {

View file

@ -1,6 +1,6 @@
import { Extractor } from './types';
import { Fetcher } from '../utils';
import { Context, Meta } from '../types';
import { Context, Meta, UrlResult } from '../types';
export class ExternalUrl implements Extractor {
readonly id = 'external';
@ -19,7 +19,7 @@ export class ExternalUrl implements Extractor {
readonly normalize = (url: URL): URL => url;
readonly extract = async (ctx: Context, url: URL, meta: Meta) => {
readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> => {
// We only want to make sure that the URL is accessible
await this.fetcher.head(ctx, url, { noFlareSolverr: true });

View file

@ -1,7 +1,7 @@
import * as cheerio from 'cheerio';
import { Extractor } from './types';
import { Fetcher } from '../utils';
import { Context, Meta } from '../types';
import { Context, Meta, UrlResult } from '../types';
export class Fsst implements Extractor {
readonly id = 'fsst';
@ -20,7 +20,7 @@ export class Fsst implements Extractor {
readonly normalize = (url: URL): URL => url;
readonly extract = async (ctx: Context, url: URL, meta: Meta) => {
readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> => {
const html = await this.fetcher.text(ctx, url);
const $ = cheerio.load(html);

View file

@ -1,6 +1,6 @@
import { Extractor } from './types';
import { Fetcher } from '../utils';
import { Context, Meta } from '../types';
import { Context, Meta, UrlResult } from '../types';
interface SoaperInfoResponsePartial {
val: string;
@ -24,7 +24,7 @@ export class Soaper implements Extractor {
readonly normalize = (url: URL): URL => url;
readonly extract = async (ctx: Context, url: URL, meta: Meta) => {
readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> => {
const movieOrEpisodeId = (url.pathname.match(/\/\w+_(\w+)/) as string[])[1] as string;
const form = new URLSearchParams();

View file

@ -2,7 +2,7 @@ import bytes from 'bytes';
import * as cheerio from 'cheerio';
import { Extractor } from './types';
import { extractUrlFromPacked, Fetcher } from '../utils';
import { Context, Meta } from '../types';
import { Context, Meta, UrlResult } from '../types';
export class SuperVideo implements Extractor {
readonly id = 'supervideo';
@ -21,7 +21,7 @@ export class SuperVideo implements Extractor {
readonly normalize = (url: URL): URL => new URL(url.href.replace('/e/', '/').replace('/embed-', '/'));
readonly extract = async (ctx: Context, url: URL, meta: Meta) => {
readonly extract = async (ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> => {
const html = await this.fetcher.text(ctx, url);
const heightAndSizeMatch = html.match(/\d{3,}x(\d{3,}), ([\d.]+ ?[GM]B)/) as string[];