Skip to content

Commit 46cda59

Browse files
committedDec 14, 2019
fix: Gérer les vidéos indisponibles de Arte.
1 parent 2c3d4d0 commit 46cda59

File tree

2 files changed

+19
-9
lines changed

2 files changed

+19
-9
lines changed
 

‎src/core/scraper/arte.js

+7-6
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,11 @@ rules.set(["*://www.arte.tv/*/videos/*/*"], async function ({ pathname }) {
3030
const response = await fetch(`${API_URL}/${lang}/${id}`);
3131
const json = await response.json();
3232

33-
return Object.values(json.videoJsonPlayer.VSR)
34-
// Garder les vidéos dans la langue courante.
35-
.filter((f) => f.id.endsWith("_1"))
36-
// Sélectionner la vidéo avec la définition la plus grande.
37-
.reduce((b, f) => (b.height < f.height ? f : b))
38-
.url;
33+
const files = Object.values(json.videoJsonPlayer.VSR)
34+
// Garder les vidéos dans la langue courante.
35+
.filter((f) => f.id.endsWith("_1"));
36+
return 0 === files.length
37+
? null
38+
: files.reduce((b, f) => (b.height < f.height ? f : b))
39+
.url;
3940
});

‎test/core/scraper/arte.js

+12-3
Original file line numberDiff line numberDiff line change
@@ -21,12 +21,21 @@ describe("scraper/arte", function () {
2121
.find(([r]) => r.includes(this.test.parent.title))[1];
2222
});
2323

24-
it("should return french video URL", async function () {
24+
it("should return null when video is unavailable", async function () {
2525
const url = "https://www.arte.tv/fr/videos/067125-020-A" +
2626
"/bits-top-list/";
27+
const expected = null;
28+
29+
const file = await action(new URL(url));
30+
assert.strictEqual(file, expected);
31+
});
32+
33+
it("should return french video URL", async function () {
34+
const url = "https://www.arte.tv/fr/videos/069798-000-A" +
35+
"/revolution-vhs/";
2736
const expected = "https://arteptweb-a.akamaihd.net/am/ptweb" +
28-
"/067000/067100/067125-020-A_SQ_2_VOF" +
29-
"_02626371_MP4-2200_AMM-PTWEB.mp4";
37+
"/069000/069700/069798-000-A_SQ_0_VOF-STF" +
38+
"_04670905_MP4-2200_AMM-PTWEB_1FpKT1ELGYC.mp4";
3039

3140
const file = await action(new URL(url));
3241
assert.strictEqual(file, expected);

0 commit comments

Comments
 (0)
Please sign in to comment.