From 666d7f7c62d45bc6c1bf28965191fe875a658694 Mon Sep 17 00:00:00 2001 From: mh4ckt3mh4ckt1c4s Date: Sat, 29 Jul 2023 00:07:20 +0200 Subject: [PATCH 1/3] fix : using new uqload.io domain --- src/core/scraper/uqload.js | 4 ++-- test/integration/scraper/uqload.js | 18 +++++++++--------- test/unit/core/scraper/uqload.js | 16 ++++++++-------- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/core/scraper/uqload.js b/src/core/scraper/uqload.js index dcd27e71..f5e9937c 100644 --- a/src/core/scraper/uqload.js +++ b/src/core/scraper/uqload.js @@ -29,14 +29,14 @@ const action = async function (_url, content) { for (const script of doc.querySelectorAll("script:not([src])")) { const result = DATA_REGEXP.exec(script.text); if (null !== result) { - return result.groups.source + "|Referer=https://uqload.co/"; + return result.groups.source + "|Referer=https://uqload.io/"; } } return undefined; }; export const extract = matchPattern( action, - "*://uqload.co/*.html", + "*://uqload.io/*.html", // Ajouter aussi l'ancien nom de domaine (qui redirige vers le nouveau). "*://uqload.com/*.html", ); diff --git a/test/integration/scraper/uqload.js b/test/integration/scraper/uqload.js index 26d8d73a..5c01b19e 100644 --- a/test/integration/scraper/uqload.js +++ b/test/integration/scraper/uqload.js @@ -13,7 +13,7 @@ describe("Scraper: Uqload", function () { it("should return undefined when it isn't a video", async function () { sinon.stub(kodi.addons, "getAddons").resolves([]); - const url = new URL("https://uqload.co/checkfiles.html"); + const url = new URL("https://uqload.io/checkfiles.html"); const options = { depth: false, incognito: false }; const file = await extract(url, options); @@ -23,7 +23,7 @@ describe("Scraper: Uqload", function () { it("should return undefined when video was deleted", async function () { sinon.stub(kodi.addons, "getAddons").resolves([]); - const url = new URL("https://uqload.co/k1phujbh3t7d.html"); + const url = new URL("https://uqload.io/k1phujbh3t7d.html"); const options = { depth: false, incognito: false }; const file = await extract(url, options); @@ -31,37 +31,37 @@ describe("Scraper: Uqload", function () { }); it("should return video URL", async function () { - const url = new URL("https://uqload.co/5x0cgygu2bgg.html"); + const url = new URL("https://uqload.io/5x0cgygu2bgg.html"); const options = { depth: false, incognito: false }; const file = await extract(url, options); assert.ok( undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.co/"), + file.endsWith("/v.mp4|Referer=https://uqload.io/"), `"${file}".endsWith(...)`, ); }); it("should return video URL when protocol is HTTP", async function () { - const url = new URL("http://uqload.co/5x0cgygu2bgg.html"); + const url = new URL("http://uqload.io/5x0cgygu2bgg.html"); const options = { depth: false, incognito: false }; const file = await extract(url, options); assert.ok( undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.co/"), + file.endsWith("/v.mp4|Referer=https://uqload.io/"), `"${file}".endsWith(...)`, ); }); it("should return video URL from embed", async function () { - const url = new URL("https://uqload.co/embed-5x0cgygu2bgg.html"); + const url = new URL("https://uqload.io/embed-5x0cgygu2bgg.html"); const options = { depth: false, incognito: false }; const file = await extract(url, options); assert.ok( undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.co/"), + file.endsWith("/v.mp4|Referer=https://uqload.io/"), `"${file}".endsWith(...)`, ); }); @@ -73,7 +73,7 @@ describe("Scraper: Uqload", function () { const file = await extract(url, options); assert.ok( undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.co/"), + file.endsWith("/v.mp4|Referer=https://uqload.io/"), `"${file}".endsWith(...)`, ); }); diff --git a/test/unit/core/scraper/uqload.js b/test/unit/core/scraper/uqload.js index 214be1c4..72f4a436 100644 --- a/test/unit/core/scraper/uqload.js +++ b/test/unit/core/scraper/uqload.js @@ -10,14 +10,14 @@ import * as scraper from "../../../../src/core/scraper/uqload.js"; describe("core/scraper/uqload.js", function () { describe("extract()", function () { it("shouldn't handle when it's a unsupported URL", async function () { - const url = new URL("https://uqload.co/faq"); + const url = new URL("https://uqload.io/faq"); const file = await scraper.extract(url); assert.equal(file, undefined); }); it("should return undefined when no script", async function () { - const url = new URL("https://uqload.co/foo.html"); + const url = new URL("https://uqload.io/foo.html"); const content = { html: () => Promise.resolve( @@ -33,13 +33,13 @@ describe("core/scraper/uqload.js", function () { }); it("should return undefined when no inline script", async function () { - const url = new URL("https://uqload.co/foo.html"); + const url = new URL("https://uqload.io/foo.html"); const content = { html: () => Promise.resolve( new DOMParser().parseFromString( ` - `, "text/html", @@ -52,7 +52,7 @@ describe("core/scraper/uqload.js", function () { }); it("should return undefined when no sources", async function () { - const url = new URL("https://uqload.co/foo.html"); + const url = new URL("https://uqload.io/foo.html"); const content = { html: () => Promise.resolve( @@ -72,7 +72,7 @@ describe("core/scraper/uqload.js", function () { }); it("should return video URL", async function () { - const url = new URL("https://uqload.co/foo.html"); + const url = new URL("https://uqload.io/foo.html"); const content = { html: () => Promise.resolve( @@ -92,7 +92,7 @@ describe("core/scraper/uqload.js", function () { const file = await scraper.extract(url, content); assert.equal( file, - "https://bar.com/baz/v.mp4|Referer=https://uqload.co/", + "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", ); }); @@ -117,7 +117,7 @@ describe("core/scraper/uqload.js", function () { const file = await scraper.extract(url, content); assert.equal( file, - "https://bar.com/baz/v.mp4|Referer=https://uqload.co/", + "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", ); }); }); From 78e10fe5e6692d4e33ff03bfaf1414cdcc6f8bf4 Mon Sep 17 00:00:00 2001 From: mh4ckt3mh4ckt1c4s Date: Sat, 29 Jul 2023 00:26:50 +0200 Subject: [PATCH 2/3] fix: fixing old uqload url support and adding test --- src/core/scraper/uqload.js | 3 ++- test/unit/core/scraper/uqload.js | 27 ++++++++++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/src/core/scraper/uqload.js b/src/core/scraper/uqload.js index f5e9937c..803465ef 100644 --- a/src/core/scraper/uqload.js +++ b/src/core/scraper/uqload.js @@ -37,6 +37,7 @@ const action = async function (_url, content) { export const extract = matchPattern( action, "*://uqload.io/*.html", - // Ajouter aussi l'ancien nom de domaine (qui redirige vers le nouveau). + // Ajouter aussi les anciens noms de domaine (qui redirige vers le nouveau). + "*://uqload.co/*.html", "*://uqload.com/*.html", ); diff --git a/test/unit/core/scraper/uqload.js b/test/unit/core/scraper/uqload.js index 72f4a436..9dd56a07 100644 --- a/test/unit/core/scraper/uqload.js +++ b/test/unit/core/scraper/uqload.js @@ -96,7 +96,7 @@ describe("core/scraper/uqload.js", function () { ); }); - it("should return video URL from old TLD", async function () { + it("should return video URL from old TLD .com", async function () { const url = new URL("https://uqload.com/foo.html"); const content = { html: () => @@ -120,5 +120,30 @@ describe("core/scraper/uqload.js", function () { "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", ); }); + + it("should return video URL from old TLD .co", async function () { + const url = new URL("https://uqload.co/foo.html"); + const content = { + html: () => + Promise.resolve( + new DOMParser().parseFromString( + ` + + `, + "text/html", + ), + ), + }; + + const file = await scraper.extract(url, content); + assert.equal( + file, + "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", + ); + }); }); }); From 7dd1e3ca616e38458541e5cb3d86e04d2b775709 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20R=C3=A8gne?= Date: Wed, 23 Aug 2023 17:42:29 +0200 Subject: [PATCH 3/3] =?UTF-8?q?fix:=20Ne=20plus=20v=C3=A9rifier=20le=20TLD?= =?UTF-8?q?=20de=20Uqload.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/core/scraper/uqload.js | 21 ++++----- test/integration/scraper/uqload.js | 40 ++++------------ test/unit/core/scraper/uqload.js | 75 +++++++----------------------- test/unit/core/scraper/vudeo.js | 2 +- 4 files changed, 37 insertions(+), 101 deletions(-) diff --git a/src/core/scraper/uqload.js b/src/core/scraper/uqload.js index c897c541..6526245b 100644 --- a/src/core/scraper/uqload.js +++ b/src/core/scraper/uqload.js @@ -1,7 +1,7 @@ /** * @module * @license MIT - * @see https://uqload.co/ + * @see https://uqload.com/ * @author Sébastien Règne */ @@ -17,7 +17,7 @@ const DATA_REGEXP = /sources: \["(?.*\/v.mp4)"\],/u; /** * Extrait les informations nécessaires pour lire une vidéo sur Kodi. * - * @param {URL} _url L'URL d'une vidéo de Uqload. + * @param {URL} url L'URL d'une vidéo de Uqload. * @param {Object} metadata Les métadonnées de l'URL. * @param {Function} metadata.html La fonction retournant la promesse contenant * le document HTML. @@ -25,20 +25,19 @@ const DATA_REGEXP = /sources: \["(?.*\/v.mp4)"\],/u; * fichier ou * undefined. */ -const action = async function (_url, metadata) { +const action = async function (url, metadata) { const doc = await metadata.html(); + if (undefined === doc) { + return undefined; + } + for (const script of doc.querySelectorAll("script:not([src])")) { const result = DATA_REGEXP.exec(script.text); if (null !== result) { - return result.groups.source + "|Referer=https://uqload.io/"; + return result.groups.source + `|Referer=${url.href}`; } } return undefined; }; -export const extract = matchPattern( - action, - "*://uqload.io/*.html", - // Ajouter aussi les anciens noms de domaine (qui redirige vers le nouveau). - "*://uqload.co/*.html", - "*://uqload.com/*.html", -); +// Ne pas filter sur le TLD car il change régulièrement. +export const extract = matchPattern(action, "*://uqload.*/*.html"); diff --git a/test/integration/scraper/uqload.js b/test/integration/scraper/uqload.js index 20aa2cf9..b7783521 100644 --- a/test/integration/scraper/uqload.js +++ b/test/integration/scraper/uqload.js @@ -9,7 +9,7 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Uqload", function () { it("should return undefined when it isn't a video", async function () { - const url = new URL("https://uqload.io/checkfiles.html"); + const url = new URL("https://uqload.com/checkfiles.html"); const context = { depth: false, incognito: false }; const file = await extract(url, context); @@ -17,7 +17,7 @@ describe("Scraper: Uqload", function () { }); it("should return undefined when video was deleted", async function () { - const url = new URL("https://uqload.io/k1phujbh3t7d.html"); + const url = new URL("https://uqload.com/k1phujbh3t7d.html"); const context = { depth: false, incognito: false }; const file = await extract(url, context); @@ -25,49 +25,29 @@ describe("Scraper: Uqload", function () { }); it("should return video URL", async function () { - const url = new URL("https://uqload.io/5x0cgygu2bgg.html"); - const context = { depth: false, incognito: false }; - - const file = await extract(url, context); - assert.ok( - undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.io/"), - `"${file}".endsWith(...)`, - ); - }); - - it("should return video URL when protocol is HTTP", async function () { - const url = new URL("http://uqload.io/5x0cgygu2bgg.html"); + const url = new URL("https://uqload.com/5x0cgygu2bgg.html"); const context = { depth: false, incognito: false }; const file = await extract(url, context); assert.ok( undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.io/"), + file.endsWith( + "/v.mp4|Referer=https://uqload.com/5x0cgygu2bgg.html", + ), `"${file}".endsWith(...)`, ); }); it("should return video URL from embed", async function () { - const url = new URL("https://uqload.io/embed-5x0cgygu2bgg.html"); - const context = { depth: false, incognito: false }; - - const file = await extract(url, context); - assert.ok( - undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.io/"), - `"${file}".endsWith(...)`, - ); - }); - - it("should return video URL from old TLD", async function () { - const url = new URL("https://uqload.com/5x0cgygu2bgg.html"); + const url = new URL("https://uqload.com/embed-5x0cgygu2bgg.html"); const context = { depth: false, incognito: false }; const file = await extract(url, context); assert.ok( undefined !== file && - file.endsWith("/v.mp4|Referer=https://uqload.io/"), + file.endsWith( + "/v.mp4|Referer=https://uqload.com/embed-5x0cgygu2bgg.html", + ), `"${file}".endsWith(...)`, ); }); diff --git a/test/unit/core/scraper/uqload.js b/test/unit/core/scraper/uqload.js index 54c1dbde..b40ba412 100644 --- a/test/unit/core/scraper/uqload.js +++ b/test/unit/core/scraper/uqload.js @@ -10,14 +10,22 @@ import * as scraper from "../../../../src/core/scraper/uqload.js"; describe("core/scraper/uqload.js", function () { describe("extract()", function () { it("shouldn't handle when it's a unsupported URL", async function () { - const url = new URL("https://uqload.io/faq"); + const url = new URL("https://uqload.foo/faq"); const file = await scraper.extract(url); assert.equal(file, undefined); }); + it("should return undefined when no html", async function () { + const url = new URL("https://uqload.foo/bar.html"); + const metadata = { html: () => Promise.resolve(undefined) }; + + const file = await scraper.extract(url, metadata); + assert.equal(file, undefined); + }); + it("should return undefined when no script", async function () { - const url = new URL("https://uqload.io/foo.html"); + const url = new URL("https://uqload.foo/bar.html"); const metadata = { html: () => Promise.resolve( @@ -33,14 +41,13 @@ describe("core/scraper/uqload.js", function () { }); it("should return undefined when no inline script", async function () { - const url = new URL("https://uqload.io/foo.html"); + const url = new URL("https://uqload.foo/bar.html"); const metadata = { html: () => Promise.resolve( new DOMParser().parseFromString( ` - + `, "text/html", ), @@ -52,7 +59,7 @@ describe("core/scraper/uqload.js", function () { }); it("should return undefined when no sources", async function () { - const url = new URL("https://uqload.io/foo.html"); + const url = new URL("https://uqload.foo/bar.html"); const metadata = { html: () => Promise.resolve( @@ -72,7 +79,7 @@ describe("core/scraper/uqload.js", function () { }); it("should return video URL", async function () { - const url = new URL("https://uqload.io/foo.html"); + const url = new URL("https://uqload.foo/bar.html"); const metadata = { html: () => Promise.resolve( @@ -80,7 +87,7 @@ describe("core/scraper/uqload.js", function () { ` `, @@ -92,57 +99,7 @@ describe("core/scraper/uqload.js", function () { const file = await scraper.extract(url, metadata); assert.equal( file, - "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", - ); - }); - - it("should return video URL from old TLD .com", async function () { - const url = new URL("https://uqload.com/foo.html"); - const metadata = { - html: () => - Promise.resolve( - new DOMParser().parseFromString( - ` - - `, - "text/html", - ), - ), - }; - - const file = await scraper.extract(url, metadata); - assert.equal( - file, - "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", - ); - }); - - it("should return video URL from old TLD .co", async function () { - const url = new URL("https://uqload.co/foo.html"); - const content = { - html: () => - Promise.resolve( - new DOMParser().parseFromString( - ` - - `, - "text/html", - ), - ), - }; - - const file = await scraper.extract(url, content); - assert.equal( - file, - "https://bar.com/baz/v.mp4|Referer=https://uqload.io/", + "https://baz.com/qux/v.mp4|Referer=https://uqload.foo/bar.html", ); }); }); diff --git a/test/unit/core/scraper/vudeo.js b/test/unit/core/scraper/vudeo.js index 6860bbcb..a97531c7 100644 --- a/test/unit/core/scraper/vudeo.js +++ b/test/unit/core/scraper/vudeo.js @@ -47,7 +47,7 @@ describe("core/scraper/vudeo.js", function () { Promise.resolve( new DOMParser().parseFromString( ` - + `, "text/html", ),