Skip to content

Commit f58c294

Browse files
committed
fix: Corriger le scraper pour Dumpert.
1 parent 805645f commit f58c294

File tree

11 files changed

+61
-258
lines changed

11 files changed

+61
-258
lines changed

src/core/labeller/dumpert.js

-25
This file was deleted.

src/core/labeller/plugin/dumpert.js

-28
This file was deleted.

src/core/labellers.js

-4
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,7 @@
55
*/
66

77
import * as dailymotion from "./labeller/dailymotion.js";
8-
import * as dumpert from "./labeller/dumpert.js";
98
import * as pluginDailymotion from "./labeller/plugin/dailymotion.js";
10-
import * as pluginDumpert from "./labeller/plugin/dumpert.js";
119
import * as pluginSendtokodi from "./labeller/plugin/sendtokodi.js";
1210
import * as pluginSoundcloud from "./labeller/plugin/soundcloud.js";
1311
import * as pluginTubed from "./labeller/plugin/tubed.js";
@@ -30,7 +28,6 @@ import { strip } from "./tools/sanitizer.js";
3028
const LABELLERS = [
3129
// Lister les labellisateurs des plugins (triées par ordre alphabétique).
3230
pluginDailymotion,
33-
pluginDumpert,
3431
pluginSendtokodi,
3532
pluginSoundcloud,
3633
pluginTubed,
@@ -40,7 +37,6 @@ const LABELLERS = [
4037
pluginYoutube,
4138
// Lister les labellisateurs (triées par ordre alphabétique).
4239
dailymotion,
43-
dumpert,
4440
soundcloud,
4541
twitch,
4642
vimeo,

src/core/plugin/dumpert.js

-23
This file was deleted.

src/core/scraper/dumpert.js

+15-7
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,28 @@
44
* @see https://www.dumpert.nl/
55
* @author Sébastien Règne
66
*/
7-
/* eslint-disable require-await */
87

9-
import * as plugin from "../plugin/dumpert.js";
108
import { matchPattern } from "../tools/matchpattern.js";
119

1210
/**
1311
* Extrait les informations nécessaire pour lire une vidéo sur Kodi.
1412
*
15-
* @param {URL} url L'URL d'une vidéo Dumpert.
16-
* @returns {Promise<string>} Une promesse contenant le lien du
17-
* <em>fichier</em>.
13+
* @param {URL} _url L'URL d'une vidéo Dumpert.
14+
* @param {Object} content Le contenu de l'URL.
15+
* @param {Function} content.html La fonction retournant la promesse contenant
16+
* le document HTML.
17+
* @returns {Promise<string|undefined>} Une promesse contenant le lien du
18+
* <em>fichier</em> ou
19+
* <code>undefined</code>.
1820
*/
19-
const action = async function (url) {
20-
return plugin.generateUrl(url);
21+
const action = async function (_url, content) {
22+
const doc = await content.html();
23+
24+
// Ne pas utiliser le scraper opengraph car Dumpert n'implémente pas
25+
// correctement la norme Open Graph. La clé "og:video" est définie dans
26+
// l'attribut "name", alors qu'il faut la renseigner dans l'attribut
27+
// "property".
28+
return doc.querySelector('meta[name="og:video"]')?.content;
2129
};
2230
export const extract = matchPattern(
2331
action,

test/integration/labeller/dumpert.js

-32
This file was deleted.

test/integration/scraper/dumpert.js

+17-12
Original file line numberDiff line numberDiff line change
@@ -5,36 +5,42 @@
55
*/
66

77
import assert from "node:assert/strict";
8+
import sinon from "sinon";
9+
import { kodi } from "../../../src/core/jsonrpc/kodi.js";
810
import { extract } from "../../../src/core/scrapers.js";
911

1012
describe("Scraper: Dumpert", function () {
11-
it("should return video URL", async function () {
13+
it("should return video URL [opengraph]", async function () {
14+
sinon.stub(kodi.addons, "getAddons").resolves([]);
15+
1216
const url = new URL("https://www.dumpert.nl/item/7924631_3a727e30");
1317
const options = { depth: false, incognito: false };
1418

1519
const file = await extract(url, options);
1620
assert.equal(
1721
file,
18-
"plugin://plugin.video.dumpert/" +
19-
"?action=play&video_page_url=https%3A%2F%2Fwww.dumpert.nl" +
20-
"%2Fitem%2F7924631_3a727e30",
22+
"https://media.dumpert.nl/tablet" +
23+
"/3a727e30_d9d8ccbfaeef83c3.mp4.mp4.mp4",
2124
);
2225
});
2326

24-
it("should return video URL when protocol is HTTP", async function () {
27+
it("should return video URL when protocol is HTTP [opengraph]", async function () {
28+
sinon.stub(kodi.addons, "getAddons").resolves([]);
29+
2530
const url = new URL("http://www.dumpert.nl/item/7924631_3a727e30");
2631
const options = { depth: false, incognito: false };
2732

2833
const file = await extract(url, options);
2934
assert.equal(
3035
file,
31-
"plugin://plugin.video.dumpert/" +
32-
"?action=play&video_page_url=http%3A%2F%2Fwww.dumpert.nl" +
33-
"%2Fitem%2F7924631_3a727e30",
36+
"https://media.dumpert.nl/tablet" +
37+
"/3a727e30_d9d8ccbfaeef83c3.mp4.mp4.mp4",
3438
);
3539
});
3640

37-
it("should return video URL from old page", async function () {
41+
it("should return video URL from old page [opengraph]", async function () {
42+
sinon.stub(kodi.addons, "getAddons").resolves([]);
43+
3844
const url = new URL(
3945
"https://www.dumpert.nl/mediabase/7248279/47066e59" +
4046
"/wheelie_in_ny.html",
@@ -44,9 +50,8 @@ describe("Scraper: Dumpert", function () {
4450
const file = await extract(url, options);
4551
assert.equal(
4652
file,
47-
"plugin://plugin.video.dumpert/" +
48-
"?action=play&video_page_url=https%3A%2F%2Fwww.dumpert.nl" +
49-
"%2Fmediabase%2F7248279%2F47066e59%2Fwheelie_in_ny.html",
53+
"https://media.dumpert.nl/tablet" +
54+
"/47066e59_This_is_some_impressive_douchebaggery.mp4.mp4.mp4",
5055
);
5156
});
5257
});

test/unit/core/labeller/dumpert.js

-40
This file was deleted.

test/unit/core/labeller/plugin/dumpert.js

-45
This file was deleted.

test/unit/core/plugin/dumpert.js

-24
This file was deleted.

0 commit comments

Comments
 (0)