fix(extractor): handle SaveFiles locked file

This commit is contained in:
WebStreamr 2025-08-13 20:34:07 +00:00
parent c3fb400116
commit 285996cbf6
No known key found for this signature in database
4 changed files with 1504 additions and 0 deletions

View file

@ -15,6 +15,10 @@ describe('SafeFiles', () => {
expect(await extractorRegistry.handle(ctx, new URL('https://savefiles.com/ip0k0dj2g0i3'), CountryCode.en)).toMatchSnapshot();
});
test('savefiles locked file', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://savefiles.com/omqq55i59nvv'), CountryCode.en)).toMatchSnapshot();
});
test('streamhls /e/', async () => {
expect(await extractorRegistry.handle(ctx, new URL('https://streamhls.to/e/ip0k0dj2g0i3'), CountryCode.en)).toMatchSnapshot();
});

View file

@ -1,4 +1,5 @@
import * as cheerio from 'cheerio';
import { NotFoundError } from '../error';
import { Context, CountryCode, Format, UrlResult } from '../types';
import { Fetcher } from '../utils';
import { Extractor } from './Extractor';
@ -27,6 +28,10 @@ export class SaveFiles extends Extractor {
protected async extractInternal(ctx: Context, url: URL, countryCode: CountryCode): Promise<UrlResult[]> {
const html = await this.fetcher.text(ctx, url);
if (/File was locked by administrator/.test(html)) {
throw new NotFoundError();
}
const fileMatch = html.match(/file:"(.*?)"/) as string[];
const sizeMatch = html.match(/\[\d{3,}x(\d{3,})/) as string[];

File diff suppressed because one or more lines are too long

View file

@ -19,6 +19,8 @@ exports[`SafeFiles savefiles 1`] = `
]
`;
exports[`SafeFiles savefiles locked file 1`] = `[]`;
exports[`SafeFiles streamhls /e/ 1`] = `
[
{