Skip to content

Commit

Permalink
fix: Actualiser le scraper de GoPlay.
Browse files Browse the repository at this point in the history
  • Loading branch information
regseb committed Sep 20, 2022
1 parent d0937c4 commit e60737c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/core/scraper/goplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { matchPattern } from "../tools/matchpattern.js";
*
* @type {string}
*/
const API_URL = "https://www.goplay.be/api/video/";
const API_URL = "https://api.goplay.be/web/v1/videos/short-form/";

/**
* Extrait les informations nécessaire pour lire une vidéo sur Kodi.
Expand All @@ -32,6 +32,6 @@ const action = async function (_url, content) {
const { id } = JSON.parse(div.dataset.video);
const response = await fetch(API_URL + id);
const json = await response.json();
return json.path;
return json.manifestUrls.hls;
};
export const extract = matchPattern(action, "*://www.goplay.be/video/*");
8 changes: 5 additions & 3 deletions test/unit/core/scraper/goplay.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ describe("core/scraper/goplay.js", function () {

it("should return video URL", async function () {
const stub = sinon.stub(globalThis, "fetch").resolves(new Response(
JSON.stringify({ path: "http://foo.be/bar.mp4" }),
JSON.stringify({
manifestUrls: { hls: "http://foo.be/bar.m3u8" },
}),
));

const url = new URL("https://www.goplay.be/video/baz");
Expand All @@ -43,11 +45,11 @@ describe("core/scraper/goplay.js", function () {
};

const file = await scraper.extract(url, content);
assert.strictEqual(file, "http://foo.be/bar.mp4");
assert.strictEqual(file, "http://foo.be/bar.m3u8");

assert.strictEqual(stub.callCount, 1);
assert.deepStrictEqual(stub.firstCall.args, [
"https://www.goplay.be/api/video/qux",
"https://api.goplay.be/web/v1/videos/short-form/qux",
]);
});
});
Expand Down

0 comments on commit e60737c

Please sign in to comment.