fix(extractor): handle FileLions Not Found case
This commit is contained in:
parent
30a709d619
commit
d1493cbb57
4 changed files with 174 additions and 2 deletions
|
|
@ -17,4 +17,8 @@ describe('FileLions', () => {
|
|||
test('mivalyo v referer lock', async () => {
|
||||
expect(await extractorRegistry.handle(ctx, new URL('https://mivalyo.com/v/tah5znapz3e5'), { referer: 'https://kinoger.com' })).toMatchSnapshot();
|
||||
});
|
||||
|
||||
test('file not found', async () => {
|
||||
expect(await extractorRegistry.handle(ctx, new URL('https://filelions.to/v/ylcp2cu5qanb'))).toMatchSnapshot();
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,5 +1,6 @@
|
|||
import bytes from 'bytes';
|
||||
import * as cheerio from 'cheerio';
|
||||
import { NotFoundError } from '../error';
|
||||
import { Context, Format, Meta, UrlResult } from '../types';
|
||||
import {
|
||||
buildMediaFlowProxyExtractorStreamUrl,
|
||||
|
|
@ -67,13 +68,17 @@ export class FileLions extends Extractor {
|
|||
protected async extractInternal(ctx: Context, url: URL, meta: Meta): Promise<UrlResult[]> {
|
||||
const headers = { Referer: meta.referer ?? url.href };
|
||||
|
||||
const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'FileLions', url, headers);
|
||||
|
||||
const fileUrl = new URL(url.href.replace('/v/', '/f/'));
|
||||
const html = await this.fetcher.text(ctx, fileUrl, { headers });
|
||||
|
||||
if (/File Not Found/.test(html)) {
|
||||
throw new NotFoundError();
|
||||
}
|
||||
|
||||
const sizeMatch = html.match(/([\d.]+ ?[GM]B)/);
|
||||
|
||||
const playlistUrl = await buildMediaFlowProxyExtractorStreamUrl(ctx, this.fetcher, 'FileLions', url, headers);
|
||||
|
||||
const $ = cheerio.load(html);
|
||||
const title = $('title').text().trim().replace(/^Watch /, '').trim();
|
||||
|
||||
|
|
|
|||
161
src/extractor/__fixtures__/FileLions/https:filelions.tofylcp2cu5qanb
generated
Normal file
161
src/extractor/__fixtures__/FileLions/https:filelions.tofylcp2cu5qanb
generated
Normal file
|
|
@ -0,0 +1,161 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>
|
||||
|
||||
Watch
|
||||
|
||||
</title>
|
||||
<META NAME="description" CONTENT="">
|
||||
<META NAME="keywords" CONTENT="">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||
<meta name="theme-color" content="#FFF">
|
||||
|
||||
<link rel="apple-touch-icon" href="/static/images/favicon/apple-touch-icon.png" sizes="180x180">
|
||||
<link rel="icon" href="/static/images/favicon/favicon-32x32.png" sizes="32x32">
|
||||
<link rel="icon" href="/static/images/favicon/favicon-16x16.png" sizes="16x16">
|
||||
<link rel="manifest" href="/static/images/favicon/manifest.json">
|
||||
<link rel="icon" href="/static/images/favicon/favicon.ico">
|
||||
<link rel="preconnect" href="https://fonts.googleapis.com">
|
||||
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="crossorigin">
|
||||
<link href="https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700&display=swap" rel="stylesheet">
|
||||
<link href="/static/css/style.css?" rel="stylesheet">
|
||||
|
||||
<script src="/static/js/jquery-3.2.1.min.js?"></script>
|
||||
<script src="/static/js/bootstrap.bundle.min.js?"></script>
|
||||
<script src="/static/js/app.js?"></script>
|
||||
<script src="/static/js/xupload.js?"></script>
|
||||
|
||||
|
||||
<!-- Google tag (gtag.js) -->
|
||||
<script async src="https://www.googletagmanager.com/gtag/js?id=G-48ZJD1VPGZ"></script>
|
||||
<script>
|
||||
window.dataLayer = window.dataLayer || [];
|
||||
function gtag(){dataLayer.push(arguments);}
|
||||
gtag('js', new Date());
|
||||
|
||||
gtag('config', 'G-48ZJD1VPGZ');
|
||||
</script>
|
||||
<!-- Yandex.Metrika counter -->
|
||||
<script type="text/javascript" >
|
||||
(function(m,e,t,r,i,k,a){m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
|
||||
m[i].l=1*new Date();
|
||||
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
|
||||
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)})
|
||||
(window, document, "script", "https://mc.yandex.ru/metrika/tag.js", "ym");
|
||||
|
||||
ym(93381808, "init", {
|
||||
clickmap:true,
|
||||
trackLinks:true,
|
||||
accurateTrackBounce:true,
|
||||
webvisor:true
|
||||
});
|
||||
</script>
|
||||
<noscript><div><img src="https://mc.yandex.ru/watch/93381808" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
|
||||
<!-- /Yandex.Metrika counter -->
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<header class="header">
|
||||
<div class="container">
|
||||
<div class="row align-items-center flex-nowrap">
|
||||
<div class="col-auto flex-grow-1 flex-shrink-1">
|
||||
<div class="row align-items-center">
|
||||
|
||||
<div class="col-auto" style="margin: 0 auto;">
|
||||
<a href="/" class="logo">
|
||||
|
||||
<img src="/static/images/logo.svg" alt="">
|
||||
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
<main>
|
||||
<section class="section">
|
||||
<div class="container">
|
||||
<div class="block">
|
||||
<div class="text-center">
|
||||
<div class="mb-4">
|
||||
<svg xmlns="http://www.w3.org/2000/svg" width="64" height="64"><path fill-rule="evenodd" fill="#DC3545" d="M32 64C14.326 64 0 49.674 0 32S14.326 0 32 0c17.666.019 31.981 14.334 32 32 0 17.674-14.326 32-32 32Zm0-61C15.984 3 3 15.984 3 32s12.984 29 29 29c16.008-.019 28.981-12.992 29-29C61 15.984 48.016 3 32 3Zm14.065 43.125a1.504 1.504 0 0 1-2.125 0l-11.94-12L20.065 46.12A1.502 1.502 0 0 1 17.941 44L29.88 32 17.941 20a1.503 1.503 0 0 1 2.124-2.125l11.935 12 11.94-11.98a1.502 1.502 0 0 1 2.12 0A1.5 1.5 0 0 1 46.065 20L34.12 32l11.945 12a1.504 1.504 0 0 1 0 2.125Z"/></svg>
|
||||
</div>
|
||||
</div>
|
||||
<h3 class="text-center mb-3">
|
||||
File Not Found
|
||||
</h3>
|
||||
<div>
|
||||
<p class="text-center">The file you were looking for could not be found, sorry for any inconvenience.</p>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="text-muted">
|
||||
<p class="text-center"><b>Possible causes of this error could be:</b></p>
|
||||
<div class="row justify-content-center">
|
||||
<div class="col-auto">
|
||||
<ul>
|
||||
<li>
|
||||
The file expired
|
||||
<li>
|
||||
The file was deleted by its owner
|
||||
<li>
|
||||
The file was deleted by administration because it didn't comply with our Terms of Use
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</section>
|
||||
</main>
|
||||
<footer class="footer">
|
||||
<div class="container">
|
||||
<div class="row">
|
||||
<div class="col-lg-4 col-xs-12">
|
||||
<div class="mb-3 text-center">
|
||||
<a href="#" class="logo">
|
||||
|
||||
<img src="/static/images/logo.svg" alt="">
|
||||
|
||||
</a>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
|
||||
<div class="col-lg-8 col-xs-12" style="position: relative">
|
||||
<div class="mb-4 text-center">
|
||||
<p class="text-muted ">
|
||||
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</footer>
|
||||
<style>
|
||||
@media (min-width:481px) {
|
||||
.text-muted {}
|
||||
}
|
||||
|
||||
@media (min-width:961px) {
|
||||
.text-muted {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: 15px
|
||||
}
|
||||
}
|
||||
</style>
|
||||
</body>
|
||||
|
||||
</html>
|
||||
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
// Jest Snapshot v1, https://jestjs.io/docs/snapshot-testing
|
||||
|
||||
exports[`FileLions file not found 1`] = `[]`;
|
||||
|
||||
exports[`FileLions filelions f 1`] = `
|
||||
[
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue