fix(extractor): handle SaveFiles locked file
This commit is contained in:
parent
c3fb400116
commit
285996cbf6
4 changed files with 1504 additions and 0 deletions
|
|
@ -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();
|
||||
});
|
||||
|
|
|
|||
|
|
@ -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[];
|
||||
|
||||
|
|
|
|||
1493
src/extractor/__fixtures__/SaveFiles/https:savefiles.comomqq55i59nvv
generated
Normal file
1493
src/extractor/__fixtures__/SaveFiles/https:savefiles.comomqq55i59nvv
generated
Normal file
File diff suppressed because one or more lines are too long
|
|
@ -19,6 +19,8 @@ exports[`SafeFiles savefiles 1`] = `
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`SafeFiles savefiles locked file 1`] = `[]`;
|
||||
|
||||
exports[`SafeFiles streamhls /e/ 1`] = `
|
||||
[
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue