Skip to content

Commit 7872071

Browse files
committed
feat: Ajouter le support de Megaphone.
1 parent 48b8a75 commit 7872071

File tree

8 files changed

+115
-6
lines changed

8 files changed

+115
-6
lines changed

README.md

+4-3
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,10 @@ des vidéos et des musiques sur **Kodi** :
1616
- liens directs : *avi*, *mkv*, *mp3*, *flac*… et torrent / magnet ;
1717
- YouTube, Twitch, Vimeo, SoundCloud ainsi que Ace Stream, Apple Podcasts,
1818
Bigo Live, BitChute, Blog Talk Radio, Castbox, Dailymotion, DevTube, Facebook,
19-
Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Metacafe, Mixcloud, My
20-
Cloud Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline,
21-
Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT Home ;
19+
Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Megaphone, Metacafe,
20+
Mixcloud, My Cloud Player, Overcast, PeerTube, Pippa, podCloud, PodMust,
21+
Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress,
22+
Viously, YT Home ;
2223
- Allemagne : Arte ;
2324
- Belgique : VRT NU ;
2425
- États-Unis : KCAA Radio ;

locales/en/amo_description.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
direct links: <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>, ... and torrent / magnet;
55
</li>
66
<li>
7-
YouTube, Twitch, Vimeo, SoundCloud as well as Ace&nbsp;Stream, Apple&nbsp;Podcasts, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Metacafe, Mixcloud, My&nbsp;Cloud&nbsp;Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT&nbsp;Home;
7+
YouTube, Twitch, Vimeo, SoundCloud as well as Ace&nbsp;Stream, Apple&nbsp;Podcasts, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Megaphone, Metacafe, Mixcloud, My&nbsp;Cloud&nbsp;Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT&nbsp;Home;
88
<ul>
99
<li>Germany: Arte;</li>
1010
<li>Belgium: VRT&nbsp;NU;</li>

locales/fr/amo_description.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
liens directs : <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>… et torrent / magnet&nbsp;;
55
</li>
66
<li>
7-
YouTube, Twitch, Vimeo, SoundCloud ainsi que Ace&nbsp;Stream, Apple&nbsp;Podcasts, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Metacafe, Mixcloud, My&nbsp;Cloud&nbsp;Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT&nbsp;Home&nbsp;;
7+
YouTube, Twitch, Vimeo, SoundCloud ainsi que Ace&nbsp;Stream, Apple&nbsp;Podcasts, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Megaphone, Metacafe, Mixcloud, My&nbsp;Cloud&nbsp;Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT&nbsp;Home&nbsp;;
88
<ul>
99
<li>Allemagne&nbsp;: Arte&nbsp;;</li>
1010
<li>Belgique&nbsp;: VRT NU&nbsp;;</li>

locales/sk/amo_description.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
priame odkazy: <em>avi</em>, <em>mkv</em>, <em>mp3</em>, <em>flac</em>, ... a torrent / magnet;
55
</li>
66
<li>
7-
YouTube, Twitch, Vimeo, SoundCloud a tiež Ace&nbsp;Stream, Apple&nbsp;Podcasty, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Metacafe, Mixcloud, My&nbsp;Cloud&nbsp;Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT&nbsp;Home;
7+
YouTube, Twitch, Vimeo, SoundCloud a tiež Ace&nbsp;Stream, Apple&nbsp;Podcasty, Bigo&nbsp;Live, BitChute, Blog&nbsp;Talk&nbsp;Radio, Castbox, Dailymotion, DevTube, Facebook, Flickr, Full30, Instagram, Jamendo, LBRY, LiveLeak, Megaphone, Metacafe, Mixcloud, My&nbsp;Cloud&nbsp;Player, Overcast, PeerTube, Pippa, podCloud, PodMust, Radio, Radioline, Steam, Streamable, TikTok, Ultimedia, Veoh, VideoPress, Viously, YT&nbsp;Home;
88
<ul>
99
<li>Nemecko: Arte;</li>
1010
<li>Belgicko: VRT&nbsp;NU;</li>

src/core/scraper/megaphone.js

+34
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/**
2+
* @module
3+
*/
4+
/* eslint-disable require-await */
5+
6+
import { matchPattern } from "../../tools/matchpattern.js";
7+
8+
/**
9+
* Extrait les informations nécessaire pour lire un son sur Kodi.
10+
*
11+
* @param {URL} url L'URL d'un son de Megaphone.
12+
* @returns {Promise.<string>} Une promesse contenant le lien du
13+
* <em>fichier</em>.
14+
*/
15+
const actionPlayer = async function ({ pathname }) {
16+
return `https://dcs.megaphone.fm${pathname}.mp3`;
17+
};
18+
export const extractPlayer = matchPattern(actionPlayer,
19+
"*://player.megaphone.fm/*");
20+
21+
/**
22+
* Extrait les informations nécessaire pour lire un son sur Kodi.
23+
*
24+
* @param {URL} url L'URL d'un son (d'une liste de lecture) de Megaphone.
25+
* @returns {Promise.<string>} Une promesse contenant le lien du
26+
* <em>fichier</em>.
27+
*/
28+
const actionPlaylist = async function ({ searchParams }) {
29+
return searchParams.has("e")
30+
? "https://dcs.megaphone.fm/" + searchParams.get("e") + ".mp3"
31+
: null;
32+
};
33+
export const extractPlaylist = matchPattern(actionPlaylist,
34+
"*://playlist.megaphone.fm/*");

src/core/scrapers.js

+2
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ import * as lbry from "./scraper/lbry.js";
3030
import * as ldjson from "./scraper/ldjson.js";
3131
// eslint-disable-next-line import/no-cycle
3232
import * as lepoint from "./scraper/lepoint.js";
33+
import * as megaphone from "./scraper/megaphone.js";
3334
import * as melty from "./scraper/melty.js";
3435
import * as metacafe from "./scraper/metacafe.js";
3536
import * as mixcloud from "./scraper/mixcloud.js";
@@ -88,6 +89,7 @@ const SCRAPERS = [
8889
konbini,
8990
lbry,
9091
lepoint,
92+
megaphone,
9193
melty,
9294
metacafe,
9395
mixcloud,

test/integration/scraper/megaphone.js

+28
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import assert from "assert";
2+
import { extract } from "../../../src/core/scrapers.js";
3+
4+
describe("Scraper: Megaphone", function () {
5+
it("should return video URL", async function () {
6+
const url = new URL("https://player.megaphone.fm/SLT2646036872?");
7+
const options = { depth: false, incognito: false };
8+
9+
const file = await extract(url, options);
10+
assert.strictEqual(file, "https://dcs.megaphone.fm/SLT2646036872.mp3");
11+
});
12+
13+
it("should return video URL when protocol is HTTP ", async function () {
14+
const url = new URL("http://player.megaphone.fm/SLT5236779375");
15+
const options = { depth: false, incognito: false };
16+
17+
const file = await extract(url, options);
18+
assert.strictEqual(file, "https://dcs.megaphone.fm/SLT5236779375.mp3");
19+
});
20+
21+
it("should return video URL from playlist", async function () {
22+
const url = new URL("https://playlist.megaphone.fm?e=SLT5884670747");
23+
const options = { depth: false, incognito: false };
24+
25+
const file = await extract(url, options);
26+
assert.strictEqual(file, "https://dcs.megaphone.fm/SLT5884670747.mp3");
27+
});
28+
});

test/unit/core/scraper/megaphone.js

+44
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
import assert from "assert";
2+
import { extractPlayer, extractPlaylist }
3+
from "../../../../src/core/scraper/megaphone.js";
4+
5+
describe("core/scraper/megaphone.js", function () {
6+
describe("extractPlayer()", function () {
7+
it("should return null when it's a unsupported URL", async function () {
8+
const url = new URL("https://megaphone.fm/");
9+
10+
const file = await extractPlayer(url);
11+
assert.strictEqual(file, null);
12+
});
13+
14+
it("should return audio", async function () {
15+
const url = new URL("https://player.megaphone.fm/foo");
16+
17+
const file = await extractPlayer(url);
18+
assert.strictEqual(file, "https://dcs.megaphone.fm/foo.mp3");
19+
});
20+
});
21+
22+
describe("extractPlaylist()", function () {
23+
it("should return null when it's a unsupported URL", async function () {
24+
const url = new URL("https://megaphone.fm/");
25+
26+
const file = await extractPlaylist(url);
27+
assert.strictEqual(file, null);
28+
});
29+
30+
it("should return null when it's not a audio", async function () {
31+
const url = new URL("https://playlist.megaphone.fm/foo");
32+
33+
const file = await extractPlaylist(url);
34+
assert.strictEqual(file, null);
35+
});
36+
37+
it("should return audio", async function () {
38+
const url = new URL("https://playlist.megaphone.fm/?e=foo");
39+
40+
const file = await extractPlaylist(url);
41+
assert.strictEqual(file, "https://dcs.megaphone.fm/foo.mp3");
42+
});
43+
});
44+
});

0 commit comments

Comments
 (0)