-
-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: Actualiser les scrapers Acast / Pippa.
- Loading branch information
Showing
9 changed files
with
97 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,63 @@ | ||
import assert from "node:assert"; | ||
import sinon from "sinon"; | ||
import * as scraper from "../../../../src/core/scraper/acast.js"; | ||
|
||
describe("core/scraper/acast.js", function () { | ||
describe("extract()", function () { | ||
it("should return undefined when it's a unsupported URL", | ||
async function () { | ||
const url = new URL("https://embed.acast.com/foo"); | ||
const url = new URL("https://play.acast.com/foo/bar"); | ||
|
||
const file = await scraper.extract(url); | ||
assert.strictEqual(file, undefined); | ||
}); | ||
|
||
it("should return undefined when id is invalid", async function () { | ||
const stub = sinon.stub(globalThis, "fetch").resolves(new Response( | ||
JSON.stringify({}), | ||
)); | ||
|
||
const url = new URL("https://play.acast.com/s/foo/bar"); | ||
|
||
const file = await scraper.extract(url); | ||
assert.strictEqual(file, undefined); | ||
|
||
assert.strictEqual(stub.callCount, 1); | ||
assert.deepStrictEqual(stub.firstCall.args, [ | ||
"https://feeder.acast.com/api/v1/shows/foo/episodes/bar", | ||
]); | ||
}); | ||
|
||
it("should return audio URL", async function () { | ||
const url = new URL("https://embed.acast.com/foo/bar?baz=qux"); | ||
const stub = sinon.stub(globalThis, "fetch").resolves(new Response( | ||
JSON.stringify({ url: "https://foo.com/bar.mp3" }), | ||
)); | ||
|
||
const url = new URL("https://play.acast.com/s/baz/qux?quux=corge"); | ||
|
||
const file = await scraper.extract(url); | ||
assert.strictEqual(file, | ||
"https://sphinx.acast.com/p/open/s/foo/e/bar/media.mp3"); | ||
assert.strictEqual(file, "https://foo.com/bar.mp3"); | ||
|
||
assert.strictEqual(stub.callCount, 1); | ||
assert.deepStrictEqual(stub.firstCall.args, [ | ||
"https://feeder.acast.com/api/v1/shows/baz/episodes/qux", | ||
]); | ||
}); | ||
|
||
it("should return audio URL embed", async function () { | ||
const stub = sinon.stub(globalThis, "fetch").resolves(new Response( | ||
JSON.stringify({ url: "https://foo.com/bar.mp3" }), | ||
)); | ||
|
||
const url = new URL("https://embed.acast.com/baz/qux?quux=corge"); | ||
|
||
const file = await scraper.extract(url); | ||
assert.strictEqual(file, "https://foo.com/bar.mp3"); | ||
|
||
assert.strictEqual(stub.callCount, 1); | ||
assert.deepStrictEqual(stub.firstCall.args, [ | ||
"https://feeder.acast.com/api/v1/shows/baz/episodes/qux", | ||
]); | ||
}); | ||
}); | ||
}); |