Skip to content

Commit

Permalink
fix: Actualiser les scrapers Acast / Pippa.
Browse files Browse the repository at this point in the history
  • Loading branch information
regseb committed Sep 27, 2022
1 parent aac561c commit 3d3a4f9
Show file tree
Hide file tree
Showing 9 changed files with 97 additions and 54 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ et Firefox. Elle permet de diffuser des vidéos et des musiques sur **Kodi** :
- YouTube, Twitch, Vimeo, SoundCloud ainsi que Acast, Ace Stream, Apple
Podcasts, Ausha, Bigo Live, BitChute, Blog Talk Radio, Castbox, Dailymotion,
DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone,
Mixcloud, Odysee, Overcast, PeerTube, Pippa, Podcast Addict, podCloud,
Pokémon TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia,
Veoh, VideoPress, VideosHub, Vidyard, Viously ;
Mixcloud, Odysee, Overcast, PeerTube, Podcast Addict, podCloud, Pokémon TV,
Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh,
VideoPress, VideosHub, Vidyard, Viously ;
- 🇩🇪 Allemagne : ARD Mediathek, Arte, DMAX, ZDF ;
- 🇧🇪 Belgique : GoPlay, VRT NU, VTM GO ;
- 🇺🇸 États-Unis : KCAA Radio ;
Expand Down
2 changes: 1 addition & 1 deletion locales/en/description.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cast Kodi, as the name suggests, adds the ability to cast videos and music
direct links: <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>, … and torrent / magnet;
</li>
<li>
YouTube, Twitch, Vimeo, SoundCloud as well as Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasts, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Pippa, Podcast&nbsp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously;
YouTube, Twitch, Vimeo, SoundCloud as well as Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasts, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Podcast&nbsp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously;
<ul>
<li>🇧🇪&nbsp;Belgium: GoPlay, VRT&nbsp;NU, VTM&nbsp;GO;</li>
<li>🇫🇷&nbsp;France: 20&nbsp;Minutes, AlloCiné, Arte, Arte&nbsp;Radio, France&nbsp;Inter, Futura&nbsp;Sciences, Gamekult, JV, Konbini, Le&nbsp;Monde, Le&nbsp;Point, L'Internaute, Melty, Ouest-France;</li>
Expand Down
2 changes: 1 addition & 1 deletion locales/es/description.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cast&nbsp;Kodi, as the name suggests, adds the ability to cast videos and music
direct links: <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>, … and torrent / magnet;
</li>
<li>
YouTube, Twitch, Vimeo, SoundCloud as well as Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasts, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Pippa, Podcast&nbsp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously;
YouTube, Twitch, Vimeo, SoundCloud as well as Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasts, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Podcast&nbsp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously;
<ul>
<li>🇧🇪&nbsp;Belgium: GoPlay, VRT&nbsp;NU, VTM&nbsp;GO;</li>
<li>🇫🇷&nbsp;France: 20&nbsp;Minutes, AlloCiné, Arte, Arte&nbsp;Radio, France&nbsp;Inter, Futura&nbsp;Sciences, Gamekult, JV, Konbini, Le&nbsp;Monde, Le&nbsp;Point, L'Internaute, Melty, Ouest-France;</li>
Expand Down
2 changes: 1 addition & 1 deletion locales/fr/description.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cast&nbsp;Kodi permet de diffuser des vidéos et des musiques sur <strong>Kodi</
liens directs : <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>… et torrent / magnet&nbsp;;
</li>
<li>
YouTube, Twitch, Vimeo, SoundCloud ainsi que Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasts, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Pippa, Podcast&nbsp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously&nbsp;;
YouTube, Twitch, Vimeo, SoundCloud ainsi que Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasts, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, ItemFix, Jamendo, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Podcast&nbsp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously&nbsp;;
<ul>
<li>🇩🇪&nbsp;Allemagne&nbsp;: ARD&nbsp;Mediathek, Arte, DMAX, ZDF&nbsp;;</li>
<li>🇧🇪&nbsp;Belgique&nbsp;: GoPlay, VRT&nbsp;NU, VTM&nbsp;GO&nbsp;;</li>
Expand Down
2 changes: 1 addition & 1 deletion locales/sk/description.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Cast&nbsp;Kodi, pridá možnosť posielania videí a hudby do <strong>Kodi</stro
priame odkazy: <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>, … a torrent / magnet;
</li>
<li>
YouTube, Twitch, Vimeo, SoundCloud a tiež Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasty, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, Jamendo, ItemFix, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Pippa, Podcast&nsbp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously;
YouTube, Twitch, Vimeo, SoundCloud a tiež Acast, Ace&nbsp;Stream, Apple&nbsp;Podcasty, Ausha, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Instagram, Jamendo, ItemFix, Mastodon, Megaphone, Mixcloud, Odysee, Overcast, PeerTube, Podcast&nsbp;Addict, podCloud, Pokémon&nbsp;TV, Radio, Radioline, Reddit, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, VideosHub, Vidyard, Viously;
<ul>
<li>🇧🇪&nbsp;Belgicko: GoPlay, VRT&nbsp;NU, VTM&nbsp;GO;</li>
<li>🇫🇷&nbsp;Francúzsko: 20&nbsp;Minutes, AlloCiné, Arte, Arte&nbsp;Radio, France&nbsp;Inter, Futura&nbsp;Sciences, Gamekult, JV, Konbini, Le&nbsp;Monde, Le&nbsp;Point, L'Internaute, Melty, Ouest-France;</li>
Expand Down
35 changes: 27 additions & 8 deletions src/core/scraper/acast.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,35 @@

import { matchPattern } from "../tools/matchpattern.js";

/**
* L'expression rationnelle pour extraire le podcast et l'épisode de l'URL.
*
* @type {RegExp}
*/
const REGEXP = /^(?:\/s)?\/(?<show>[^/]+)\/(?<episode>[^/]+)/u;

/**
* L'URL de l'API de Acast.
*
* @type {string}
*/
const API_URL = "https://feeder.acast.com/api/v1";

/**
* Extrait les informations nécessaire pour lire un son sur Kodi.
*
* @param {URL} url L'URL d'un son intégré de Acast.
* @returns {Promise<string>} Une promesse contenant le lien du
* <em>fichier</em>.
* @param {URL} url L'URL d'un son de Acast.
* @returns {Promise<string|undefined>} Une promesse contenant le lien du
* <em>fichier</em> ou
* <code>undefined</code>.
*/
const action = function ({ pathname }) {
const [, s, e] = pathname.split("/");
return Promise.resolve(`https://sphinx.acast.com/p/open/s/${s}/e/${e}` +
"/media.mp3");
const action = async function ({ pathname }) {
const result = REGEXP.exec(pathname);
const response = await fetch(`${API_URL}/shows/${result.groups.show}` +
`/episodes/${result.groups.episode}`);
const json = await response.json();
return json.url;
};
export const extract = matchPattern(action, "*://embed.acast.com/*/*");
export const extract = matchPattern(action,
"*://play.acast.com/s/*/*",
"*://embed.acast.com/*/*");
24 changes: 18 additions & 6 deletions test/integration/scraper/acast.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,20 +3,32 @@ import { extract } from "../../../src/core/scrapers.js";

describe("Scraper: Acast", function () {
it("should return audio URL [opengraph]", async function () {
const url = new URL("https://shows.acast.com/cdanslair/episodes" +
"/chine-le-virus-qui-inquiete-le-monde-22-01-2020");
const url = new URL("https://play.acast.com/s/c-dans-lair" +
"/8caa8723-c9fd-4104-97f9-5da3d44f2d0b");
const options = { depth: false, incognito: false };

const file = await extract(url, options);
assert.strictEqual(file,
"https://open.acast.com/public/streams" +
"/5bb36892b799143c5a063e7f/episodes" +
"/5e288874bd860fd53f96625f.mp3");
"https://francetv.proxycast.org/2969354392962084864" +
"/8caa8723-c9fd-4104-97f9-5da3d44f2d0b.mp3" +
"?u=VePZcdrLSG&_=1661879526");
});

it("should return audio URL from share [opengraph]", async function () {
const url = new URL("https://play.acast.com/s" +
"/5d84d37cf721f89940031fb4" +
"/63282b9b00922400136f2602");
const options = { depth: false, incognito: false };

const file = await extract(url, options);
assert.strictEqual(file,
"https://sphinx.acast.com/p/open/s/5d84d37cf721f89940031fb4/e" +
"/63282b9b00922400136f2602/media.mp3");
});

it("should return audio URL from embed", async function () {
const url = new URL("https://embed.acast.com/5b7ac427c6a58e726f576cff" +
"/626c0242162abf00141b401b?logo=false");
"/626c0242162abf00141b401b?seek=42");
const options = { depth: false, incognito: false };

const file = await extract(url, options);
Expand Down
29 changes: 0 additions & 29 deletions test/integration/scraper/pippa.js

This file was deleted.

49 changes: 45 additions & 4 deletions test/unit/core/scraper/acast.js
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",
]);
});
});
});

0 comments on commit 3d3a4f9

Please sign in to comment.