chore(source): retry also blocking errors with different VidSrc TLD
This commit is contained in:
parent
fde6128757
commit
af4d0010fb
3 changed files with 31 additions and 2 deletions
|
|
@ -38,4 +38,20 @@ describe('VidSrc', () => {
|
|||
|
||||
expect(await vidSrc.extract(ctx, new URL('https://vidsrc.xyz/embed/movie/tt33043892/1/1'))).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('blocking issues are retried and fail if no tlds are left', async () => {
|
||||
const mockAgent = new MockAgent({ enableCallHistory: true });
|
||||
mockAgent.disableNetConnect();
|
||||
setGlobalDispatcher(mockAgent);
|
||||
|
||||
mockAgent.get('https://vidsrc.xyz')
|
||||
.intercept({ path: '/embed/movie/tt33043892/1/1' }).reply(403);
|
||||
mockAgent.get('https://vidsrc.net')
|
||||
.intercept({ path: '/embed/movie/tt33043892/1/1' }).reply(403);
|
||||
|
||||
const fetcher = new Fetcher(winston.createLogger({ transports: [new winston.transports.Console({ level: 'nope' })] }));
|
||||
const vidSrc = new VidSrc(fetcher, ['net', 'xyz']);
|
||||
|
||||
expect(await vidSrc.extract(ctx, new URL('https://vidsrc.xyz/embed/movie/tt33043892/1/1'))).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
import * as cheerio from 'cheerio';
|
||||
import slugify from 'slugify';
|
||||
import { NotFoundError, TooManyRequestsError } from '../error';
|
||||
import { BlockedError, NotFoundError, TooManyRequestsError } from '../error';
|
||||
import { Context, Format, Meta, NonEmptyArray, UrlResult } from '../types';
|
||||
import { Fetcher, guessHeightFromPlaylist } from '../utils';
|
||||
import { Extractor } from './Extractor';
|
||||
|
|
@ -41,7 +41,7 @@ export class VidSrc extends Extractor {
|
|||
try {
|
||||
html = await this.fetcher.text(ctx, newUrl);
|
||||
} catch (error) {
|
||||
if (error instanceof TooManyRequestsError && tlds.length) {
|
||||
if (tlds.length && (error instanceof TooManyRequestsError || error instanceof BlockedError)) {
|
||||
return this.extractUsingRandomTld(ctx, url, meta, tlds);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,19 @@ exports[`VidSrc Full Metal Jacket 1`] = `
|
|||
]
|
||||
`;
|
||||
|
||||
exports[`VidSrc blocking issues are retried and fail if no tlds are left 1`] = `
|
||||
[
|
||||
{
|
||||
"error": [Error],
|
||||
"format": "unknown",
|
||||
"isExternal": true,
|
||||
"label": "VidSrc",
|
||||
"sourceId": "vidsrc",
|
||||
"url": "https://vidsrc.xyz/embed/movie/tt33043892/1/1",
|
||||
},
|
||||
]
|
||||
`;
|
||||
|
||||
exports[`VidSrc not found 1`] = `[]`;
|
||||
|
||||
exports[`VidSrc rate limit issues are retried and fail if no tlds are left 1`] = `
|
||||
|
|
|
|||
Loading…
Reference in a new issue