diff --git a/src/core/index.js b/src/core/index.js index ddd35296..6cafe4f9 100644 --- a/src/core/index.js +++ b/src/core/index.js @@ -77,7 +77,10 @@ export const cast = async function (action, urls) { } - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), { + "depth": 0, + "incognito": browser.extension.inIncognitoContext + }); switch (action) { case "send": await jsonrpc.send(file); break; case "insert": await jsonrpc.insert(file); break; @@ -85,9 +88,11 @@ export const cast = async function (action, urls) { default: throw new Error(action + " is not supported"); } - const config = await browser.storage.local.get(["general-history"]); - if (config["general-history"]) { - await browser.history.addUrl({ url }); + if (!browser.extension.inIncognitoContext) { + const config = await browser.storage.local.get(["general-history"]); + if (config["general-history"]) { + await browser.history.addUrl({ url }); + } } }; diff --git a/src/core/scraper/devtube.js b/src/core/scraper/devtube.js index a62e5c5d..9bbe7be0 100644 --- a/src/core/scraper/devtube.js +++ b/src/core/scraper/devtube.js @@ -10,16 +10,21 @@ import { matchPattern } from "../../tools/matchpattern.js"; * * @constant {string} */ -const PLUGIN_URL = "plugin://plugin.video.youtube/play/?video_id="; +const PLUGIN_URL = "plugin://plugin.video.youtube/play/"; /** * Extrait les informations nécessaire pour lire la vidéo sur Kodi. * - * @param {URL} url L'URL d'une vidéo DevTube. + * @param {URL} url L'URL d'une vidéo DevTube. + * @param {HTMLDocument} _doc Le contenu HTML de la page. + * @param {object} options Les options de l'extraction. + * @param {boolean} options.incognito La marque indiquant si l'utilisateur + * est en navigation privée. * @returns {Promise.} Une promesse contenant le lien du * fichier. */ -const action = async function ({ pathname }) { - return PLUGIN_URL + pathname.slice(7); +const action = async function ({ pathname }, _doc, { incognito }) { + return PLUGIN_URL + "?video_id=" + pathname.slice(7) + + "&incognito=" + incognito.toString(); }; export const extract = matchPattern(action, "*://dev.tube/video/*"); diff --git a/src/core/scraper/youtube.js b/src/core/scraper/youtube.js index 909e084c..8083942f 100644 --- a/src/core/scraper/youtube.js +++ b/src/core/scraper/youtube.js @@ -15,20 +15,26 @@ const PLUGIN_URL = "plugin://plugin.video.youtube/play/"; /** * Extrait les informations nécessaire pour lire une vidéo / playlist sur Kodi. * - * @param {URL} url L'URL d'une vidéo / playlist YouTube (ou Invidious / - * HookTube). + * @param {URL} url L'URL d'une vidéo / playlist YouTube + * (ou Invidious / HookTube). + * @param {HTMLDocument} _doc Le contenu HTML de la page. + * @param {object} options Les options de l'extraction. + * @param {boolean} options.incognito La marque indiquant si l'utilisateur + * est en navigation privée. * @returns {Promise.} Une promesse contenant le lien du * fichier ou null. */ -const actionVideo = async function ({ searchParams }) { +const actionVideo = async function ({ searchParams }, _doc, { incognito }) { const config = await browser.storage.local.get(["youtube-playlist"]); if (searchParams.has("list") && ("playlist" === config["youtube-playlist"] || !searchParams.has("v"))) { - return PLUGIN_URL + "?playlist_id=" + searchParams.get("list"); + return PLUGIN_URL + "?playlist_id=" + searchParams.get("list") + + "&incognito=" + incognito.toString(); } if (searchParams.has("v")) { - return PLUGIN_URL + "?video_id=" + searchParams.get("v"); + return PLUGIN_URL + "?video_id=" + searchParams.get("v") + + "&incognito=" + incognito.toString(); } return null; @@ -41,14 +47,19 @@ export const extractVideo = matchPattern(actionVideo, /** * Extrait les informations nécessaire pour lire une playlist sur Kodi. * - * @param {URL} url L'URL d'une playlist YouTube. + * @param {URL} url L'URL d'une playlist YouTube. + * @param {HTMLDocument} _doc Le contenu HTML de la page. + * @param {object} options Les options de l'extraction. + * @param {boolean} options.incognito La marque indiquant si l'utilisateur + * est en navigation privée. * @returns {Promise.} Une promesse contenant le lien du * fichier ou null. */ -const actionPlaylist = async function ({ searchParams }) { +const actionPlaylist = async function ({ searchParams }, _doc, { incognito }) { return searchParams.has("list") - ? PLUGIN_URL + "?playlist_id=" + searchParams.get("list") - : null; + ? PLUGIN_URL + "?playlist_id=" + searchParams.get("list") + + "&incognito=" + incognito.toString() + : null; }; export const extractPlaylist = matchPattern(actionPlaylist, "*://*.youtube.com/playlist*"); @@ -56,13 +67,18 @@ export const extractPlaylist = matchPattern(actionPlaylist, /** * Extrait les informations nécessaire pour lire une vidéo sur Kodi. * - * @param {URL} url L'URL d'une vidéo YouTube intégrée (ou Invidious / - * HookTube). + * @param {URL} url L'URL d'une vidéo YouTube intégrée + * (ou Invidious / HookTube). + * @param {HTMLDocument} _doc Le contenu HTML de la page. + * @param {object} options Les options de l'extraction. + * @param {boolean} options.incognito La marque indiquant si l'utilisateur + * est en navigation privée. * @returns {Promise.} Une promesse contenant le lien du * fichier. */ -const actionEmbed = async function ({ pathname }) { - return PLUGIN_URL + "?video_id=" + pathname.slice(7); +const actionEmbed = async function ({ pathname }, _doc, { incognito }) { + return PLUGIN_URL + "?video_id=" + pathname.slice(7) + + "&incognito=" + incognito.toString(); }; export const extractEmbed = matchPattern(actionEmbed, "*://www.youtube.com/embed/*", @@ -73,11 +89,16 @@ export const extractEmbed = matchPattern(actionEmbed, /** * Extrait les informations nécessaire pour lire une vidéo sur Kodi. * - * @param {URL} url L'URL minifiée d'une vidéo YouTube. + * @param {URL} url L'URL minifiée d'une vidéo YouTube. + * @param {HTMLDocument} _doc Le contenu HTML de la page. + * @param {object} options Les options de l'extraction. + * @param {boolean} options.incognito La marque indiquant si l'utilisateur + * est en navigation privée. * @returns {Promise.} Une promesse contenant le lien du * fichier. */ -const actionMinify = async function ({ pathname }) { - return PLUGIN_URL + "?video_id=" + pathname.slice(1); +const actionMinify = async function ({ pathname }, _doc, { incognito }) { + return PLUGIN_URL + "?video_id=" + pathname.slice(1) + + "&incognito=" + incognito.toString(); }; export const extractMinify = matchPattern(actionMinify, "*://youtu.be/*"); diff --git a/test/integration/scraper/acestream.js b/test/integration/scraper/acestream.js index 95de60c5..cdba4163 100644 --- a/test/integration/scraper/acestream.js +++ b/test/integration/scraper/acestream.js @@ -4,11 +4,12 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Ace Stream", function () { it("should return video URL", async function () { const url = "acestream://94c2fd8fb9bc8f2fc71a2cbe9d4b866f227a0209"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://program.plexus/?mode=1&name=" + "&url=acestream%3A%2F%2F94c2fd8fb9b" + "c8f2fc71a2cbe9d4b866f227a0209"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/allocine.js b/test/integration/scraper/allocine.js index 6ac6c4bb..6d28fcc2 100644 --- a/test/integration/scraper/allocine.js +++ b/test/integration/scraper/allocine.js @@ -4,48 +4,53 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: AlloCiné", function () { it("should return URL when it's not a video", async function () { const url = "http://www.allocine.fr/video/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return standard video URL", async function () { const url = "http://www.allocine.fr/video/video-19577157/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://fr.vid.web.acsta.net/nmedia/33/18/02/23/15" + "/19577157_sd_013.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return high video URL", async function () { const url = "http://www.allocine.fr/video" + "/player_gen_cmedia=19583315&cfilm=232669.html"; + const options = { "depth": 0, "incognito": false }; const expected = "http://fr.vid.web.acsta.net/nmedia/33/19/04/02/14" + "//19583315_hd_013.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return medium video URL", async function () { const url = "http://www.allocine.fr/video" + "/player_gen_cmedia=19432206&cfilm=1051.html"; + const options = { "depth": 0, "incognito": false }; const expected = "http://fr.vid.web.acsta.net/nmedia/s3/33/18/66/14" + "/37/19432206_sd_013.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL from RSS", async function () { const url = "http://rss.allocine.fr/~r/ac/actualites/cine/~3" + "/JT3DmCdQCdQ/fichearticle_gen_carticle=18685966.html"; + const options = { "depth": 0, "incognito": false }; const expected = "http://fr.vid.web.acsta.net/nmedia/33/19/11/22/16" + "//19586672_hd_013.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/applepodcasts.js b/test/integration/scraper/applepodcasts.js index 8693a20b..6599a49e 100644 --- a/test/integration/scraper/applepodcasts.js +++ b/test/integration/scraper/applepodcasts.js @@ -4,19 +4,21 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Apple Podcasts", function () { it("should return URL when it's not an audio", async function () { const url = "https://podcasts.apple.com/us/podcast/culture-1999/id"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL", async function () { const url = "https://podcasts.apple.com/fr/podcast" + "/cest-papy-mamie/id1093080425?i=1000435243113"; + const options = { "depth": 0, "incognito": false }; const expected = "https://dts.podtrac.com/redirect.mp3" + "/www.arteradio.com/podcast_sound/61661310.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/arte.js b/test/integration/scraper/arte.js index ffe2c6d8..e15df6e0 100644 --- a/test/integration/scraper/arte.js +++ b/test/integration/scraper/arte.js @@ -4,31 +4,34 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Arte", function () { it("should return URL when video is unavailable", async function () { const url = "https://www.arte.tv/fr/videos/067125-020-A/bits-top-list/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return french video URL", async function () { const url = "https://www.arte.tv/fr/videos/069798-000-A" + "/revolution-vhs/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://arteptweb-a.akamaihd.net/am/ptweb" + "/069000/069700/069798-000-A_SQ_0_VOF-STF" + "_04670905_MP4-2200_AMM-PTWEB_1FpKT1ELGYC.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return german video URL", async function () { const url = "https://www.arte.tv/de/videos/077140-006-A" + "/blow-up-john-carpenter-aus-der-sicht-von-thierry-jousse/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://arteptweb-a.akamaihd.net/am/ptweb" + "/077000/077100/077140-006-A_SQ_0_VA-STA" + "_03470223_MP4-2200_AMM-PTWEB_u4hdDbkpd.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/arteradio.js b/test/integration/scraper/arteradio.js index ce372e6f..6d038e48 100644 --- a/test/integration/scraper/arteradio.js +++ b/test/integration/scraper/arteradio.js @@ -4,19 +4,21 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Arte Radio", function () { it("should return audio URL", async function () { const url = "https://www.arteradio.com/son/61657661/fais_moi_ouir"; + const options = { "depth": 0, "incognito": false }; const expected = "https://download.www.arte.tv/permanent/arteradio" + "/sites/default/files/sons/01faismoiouir_hq_fr.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when protocol is HTTP", async function () { const url = "http://www.arteradio.com/son/61657661/fais_moi_ouir"; + const options = { "depth": 0, "incognito": false }; const expected = "https://download.www.arte.tv/permanent/arteradio" + "/sites/default/files/sons/01faismoiouir_hq_fr.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/bitchute.js b/test/integration/scraper/bitchute.js index ee624478..06fce26c 100644 --- a/test/integration/scraper/bitchute.js +++ b/test/integration/scraper/bitchute.js @@ -4,10 +4,11 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: BitChute", function () { it("should return video URL", async function () { const url = "https://www.bitchute.com/video/dz5JcCZnJMge/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://seed126.bitchute.com/hU2elaB5u3kB" + "/dz5JcCZnJMge.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/blogtalkradio.js b/test/integration/scraper/blogtalkradio.js index a4ef5437..6c5e3c48 100644 --- a/test/integration/scraper/blogtalkradio.js +++ b/test/integration/scraper/blogtalkradio.js @@ -4,9 +4,10 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Blog Talk Radio", function () { it("should return null when it's not an audio", async function () { const url = "https://www.blogtalkradio.com/technology"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -14,21 +15,23 @@ describe("Scraper: Blog Talk Radio", function () { const url = "https://www.blogtalkradio.com/stretchingadollar" + "/2011/03/02/7-mozilla-firefox-add-ons-to-help" + "-your-small-business-stretch-a-dollar-to-save"; + const options = { "depth": 0, "incognito": false }; const expected = "https://www.blogtalkradio.com/stretchingadollar" + "/2011/03/02/7-mozilla-firefox-add-ons-to-help" + "-your-small-business-stretch-a-dollar-to-save.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when protocol is HTTP", async function () { const url = "http://www.blogtalkradio.com/firefoxnews-online" + "/2011/06/13/firefoxnews-online"; + const options = { "depth": 0, "incognito": false }; const expected = "https://www.blogtalkradio.com/firefoxnews-online" + "/2011/06/13/firefoxnews-online.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/dailymotion.js b/test/integration/scraper/dailymotion.js index 7f268523..856a3595 100644 --- a/test/integration/scraper/dailymotion.js +++ b/test/integration/scraper/dailymotion.js @@ -4,28 +4,31 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Dailymotion", function () { it("should return video id", async function () { const url = "https://www.dailymotion.com/video/x17qw0a"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dailymotion_com/" + "?mode=playVideo&url=x17qw0a"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return tiny video id", async function () { const url = "http://dai.ly/x5riqme"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dailymotion_com/" + "?mode=playVideo&url=x5riqme"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return embed video id", async function () { const url = "https://www.dailymotion.com/embed/video/a12bc3d"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dailymotion_com/" + "?mode=playVideo&url=a12bc3d"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/devtube.js b/test/integration/scraper/devtube.js index 067367d7..907181de 100644 --- a/test/integration/scraper/devtube.js +++ b/test/integration/scraper/devtube.js @@ -4,10 +4,12 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: DevTube", function () { it("should return video id", async function () { const url = "https://dev.tube/video/4rWypxBwrR4"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=4rWypxBwrR4"; + "?video_id=4rWypxBwrR4" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/dumpert.js b/test/integration/scraper/dumpert.js index 35de3b12..5e517e46 100644 --- a/test/integration/scraper/dumpert.js +++ b/test/integration/scraper/dumpert.js @@ -5,24 +5,26 @@ describe("Scraper: Dumpert", function () { it("should return video URL", async function () { const url = "https://www.dumpert.nl/mediabase/7248279/47066e59" + "/wheelie_in_ny.html"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dumpert/?action=play" + "&video_page_url=https%3A%2F%2Fwww.dumpert.nl" + "%2Fmediabase%2F7248279%2F47066e59" + "%2Fwheelie_in_ny.html"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://www.dumpert.nl/mediabase/7248279/47066e59" + "/wheelie_in_ny.html"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dumpert/?action=play" + "&video_page_url=http%3A%2F%2Fwww.dumpert.nl" + "%2Fmediabase%2F7248279%2F47066e59" + "%2Fwheelie_in_ny.html"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/facebook.js b/test/integration/scraper/facebook.js index fd34bb70..027f5962 100644 --- a/test/integration/scraper/facebook.js +++ b/test/integration/scraper/facebook.js @@ -4,75 +4,84 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Facebook", function () { it("should return URL when it's not a video", async function () { const url = "https://www.facebook.com/XBMC/videos/666/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "https://www.facebook.com/XBMC/videos/10152476888501641/"; + const options = { "depth": 0, "incognito": false }; const expected = "/10840595_10152476888576641_527585110_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://www.facebook.com/XBMC/videos/10152476888501641/"; + const options = { "depth": 0, "incognito": false }; const expected = "/10840595_10152476888576641_527585110_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); it("should return video URL when it's mobile version", async function () { const url = "https://m.facebook.com/XBMC/videos/10152476888501641/"; + const options = { "depth": 0, "incognito": false }; const expected = "/10840595_10152476888576641_527585110_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); it("should return video URL when it's a live", async function () { const url = "https://www.facebook.com/foxcarolinanews/videos" + "/2332364197043199/"; + const options = { "depth": 0, "incognito": false }; const expected = "10000000_737031756806369_1300171264592888927_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); it("should return URL when video doesn't exist", async function () { const url = "https://www.facebook.com/watch/?v=666"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not video", async function () { const url = "https://www.facebook.com/watch/?x=315156812365737"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL from watch page", async function () { const url = "https://www.facebook.com/watch/?v=315156812365737"; + const options = { "depth": 0, "incognito": false }; const expected = "/40059842_458664621312657_6558162886282182656_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); it("should return video URL when protocol is HTTP from watch page", async function () { const url = "http://www.facebook.com/watch?v=315156812365737"; + const options = { "depth": 0, "incognito": false }; const expected = "/40059842_458664621312657_6558162886282182656_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); }); diff --git a/test/integration/scraper/flickr.js b/test/integration/scraper/flickr.js index da4dba76..bc514325 100644 --- a/test/integration/scraper/flickr.js +++ b/test/integration/scraper/flickr.js @@ -4,18 +4,20 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Flickr", function () { it("should return URL when it's not a video", async function () { const url = "http://www.flickr.com/photos/149130852@N05/40962531395/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "http://www.flickr.com/photos/brandonsphoto/9501379492/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://live.staticflickr.com/video/9501379492/" + "b2e279c142/700.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected), `"${file}".startsWith(expected)`); }); }); diff --git a/test/integration/scraper/framatube.js b/test/integration/scraper/framatube.js index 11e3f750..34902687 100644 --- a/test/integration/scraper/framatube.js +++ b/test/integration/scraper/framatube.js @@ -5,20 +5,22 @@ describe("Scraper: Framatube", function () { it("should return video embed URL", async function () { const url = "https://framatube.org/videos/embed" + "/0900bd2e-7306-4c39-b48b-2d0cd611742e"; + const options = { "depth": 0, "incognito": false }; const expected = "https://framatube.org/static/webseed" + "/0900bd2e-7306-4c39-b48b-2d0cd611742e-1080.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://framatube.org/videos/watch" + "/0b04f13d-1e18-4f1d-814e-4979aa7c9c44"; + const options = { "depth": 0, "incognito": false }; const expected = "https://peertube.datagueule.tv/static/webseed" + "/0b04f13d-1e18-4f1d-814e-4979aa7c9c44-1080.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/franceinter.js b/test/integration/scraper/franceinter.js index eb63ea85..2163775a 100644 --- a/test/integration/scraper/franceinter.js +++ b/test/integration/scraper/franceinter.js @@ -5,10 +5,11 @@ describe("Scraper: France Inter", function () { it("should return audio URL", async function () { const url = "https://www.franceinter.fr/emissions/blockbusters" + "/blockbusters-19-juillet-2019"; + const options = { "depth": 0, "incognito": false }; const expected = "https://media.radiofrance-podcast.net/podcast09" + "/17309-19.07.2019-ITEMA_22112050-0.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/full30.js b/test/integration/scraper/full30.js index ee95e989..db04968e 100644 --- a/test/integration/scraper/full30.js +++ b/test/integration/scraper/full30.js @@ -4,39 +4,43 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Full30", function () { it("should return URL when it's not a video", async function () { const url = "https://www.full30.com/video/foobar"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "http://www.full30.com/video" + "/01c970fbc3cf59528c3daaa3a4020edb"; + const options = { "depth": 0, "incognito": false }; const expected = "https://us.videos.epicio.net/public/full30v1/videos" + "/demolitionranch" + "/01c970fbc3cf59528c3daaa3a4020edb/854x480.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not a video from watch page", async function () { const url = "https://www.full30.com/watch/foobar"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL from watch page", async function () { const url = "https://www.full30.com/watch/MjY1/apple-devices-vs-50cal"; + const options = { "depth": 0, "incognito": false }; const expected = "https://us.videos.epicio.net/public/full30v1/videos" + "/demolitionranch" + "/01c970fbc3cf59528c3daaa3a4020edb/854x480.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/gamekult.js b/test/integration/scraper/gamekult.js index 8537906d..f9cd5ed4 100644 --- a/test/integration/scraper/gamekult.js +++ b/test/integration/scraper/gamekult.js @@ -5,9 +5,10 @@ describe("Scraper: Gamekult", function () { it("should return URL when it's not a video", async function () { const url = "https://www.gamekult.com/jeux/dead-cells-3050326015" + "/joueurs.html"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -15,19 +16,21 @@ describe("Scraper: Gamekult", function () { const url = "https://www.gamekult.com/actualite" + "/revivez-la-conference-bethesda-et-le" + "-debriefing-avec-le-plateau-gk-3050817795.html"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dailymotion_com/" + "?mode=playVideo&url=x7aour7"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL without 'www'", async function () { const url = "https://gamekult.com/jeux/dead-cells-3050326015.html"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.dailymotion_com/" + "?mode=playVideo&url=x6o6sws"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/hooktube.js b/test/integration/scraper/hooktube.js index 009eb0d4..466ab643 100644 --- a/test/integration/scraper/hooktube.js +++ b/test/integration/scraper/hooktube.js @@ -6,10 +6,12 @@ describe("Scraper: HookTube", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://hooktube.com/watch?v=LACbVhgtx9I"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=LACbVhgtx9I"; + "?video_id=LACbVhgtx9I" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -17,10 +19,12 @@ describe("Scraper: HookTube", function () { it("should return embed video id", async function () { const url = "https://hooktube.com/embed/3lPSQ5KjamI"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=3lPSQ5KjamI"; + "?video_id=3lPSQ5KjamI" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/instagram.js b/test/integration/scraper/instagram.js index 669bc5e6..368940cc 100644 --- a/test/integration/scraper/instagram.js +++ b/test/integration/scraper/instagram.js @@ -4,25 +4,28 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Instagram", function () { it("should return URL when it's not a video", async function () { const url = "https://www.instagram.com/p/6p_BDeK-8G/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "https://www.instagram.com/p/BpFwZ6JnYPq/"; + const options = { "depth": 0, "incognito": false }; const expected = "/43507506_351933205369613_6559511411523846144_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); it("should return video URL when protocol is HTTP", async function () { const url = "https://www.instagram.com/p/Bpji87LiJFs/"; + const options = { "depth": 0, "incognito": false }; const expected = "/44876841_340575853170202_7413375163648966656_n.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.includes(expected), `"${file}".includes(expected)`); }); }); diff --git a/test/integration/scraper/invidious.js b/test/integration/scraper/invidious.js index 5abbaedb..e44e10ea 100644 --- a/test/integration/scraper/invidious.js +++ b/test/integration/scraper/invidious.js @@ -6,10 +6,12 @@ describe("Scraper: Invidious", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://invidio.us/watch?v=e6EQwSadpPk"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=e6EQwSadpPk"; + "?video_id=e6EQwSadpPk" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -17,10 +19,12 @@ describe("Scraper: Invidious", function () { it("should return embed video id", async function () { const url = "https://invidio.us/embed/8cmBd7lkunk"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=8cmBd7lkunk"; + "?video_id=8cmBd7lkunk" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/jamendo.js b/test/integration/scraper/jamendo.js index 3576f4c8..03b5c52e 100644 --- a/test/integration/scraper/jamendo.js +++ b/test/integration/scraper/jamendo.js @@ -4,27 +4,30 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Jamendo", function () { it("should return URL when it's not a sound", async function () { const url = "https://www.jamendo.com/track/404/not-found"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL", async function () { const url = "https://www.jamendo.com/track/3431/avant-j-etais-trappeur"; + const options = { "depth": 0, "incognito": false }; const expected = "https://mp3l.jamendo.com/" + "?trackid=3431&format=mp31&from=app-97dab294"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when protocol is HTTP", async function () { const url = "http://www.jamendo.com/track/33454/vacance-au-camping"; + const options = { "depth": 0, "incognito": false }; const expected = "https://mp3l.jamendo.com/" + "?trackid=33454&format=mp31&from=app-97dab294"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/jeuxvideocom.js b/test/integration/scraper/jeuxvideocom.js index b24a528a..7ec00a50 100644 --- a/test/integration/scraper/jeuxvideocom.js +++ b/test/integration/scraper/jeuxvideocom.js @@ -4,9 +4,10 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: JeuxVideoCom", function () { it("should return URL when it's not a video", async function () { const url = "http://www.jeuxvideo.com/videos-de-jeux.htm"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -14,10 +15,11 @@ describe("Scraper: JeuxVideoCom", function () { async function () { const url = "http://www.jeuxvideo.com/videos-editeurs/0000/00007335" + "/half-life-2-pc-trailer-00004956.htm"; + const options = { "depth": 0, "incognito": false }; const expected = "http://videohd.jeuxvideo.com/videos_editeurs/0000" + "/00004956-high.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -25,20 +27,22 @@ describe("Scraper: JeuxVideoCom", function () { async function () { const url = "http://www.jeuxvideo.com/extraits-videos-jeux/0002" + "/00023827/portal-2-pc-meet-wheatley-00008311.htm"; + const options = { "depth": 0, "incognito": false }; const expected = "http://videohd.jeuxvideo.com/extraits/201104" + "/portal_2_pc-00008311-high.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "http://www.jeuxvideo.com/videos/461728" + "/superhot-notre-avis-en-deux-minutes-sur-ce-fps-original.htm"; + const options = { "depth": 0, "incognito": false }; const expected = "http://video1080.jeuxvideo.com/news/v/t" + "/vtsuperhot-259342-1457111085-1080p.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/kcaastreaming.js b/test/integration/scraper/kcaastreaming.js index 2341ad55..ff23b656 100644 --- a/test/integration/scraper/kcaastreaming.js +++ b/test/integration/scraper/kcaastreaming.js @@ -4,9 +4,10 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: KCAA Radio", function () { it("should return audio URL", async function () { const url = "http://live.kcaastreaming.com/"; + const options = { "depth": 0, "incognito": false }; const expected = "http://stream.kcaastreaming.com:5222/kcaa.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/konbini.js b/test/integration/scraper/konbini.js index eac3fbf8..f20793b0 100644 --- a/test/integration/scraper/konbini.js +++ b/test/integration/scraper/konbini.js @@ -5,10 +5,12 @@ describe("Scraper: Konbini", function () { it("should return URL", async function () { const url = "https://www.konbini.com/fr/cinema/sam-mendes-plonge" + "-lhorreur-tranchees-premier-trailer-de-1917"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=gZjQROMAh_s"; + "?video_id=gZjQROMAh_s" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/liveleak.js b/test/integration/scraper/liveleak.js index e5fa7d3e..9f39cfe2 100644 --- a/test/integration/scraper/liveleak.js +++ b/test/integration/scraper/liveleak.js @@ -4,21 +4,23 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: LiveLeak", function () { it("should return video URL", async function () { const url = "https://www.liveleak.com/view?t=HfVq_1535497667"; + const options = { "depth": 0, "incognito": false }; const expected = "https://cdn.liveleak.com/80281E/ll_a_s/2018/Aug/28/" + "LiveLeak-dot-com-Untitled_1535497475.wmv.5b85d54bbb2dd.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected), `"${file}".startsWith(expected)`); }); - it("should return video URL even when URL contains \"mp4\"", + it("should return video URL even when URL contains 'mp4'", async function () { const url = "https://www.liveleak.com/view?t=Cmp4X_1539969642"; + const options = { "depth": 0, "incognito": false }; const expected = "https://cdn.liveleak.com/80281E/ll_a_s/2018/Oct/19/" + "LiveLeak-dot-com-LaunchPadWaterDelugeSystemTestatNASAKenn_" + "1539969608.mp4.5bca1334cea29.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected), `"${file}".startsWith(expected)`); }); }); diff --git a/test/integration/scraper/magnet.js b/test/integration/scraper/magnet.js index 34943e81..74f1cebc 100644 --- a/test/integration/scraper/magnet.js +++ b/test/integration/scraper/magnet.js @@ -10,6 +10,7 @@ describe("Scraper: magnet", function () { "&tr=udp%3a%2f%2ftracker.publicbt.com%3a80%2fannounce" + "&ws=http%3a%2f%2fdistribution.bbb3d.renderfarming.net" + "%2fvideo%2fmp4%2fbbb_sunflower_1080p_30fps_normal.mp4"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.elementum/play?uri=" + "magnet%3A" + "%3Fxt%3Durn%3Abtih%3A88594AAACBDE40EF3E2510C47374EC0AA396C08E" + @@ -19,7 +20,7 @@ describe("Scraper: magnet", function () { "%26ws%3Dhttp%253a%252f%252fdistribution.bbb3d.renderfarming.net" + "%252fvideo%252fmp4%252fbbb_sunflower_1080p_30fps_normal.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/melty.js b/test/integration/scraper/melty.js index a156584d..03ab0137 100644 --- a/test/integration/scraper/melty.js +++ b/test/integration/scraper/melty.js @@ -5,20 +5,23 @@ describe("Scraper: Melty", function () { it("should return URL from hosted video", async function () { const url = "https://www.melty.fr/le-joker-la-fin-alternative-bien" + "-plus-sombre-revelee-a703715.html"; + const options = { "depth": 0, "incognito": false }; const expected = "https://media.melty.fr/article-4052018-desktop" + "/video.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL from YouTube video", async function () { const url = "https://www.melty.fr/les-films-d-action-qui-ont-change" + "-le-game-de-la-decennie-a702835.html"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=mtolAJbj44s"; + "?video_id=mtolAJbj44s" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/mixcloud.js b/test/integration/scraper/mixcloud.js index 59af485d..413be947 100644 --- a/test/integration/scraper/mixcloud.js +++ b/test/integration/scraper/mixcloud.js @@ -4,31 +4,34 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Mixcloud", function () { it("should return URL when it's not an audio", async function () { const url = "https://www.mixcloud.com/discover/jazz/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id", async function () { const url = "https://www.mixcloud.com" + "/LesGar%C3%A7onsBienElev%C3%A9s/n101/"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.mixcloud/?mode=40" + "&key=%2FLesGar%25C3%25A7onsBienElev%25C3%25A9s" + "%2Fn101%2F"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id when protocol is HTTP", async function () { const url = "http://www.mixcloud.com" + "/LesGar%C3%A7onsBienElev%C3%A9s/n101/"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.mixcloud/?mode=40" + "&key=%2FLesGar%25C3%25A7onsBienElev%25C3%25A9s" + "%2Fn101%2F"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/mixer.js b/test/integration/scraper/mixer.js index f525a725..01e58565 100644 --- a/test/integration/scraper/mixer.js +++ b/test/integration/scraper/mixer.js @@ -4,45 +4,50 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Mixer", function () { it("should return URL when it's not a video", async function () { const url = "https://mixer.com/pro"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return null URL it's invalid URL", async function () { const url = "https://mixer.com/not/found"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "https://mixer.com/NINJA"; + const options = { "depth": 0, "incognito": false }; const expected = "https://mixer.com/api/v1/channels/90571077" + "/manifest.m3u8"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://mixer.com/ChannelOne"; + const options = { "depth": 0, "incognito": false }; const expected = "https://mixer.com/api/v1/channels/58717" + "/manifest.m3u8"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL from embed video", async function () { const url = "https://mixer.com/embed/player/LevelUpCast" + "?disableLowLatency=1"; + const options = { "depth": 0, "incognito": false }; const expected = "https://mixer.com/api/v1/channels/15808052" + "/manifest.m3u8"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/mycloudplayers.js b/test/integration/scraper/mycloudplayers.js index 17ddb1dd..0e29b06e 100644 --- a/test/integration/scraper/mycloudplayers.js +++ b/test/integration/scraper/mycloudplayers.js @@ -4,27 +4,30 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: My Cloud Player", function () { it("should return URL when it's not an audio", async function () { const url = "https://mycloudplayers.com/?featured=tracks"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id", async function () { const url = "https://mycloudplayers.com/?play=176387011"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.soundcloud/play/" + "?audio_id=176387011"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id when protocol is HTTP", async function () { const url = "http://mycloudplayers.com/?play=176387011"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.soundcloud/play/" + "?audio_id=176387011"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/onetv.js b/test/integration/scraper/onetv.js index 6c513569..48febcaf 100644 --- a/test/integration/scraper/onetv.js +++ b/test/integration/scraper/onetv.js @@ -4,9 +4,10 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Первый канал (1tv.ru)", function () { it("should return URL when it's not a show", async function () { const url = "https://www.1tv.ru/shows/kvn"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -14,32 +15,35 @@ describe("Scraper: Первый канал (1tv.ru)", function () { const url = "https://www.1tv.ru/shows/pozner/izbrannoe" + "/razvlech-publiku-lozhyu-slozhno-maksim-galkin-o-svobode" + "-yumora-pozner-fragment-vypuska-ot-03-06-2019"; + const options = { "depth": 0, "incognito": false }; const expected = "https://balancer-vod.1tv.ru/video" + "/multibitrate/video/2019/06/03" + "/0535f134-80c9-40f2-af3b-6bb485488fe8" + "_20190604_Pozner_High_950.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return show URL when protocol is HTTP", async function () { const url = "http://www.1tv.ru/shows/zdorove/vypuski" + "/zdorove-vypusk-ot-26-05-2019"; + const options = { "depth": 0, "incognito": false }; const expected = "https://balancer-vod.1tv.ru/video" + "/multibitrate/video/2019/05/26" + "/0bcc8f80-6082-4589-85b1-fcc000e150e9" + "_HD-news-2019_05_26-08_19_35_2923421_cut_950.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not a movie", async function () { const url = "https://www.1tv.ru/movies/vse-filmy"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -52,12 +56,13 @@ describe("Scraper: Первый канал (1tv.ru)", function () { const url = "https://www.1tv.ru" + doc.querySelector(`article.hasVideo[data-type="content_modal"]` + ` a[href^="/movies/"]`); + const options = { "depth": 0, "incognito": false }; const expected = { "start": "https://balancer-vod.1tv.ru/video/multibitrate/video/", "end": ".mp4" }; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected.start), `"${file}".startsWith(expected.start) from ${url}`); assert.ok(file.endsWith(expected.end), diff --git a/test/integration/scraper/ouestfrance.js b/test/integration/scraper/ouestfrance.js index 1060b283..c71bbc8c 100644 --- a/test/integration/scraper/ouestfrance.js +++ b/test/integration/scraper/ouestfrance.js @@ -6,9 +6,10 @@ describe("Scraper: Ouest-France", function () { const url = "https://www.ouest-france.fr/festivals" + "/festival-dangouleme/bd-grand-prix-d-angouleme-catherine" + "-meurisse-chris-ware-et-emmanuel-guibert-finalistes-6690989"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -16,10 +17,11 @@ describe("Scraper: Ouest-France", function () { const url = "https://www.ouest-france.fr/culture/cinema" + "/festival-cannes/festival-de-cannes-spike-lee-cineaste" + "-phare-de-la-cause-noire-president-du-jury-6688060"; + const options = { "depth": 0, "incognito": false }; const expected = "/cd/be/cdbeda603ae5805ab0561403d5e1afabcd685162.mp4" + "?mdtk=01124706"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); }); diff --git a/test/integration/scraper/overcast.js b/test/integration/scraper/overcast.js index a1af81e8..1449e028 100644 --- a/test/integration/scraper/overcast.js +++ b/test/integration/scraper/overcast.js @@ -4,10 +4,11 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Overcast", function () { it("should return video URL", async function () { const url = "https://overcast.fm/+JUKOBdbAM"; + const options = { "depth": 0, "incognito": false }; const expected = "https://tracking.feedpress.it/link/17512/13061508" + "/b6710001_tc.mp3#t=0"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/pippa.js b/test/integration/scraper/pippa.js index 942253c4..419b68ec 100644 --- a/test/integration/scraper/pippa.js +++ b/test/integration/scraper/pippa.js @@ -4,31 +4,34 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Pippa", function () { it("should return URL when it's not an audio", async function () { const url = "https://shows.pippa.io/studio-404/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL", async function () { const url = "https://shows.pippa.io/cdanslair/episodes" + "/5-decembre-la-greve-qui-fait-peur-22-11-2019"; + const options = { "depth": 0, "incognito": false }; const expected = "https://app.pippa.io/public/streams" + "/5bb36892b799143c5a063e7f/episodes" + "/5dd81469bd860fd53f965cf7.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when protocol is HTTP", async function () { const url = "http://shows.pippa.io/cdanslair/episodes" + "/hongkong-la-colere-monte-pekin-menace-19-11-2019"; + const options = { "depth": 0, "incognito": false }; const expected = "https://app.pippa.io/public/streams" + "/5bb36892b799143c5a063e7f/episodes" + "/5dd4250950a8cbb62f4b21ad.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/podcloud.js b/test/integration/scraper/podcloud.js index bfbc930d..1c8ba91f 100644 --- a/test/integration/scraper/podcloud.js +++ b/test/integration/scraper/podcloud.js @@ -5,20 +5,22 @@ describe("Scraper: podCloud", function () { it("should return audio URL", async function () { const url = "https://podcloud.fr/podcast/le-cosy-corner/episode" + "/numero-51-sa-puissance-est-maximum"; + const options = { "depth": 0, "incognito": false }; const expected = "https://podcloud.fr/ext/le-cosy-corner" + "/numero-51-sa-puissance-est-maximum/enclosure.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when protocol is HTTP", async function () { const url = "https://podcloud.fr/podcast/2-heures-de-perdues" + "/episode/stargate"; + const options = { "depth": 0, "incognito": false }; const expected = "https://podcloud.fr/ext/2-heures-de-perdues" + "/stargate/enclosure.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/radio.js b/test/integration/scraper/radio.js index c2720cdf..b6d8256d 100644 --- a/test/integration/scraper/radio.js +++ b/test/integration/scraper/radio.js @@ -4,42 +4,47 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Radio", function () { it("should return URL when it's not an audio", async function () { const url = "https://www.radio.net/s/notfound"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL", async function () { const url = "https://www.radio.net/s/fip"; + const options = { "depth": 0, "incognito": false }; const expected = "http://icecast.radiofrance.fr/fip-hifi.aac"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when protocol is HTTP", async function () { const url = "http://www.radio.net/s/franceinter"; + const options = { "depth": 0, "incognito": false }; const expected = "http://icecast.radiofrance.fr/franceinter-midfi.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL when URL has subdomain", async function () { const url = "https://br.radio.net/s/antena1br"; + const options = { "depth": 0, "incognito": false }; const expected = "http://antena1.newradio.it/stream/1/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio URL from french version", async function () { const url = "https://www.radio.fr/s/franceinfo"; + const options = { "depth": 0, "incognito": false }; const expected = "http://direct.franceinfo.fr/live" + "/franceinfo-midfi.mp3"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/radioline.js b/test/integration/scraper/radioline.js index fdeb816a..53acb542 100644 --- a/test/integration/scraper/radioline.js +++ b/test/integration/scraper/radioline.js @@ -4,9 +4,10 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Radioline", function () { it("should return null when it's not an audio", async function () { const url = "https://fr-fr.radioline.co/qui-sommes-nous"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -14,9 +15,10 @@ describe("Scraper: Radioline", function () { async function () { const url = "http://www.radioline.co/search-result-for-radio-france" + "#radios/france-bleu-provence-666-fm"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -27,10 +29,11 @@ describe("Scraper: Radioline", function () { "/france-inter-tanguy-pastureau-maltraite-l-info" + ".gerald-darmanin-is-watching-you" + "-20181112111300-767ff243e145d03dae436beee7e078a1"; + const options = { "depth": 0, "incognito": false }; const expected = "http://rf.proxycast.org/1501861709009133568" + "/18141-12.11.2018-ITEMA_21890205-0.mp3?_=1448798384"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -40,10 +43,11 @@ describe("Scraper: Radioline", function () { "#chapters/france-inter-la-chronique-de-pablo-mira" + ".ras-le-bol-du-ras-le-bol" + "-20181114163800-3297da9989a66c1213ce5976c250f736"; + const options = { "depth": 0, "incognito": false }; const expected = "http://rf.proxycast.org/1502668985731129344" + "/16598-14.11.2018-ITEMA_21892402-0.mp3?_=1431848591"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/soundcloud.js b/test/integration/scraper/soundcloud.js index bf917add..355373b3 100644 --- a/test/integration/scraper/soundcloud.js +++ b/test/integration/scraper/soundcloud.js @@ -5,46 +5,51 @@ describe("Scraper: SoundCloud", function () { it("should return URL when it's not an audio", async function () { const url = "https://soundcloud.com/a-tribe-called-red/sets" + "/trapline-ep"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not an audio with one slash", async function () { const url = "https://soundcloud.com/you/collection"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id", async function () { const url = "https://soundcloud.com/esa/a-singing-comet"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.soundcloud/play/" + "?track_id=176387011"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id when protocol is HTTP", async function () { const url = "http://soundcloud.com/esa/a-singing-comet"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.soundcloud/play/" + "?track_id=176387011"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return audio id from mobile version", async function () { const url = "https://mobi.soundcloud.com/a-tribe-called-red" + "/electric-pow-wow-drum"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.audio.soundcloud/play/" + "?track_id=8481452"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/steam.js b/test/integration/scraper/steam.js index f166cfed..1f4ff795 100644 --- a/test/integration/scraper/steam.js +++ b/test/integration/scraper/steam.js @@ -4,35 +4,39 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Steam", function () { it("should return URL when it's not a video", async function () { const url = "https://store.steampowered.com/app/400/Portal/"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "https://store.steampowered.com/app/620/Portal_2/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://steamcdn-a.akamaihd.net/steam/apps" + "/81613/movie_max.mp4?t=1452903069"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://store.steampowered.com/app/322500/SUPERHOT/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://steamcdn-a.akamaihd.net/steam/apps" + "/256682033/movie_max.mp4?t=1492645342"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not a broadcast", async function () { const url = "https://steamcommunity.com/broadcast/watch/404"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -44,12 +48,13 @@ describe("Scraper: Steam", function () { const doc = new DOMParser().parseFromString(text, "text/html"); const url = doc.querySelector("a").href; + const options = { "depth": 0, "incognito": false }; const expected = { "start": /^https:\/\/[^.]+\.steamcontent\.com\/broadcast\//u, "end": ".broadcast.steamcontent.com:80" }; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(expected.start.test(file), `expected.start.test("${file}") from ${url}`); assert.ok(file.endsWith(expected.end), diff --git a/test/integration/scraper/stormotv.js b/test/integration/scraper/stormotv.js index 29188361..563a727a 100644 --- a/test/integration/scraper/stormotv.js +++ b/test/integration/scraper/stormotv.js @@ -12,9 +12,10 @@ describe("Scraper: StormoTV", function () { it("should return video URL", async function () { const url = "https://www.stormo.tv/videos/514985" + "/little-big-rock-paper-scissors/"; + const options = { "depth": 0, "incognito": false }; const expected = "/514000/514985/514985_low.mp4/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); }); diff --git a/test/integration/scraper/streamable.js b/test/integration/scraper/streamable.js index f506196d..2cda26b3 100644 --- a/test/integration/scraper/streamable.js +++ b/test/integration/scraper/streamable.js @@ -4,10 +4,11 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Streamable", function () { it("should return video URL", async function () { const url = "https://streamable.com/tapn9"; + const options = { "depth": 0, "incognito": false }; const expected = "https://cdn-b-east.streamable.com/video/mp4" + "/tapn9.mp4?"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected), `"${file}".startsWith(expected)`); }); }); diff --git a/test/integration/scraper/tiktok.js b/test/integration/scraper/tiktok.js index 3b11b099..bc3c06f2 100644 --- a/test/integration/scraper/tiktok.js +++ b/test/integration/scraper/tiktok.js @@ -5,11 +5,12 @@ describe("Scraper: TikTok", function () { it("should return video URL", async function () { const url = "https://www.tiktok.com/@the90guy/video" + "/6710341586984635654?langCountry=fr"; + const options = { "depth": 0, "incognito": false }; const expected = "&lr=tiktok_m&qs=0&rc=ampvbHJwdnV4bjMzOjczM0ApPD" + "M7OGU0aWU3NzM8aTY1PGc0azNhbmpja2NfLS0zMTZzczI1L" + "zQyMF8yYV81X141LS06Yw%3D%3D"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); }); diff --git a/test/integration/scraper/torrent.js b/test/integration/scraper/torrent.js index 902eef6f..909744c5 100644 --- a/test/integration/scraper/torrent.js +++ b/test/integration/scraper/torrent.js @@ -5,11 +5,12 @@ describe("Scraper: torrent", function () { it("should return video URL from torrent", async function () { const url = "https://archive.org/download/Sintel" + "/Sintel_archive.torrent"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.elementum/play" + "?uri=https%3A%2F%2Farchive.org" + "%2Fdownload%2FSintel%2FSintel_archive.torrent"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/twitch.js b/test/integration/scraper/twitch.js index b6ff3133..ff82a4a7 100644 --- a/test/integration/scraper/twitch.js +++ b/test/integration/scraper/twitch.js @@ -4,73 +4,81 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Twitch", function () { it("should return video id", async function () { const url = "https://www.twitch.tv/videos/164088111"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&video_id=164088111"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id when protocol is HTTP", async function () { const url = "http://www.twitch.tv/videos/164088111"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&video_id=164088111"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id from 'go'", async function () { const url = "https://go.twitch.tv/videos/164088111"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&video_id=164088111"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id from mobile version", async function () { const url = "https://m.twitch.tv/videos/164088111"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&video_id=164088111"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not a clip", async function () { const url = "https://clips.twitch.tv/embed?noclip=Awesome"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return embed clip name", async function () { const url = "https://clips.twitch.tv/embed" + "?clip=IncredulousAbstemiousFennelImGlitch"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&slug=IncredulousAbstemiousFennelImGlitch"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return clip name", async function () { const url = "https://clips.twitch.tv/GleamingWildCougarFUNgineer"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&slug=GleamingWildCougarFUNgineer"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return clip name when protocol is HTTP", async function () { const url = "http://clips.twitch.tv/GleamingWildCougarFUNgineer"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&slug=GleamingWildCougarFUNgineer"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); @@ -78,92 +86,102 @@ describe("Scraper: Twitch", function () { const url = "https://www.twitch.tv/twitch/clip" + "/GleamingWildCougarFUNgineer" + "?filter=clips&range=7d&sort=time"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&slug=GleamingWildCougarFUNgineer"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return clip name from 'go'", async function () { const url = "https://go.twitch.tv/twitch/clip" + "/GleamingWildCougarFUNgineer"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&slug=GleamingWildCougarFUNgineer"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return clip name from mobile version", async function () { const url = "https://m.twitch.tv/twitch/clip" + "/GleamingWildCougarFUNgineer"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&slug=GleamingWildCougarFUNgineer"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not channel or video", async function () { const url = "https://player.twitch.tv/?other=foobar"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return channel name from player", async function () { const url = "https://player.twitch.tv/?channel=canardpc&muted=true"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&channel_name=canardpc"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id from player", async function () { const url = "https://player.twitch.tv/?video=474384559&autoplay=false"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&video_id=474384559"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return channel name", async function () { const url = "https://www.twitch.tv/nolife"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&channel_name=nolife"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return channel name when protocol is HTTP", async function () { const url = "http://www.twitch.tv/nolife"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&channel_name=nolife"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return channel name form 'go'", async function () { const url = "https://go.twitch.tv/nolife"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&channel_name=nolife"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return channel name from mobile version", async function () { const url = "https://m.twitch.tv/jvtv"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.twitch/?mode=play" + "&channel_name=jvtv"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/ultimedia.js b/test/integration/scraper/ultimedia.js index bc20e961..a866eec2 100644 --- a/test/integration/scraper/ultimedia.js +++ b/test/integration/scraper/ultimedia.js @@ -4,39 +4,43 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Ultimedia", function () { it("should return URL when it's not an audio", async function () { const url = "https://www.ultimedia.com/default/presentation/cgu"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "https://www.ultimedia.com/default/index/videogeneric/id" + "/pms83v"; + const options = { "depth": 0, "incognito": false }; const expected = "f1/84/f184a3218cbc7fd3d9cc6f4ac3e06ef7cb971753.mp4" + "?mdtk=01601930"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://www.ultimedia.com/default/index/videogeneric/id" + "/8lflp5"; + const options = { "depth": 0, "incognito": false }; const expected = "/2f/89/2f89cbc343c0d91d934129c541dd854b020e5f14.mp4" + "?mdtk=01601930"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); it("should return video URL from embed", async function () { const url = "https://www.ultimedia.com/deliver/generic/iframe/mdtk" + "/01836272/src/pzmpzr/zone/1/showtitle/1/"; + const options = { "depth": 0, "incognito": false }; const expected = "/f6/5c/f65ca8f12f314060fd3ed79e9d0e66ace641a800.mp4" + "?mdtk=01836272"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); }); diff --git a/test/integration/scraper/utvarpsaga.js b/test/integration/scraper/utvarpsaga.js index 7256cc3a..1a4ef686 100644 --- a/test/integration/scraper/utvarpsaga.js +++ b/test/integration/scraper/utvarpsaga.js @@ -5,10 +5,11 @@ describe("Scraper: Útvarp Saga", function () { it("should return video URL", async function () { const url = "https://utvarpsaga.is/" + "snjallsimarnir-eru-farnir-ad-stjorna-lifi-folks/"; + const options = { "depth": 0, "incognito": false }; const expected = "https://www.utvarpsaga.is/file/" + "s%C3%AD%C3%B0degi-a-7.9.18.mp3?_=1"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/vimeo.js b/test/integration/scraper/vimeo.js index 42caee35..d566c63b 100644 --- a/test/integration/scraper/vimeo.js +++ b/test/integration/scraper/vimeo.js @@ -4,41 +4,46 @@ import { extract } from "../../../src/core/scrapers.js"; describe("Scraper: Vimeo", function () { it("should return URL when it's not a video", async function () { const url = "https://vimeo.com/channels"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id", async function () { const url = "https://vimeo.com/228786490"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vimeo/play/?video_id=228786490"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id when protocol is HTTP", async function () { const url = "http://vimeo.com/228786490"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vimeo/play/?video_id=228786490"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not a embed video", async function () { const url = "https://player.vimeo.com/video/foobar"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return embed video id", async function () { const url = "https://player.vimeo.com/video/228786490"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vimeo/play/?video_id=228786490"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/vingtminutes.js b/test/integration/scraper/vingtminutes.js index 81999b79..f912d993 100644 --- a/test/integration/scraper/vingtminutes.js +++ b/test/integration/scraper/vingtminutes.js @@ -6,19 +6,21 @@ describe("Scraper: 20 Minutes", function () { const url = "https://www.20minutes.fr/high-tech" + "/2694715-20200114-mozilla-devoile-son" + "-assistant-virtuel-pense-pour-firefox"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL", async function () { const url = "https://www.20minutes.fr/sciences" + "/2697215-20200117-ariane-5-succes-premier-lancement-annee"; + const options = { "depth": 0, "incognito": false }; const expected = "/59/6b/596b282e57e592e47df9a6f0434f3281f82b79df.mp4" + "?mdtk=01357940"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.endsWith(expected), `"${file}".endsWith(expected)`); }); }); diff --git a/test/integration/scraper/vrtnu.js b/test/integration/scraper/vrtnu.js index 3d513146..4959b221 100644 --- a/test/integration/scraper/vrtnu.js +++ b/test/integration/scraper/vrtnu.js @@ -5,38 +5,42 @@ describe("Scraper: VRT NU", function () { it("should return video URL", async function () { const url = "https://www.vrt.be/vrtnu/a-z/het-journaal/2019" + "/het-journaal-het-journaal-13u-20190901/"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vrt.nu/play/url" + "/https://www.vrt.be/vrtnu/a-z/het-journaal" + "/2019/het-journaal-het-journaal-13u-20190901/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL when protocol is HTTP", async function () { const url = "http://www.vrt.be/vrtnu/a-z/pano/2019/pano-s2019a9/"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vrt.nu/play/url" + "/http://www.vrt.be/vrtnu/a-z/pano/2019/pano-s2019a9/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL without 'www'", async function () { const url = "https://vrt.be/vrtnu/a-z/koppen/2016/koppen-d20180721/"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vrt.nu/play/url" + "/https://vrt.be/vrtnu/a-z/koppen/2016/koppen-d20180721/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL from 'link' page", async function () { const url = "https://vrtnu.page.link/KXWX"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.vrt.nu/play/url" + "/https://vrtnu.page.link/KXWX"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/youtube.js b/test/integration/scraper/youtube.js index 56ea7a97..9b6e2499 100644 --- a/test/integration/scraper/youtube.js +++ b/test/integration/scraper/youtube.js @@ -6,9 +6,10 @@ describe("Scraper: YouTube", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "https://www.youtube.com/watch?x=123456"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -19,10 +20,12 @@ describe("Scraper: YouTube", function () { const url = "https://www.youtube.com/watch?v=avt4ZWlVjdY" + "&list=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?playlist_id=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum"; + "?playlist_id=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -33,10 +36,12 @@ describe("Scraper: YouTube", function () { const url = "https://www.youtube.com/watch?v=avt4ZWlVjdY" + "&list=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=avt4ZWlVjdY"; + "?video_id=avt4ZWlVjdY" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -46,10 +51,12 @@ describe("Scraper: YouTube", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "https://www.youtube.com/watch?v=sWfAtMQa_yo"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=sWfAtMQa_yo"; + "?video_id=sWfAtMQa_yo" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -59,10 +66,12 @@ describe("Scraper: YouTube", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "http://www.youtube.com/watch?v=sWfAtMQa_yo"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=sWfAtMQa_yo"; + "?video_id=sWfAtMQa_yo" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -73,9 +82,10 @@ describe("Scraper: YouTube", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://m.youtube.com/watch?a=dQw4w9WgXcQ"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -85,10 +95,12 @@ describe("Scraper: YouTube", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "https://m.youtube.com/watch?v=dQw4w9WgXcQ"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=dQw4w9WgXcQ"; + "?video_id=dQw4w9WgXcQ" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -98,9 +110,10 @@ describe("Scraper: YouTube", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://music.youtube.com/watch?m=abcdef"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -111,10 +124,12 @@ describe("Scraper: YouTube", function () { const url = "https://music.youtube.com/watch?v=IOqxarVWKRs" + "&list=RDAMVMIOqxarVWKRs"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=IOqxarVWKRs"; + "?video_id=IOqxarVWKRs" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -122,64 +137,76 @@ describe("Scraper: YouTube", function () { it("should return URL when it's not a playlist", async function () { const url = "https://www.youtube.com/playlist?v=dQw4w9WgXcQ"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return playlist id", async function () { const url = "https://www.youtube.com/playlist" + "?list=PLd8UclkuwTj9vaRGP3859UHcdmlrkAd-9"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?playlist_id=PLd8UclkuwTj9vaRGP3859UHcdmlrkAd-9"; + "?playlist_id=PLd8UclkuwTj9vaRGP3859UHcdmlrkAd-9" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return URL when it's not a playlist from mobile", async function () { const url = "https://m.youtube.com/playlist?video=PL3A5849BDE0581B19"; + const options = { "depth": 0, "incognito": false }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return playlist id from mobile", async function () { const url = "https://m.youtube.com/playlist?list=PL3A5849BDE0581B19"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?playlist_id=PL3A5849BDE0581B19"; + "?playlist_id=PL3A5849BDE0581B19" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return embed video id", async function () { const url = "https://www.youtube.com/embed/v3gefWEggSc"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=v3gefWEggSc"; + "?video_id=v3gefWEggSc" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id without cookie", async function () { const url = "https://www.youtube-nocookie.com/embed/u9gVaeb9le4"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=u9gVaeb9le4"; + "?video_id=u9gVaeb9le4" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video id from tiny URL", async function () { const url = "https://youtu.be/NSFbekvYOlI"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=NSFbekvYOlI"; + "?video_id=NSFbekvYOlI" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/integration/scraper/ythome.js b/test/integration/scraper/ythome.js index a9474226..d1faffc2 100644 --- a/test/integration/scraper/ythome.js +++ b/test/integration/scraper/ythome.js @@ -5,19 +5,23 @@ describe("Scraper: YT Home", function () { it("should return video URL", async function () { const url = "https://yt.ax/watch" + "/how-to-make-perfect-chocolate-chip-cookies-40889071/"; + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=rEdl2Uetpvo"; + "?video_id=rEdl2Uetpvo" + + "&incognito=false"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return video URL from short link", async function () { const url = "https://yt.ax/rEdl2Uetpvo"; + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=rEdl2Uetpvo"; + "?video_id=rEdl2Uetpvo" + + "&incognito=true"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); }); diff --git a/test/polyfill/browser.js b/test/polyfill/browser.js index b9ca99dc..dacb6880 100644 --- a/test/polyfill/browser.js +++ b/test/polyfill/browser.js @@ -22,6 +22,9 @@ export const browser = { : Promise.reject(new Error("Bookmark not found")); } }, + "extension": { + "inIncognitoContext": false + }, "i18n": { "getMessage": (key, substitutions) => { if (!(key in I18NS)) { diff --git a/test/unit/core/scraper/devtube.js b/test/unit/core/scraper/devtube.js index 5aca1886..c9da81d1 100644 --- a/test/unit/core/scraper/devtube.js +++ b/test/unit/core/scraper/devtube.js @@ -13,10 +13,13 @@ describe("core/scraper/devtube.js", function () { it("should return video id", async function () { const url = "https://dev.tube/video/4rWypxBwrR4"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=4rWypxBwrR4"; + "?video_id=4rWypxBwrR4" + + "&incognito=false"; - const file = await extract(new URL(url)); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); diff --git a/test/unit/core/scraper/iframe.js b/test/unit/core/scraper/iframe.js index 487dae79..89b8dde5 100644 --- a/test/unit/core/scraper/iframe.js +++ b/test/unit/core/scraper/iframe.js @@ -6,9 +6,10 @@ describe("core/scraper/iframe.js", function () { it("should return null when it's not a HTML page", async function () { const url = "https://example.com/not_html.zip"; const doc = null; + const options = { "depth": 0 }; const expected = null; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -20,9 +21,10 @@ describe("core/scraper/iframe.js", function () { `, "text/html"); + const options = { "depth": 0, "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=YbJOTdZBX1g"; + "?video_id=YbJOTdZBX1g" + + "&incognito=false"; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); diff --git a/test/unit/core/scraper/onetv.js b/test/unit/core/scraper/onetv.js index 576bc886..6d53e0a6 100644 --- a/test/unit/core/scraper/onetv.js +++ b/test/unit/core/scraper/onetv.js @@ -11,7 +11,7 @@ describe("core/scraper/onetv.js", function () { `, "text/html"); const expected = null; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc); assert.strictEqual(file, expected); }); @@ -26,7 +26,7 @@ describe("core/scraper/onetv.js", function () { `, "text/html"); const expected = "http://bar.com/baz.mp4"; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc); assert.strictEqual(file, expected); }); }); diff --git a/test/unit/core/scraper/opengraph.js b/test/unit/core/scraper/opengraph.js index 2be38a11..f2c7fe50 100644 --- a/test/unit/core/scraper/opengraph.js +++ b/test/unit/core/scraper/opengraph.js @@ -7,9 +7,10 @@ describe("core/scraper/opengraph.js", function () { it("should return null when it's not a HTML page", async function () { const url = "https://foo.com"; const doc = null; + const options = { "depth": 0 }; const expected = null; - const file = await extractVideo(new URL(url), doc, { "depth": 0 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -19,9 +20,10 @@ describe("core/scraper/opengraph.js", function () { `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extractVideo(new URL(url), doc, { "depth": 0 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -34,9 +36,10 @@ describe("core/scraper/opengraph.js", function () { `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extractVideo(new URL(url), doc, { "depth": 0 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -50,9 +53,10 @@ describe("core/scraper/opengraph.js", function () { content="http://bar.com/baz.pdf" /> `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extractVideo(new URL(url), doc, { "depth": 0 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -66,9 +70,10 @@ describe("core/scraper/opengraph.js", function () { content="http://bar.com/baz.mkv" /> `, "text/html"); + const options = { "depth": 0 }; const expected = "http://bar.com/baz.mkv"; - const file = await extractVideo(new URL(url), doc, { "depth": 0 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -82,9 +87,10 @@ describe("core/scraper/opengraph.js", function () { content="http://bar.com/baz.html" /> `, "text/html"); + const options = { "depth": 1 }; const expected = null; - const file = await extractVideo(new URL(url), doc, { "depth": 1 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -98,10 +104,12 @@ describe("core/scraper/opengraph.js", function () { content="https://www.youtube.com/embed/v3gefWEggSc" /> `, "text/html"); + const options = { "depth": 0, "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=v3gefWEggSc"; + "?video_id=v3gefWEggSc" + + "&incognito=true"; - const file = await extractVideo(new URL(url), doc, { "depth": 0 }); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); @@ -110,9 +118,10 @@ describe("core/scraper/opengraph.js", function () { it("should return null when it's not a HTML page", async function () { const url = "https://foo.com"; const doc = null; + const options = { "depth": 0 }; const expected = null; - const file = await extractAudio(new URL(url), doc, { "depth": 0 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -122,9 +131,10 @@ describe("core/scraper/opengraph.js", function () { `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extractAudio(new URL(url), doc, { "depth": 0 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -137,9 +147,10 @@ describe("core/scraper/opengraph.js", function () { `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extractAudio(new URL(url), doc, { "depth": 0 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -153,9 +164,10 @@ describe("core/scraper/opengraph.js", function () { content="http://bar.com/baz.pdf" /> `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extractAudio(new URL(url), doc, { "depth": 0 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -169,9 +181,10 @@ describe("core/scraper/opengraph.js", function () { content="http://bar.com/baz.wav" /> `, "text/html"); + const options = { "depth": 0 }; const expected = "http://bar.com/baz.wav"; - const file = await extractAudio(new URL(url), doc, { "depth": 0 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -185,9 +198,10 @@ describe("core/scraper/opengraph.js", function () { content="http://bar.com/baz.html" /> `, "text/html"); + const options = { "depth": 1 }; const expected = null; - const file = await extractAudio(new URL(url), doc, { "depth": 1 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -202,10 +216,11 @@ describe("core/scraper/opengraph.js", function () { `/cest-papy-mamie/id1093080425?i=1000435243113" /> `, "text/html"); + const options = { "depth": 0 }; const expected = "https://dts.podtrac.com/redirect.mp3" + "/www.arteradio.com/podcast_sound/61661310.mp3"; - const file = await extractAudio(new URL(url), doc, { "depth": 0 }); + const file = await extractAudio(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); diff --git a/test/unit/core/scraper/ouestfrance.js b/test/unit/core/scraper/ouestfrance.js index 88c07e4b..736ce579 100644 --- a/test/unit/core/scraper/ouestfrance.js +++ b/test/unit/core/scraper/ouestfrance.js @@ -14,9 +14,10 @@ describe("core/scraper/ouestfrance.js", function () { it("should return null when it's not a HTML page", async function () { const url = "https://www.ouest-france.fr/foo"; const doc = null; + const options = { "depth": 0 }; const expected = null; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -29,9 +30,10 @@ describe("core/scraper/ouestfrance.js", function () { `/123456789" /> `, "text/html"); + const options = { "depth": 1 }; const expected = null; - const file = await extract(new URL(url), doc, { "depth": 1 }); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -41,9 +43,10 @@ describe("core/scraper/ouestfrance.js", function () { `, "text/html"); + const options = { "depth": 0 }; const expected = null; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -56,10 +59,11 @@ describe("core/scraper/ouestfrance.js", function () { `/123456789" /> `, "text/html"); + const options = { "depth": 0 }; const expected = "plugin://plugin.video.dailymotion_com/" + "?mode=playVideo&url=123456789"; - const file = await extract(new URL(url), doc, { "depth": 0 }); + const file = await extract(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); diff --git a/test/unit/core/scraper/youtube.js b/test/unit/core/scraper/youtube.js index b3227e70..e471b75b 100644 --- a/test/unit/core/scraper/youtube.js +++ b/test/unit/core/scraper/youtube.js @@ -6,9 +6,11 @@ describe("core/scraper/youtube.js", function () { describe("extractVideo()", function () { it("should return null when it's a unsupported URL", async function () { const url = "https://www.youtube.com/feed/trending"; + const doc = undefined; + const options = { "incognito": false }; const expected = null; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); }); @@ -16,9 +18,11 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "https://www.youtube.com/watch?x=123456"; + const doc = undefined; + const options = { "incognito": false }; const expected = null; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -30,10 +34,13 @@ describe("core/scraper/youtube.js", function () { const url = "https://www.youtube.com/watch" + "?v=avt4ZWlVjdY" + "&list=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?playlist_id=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum"; + "?playlist_id=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum" + + "&incognito=false"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -45,10 +52,13 @@ describe("core/scraper/youtube.js", function () { const url = "https://www.youtube.com/watch" + "?v=avt4ZWlVjdY" + "&list=PL7nedIL_qbuZBS5ZAiGkjB1LW9C3zZvum"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=avt4ZWlVjdY"; + "?video_id=avt4ZWlVjdY" + + "&incognito=true"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -59,10 +69,13 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "https://www.youtube.com/watch?v=sWfAtMQa_yo"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=sWfAtMQa_yo"; + "?video_id=sWfAtMQa_yo" + + "&incognito=false"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -72,10 +85,13 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "http://www.youtube.com/watch?v=sWfAtMQa_yo"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=sWfAtMQa_yo"; + "?video_id=sWfAtMQa_yo" + + "&incognito=true"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -86,9 +102,11 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://m.youtube.com/watch?a=dQw4w9WgXcQ"; + const doc = undefined; + const options = { "incognito": false }; const expected = null; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -98,10 +116,13 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "playlist" }); const url = "https://m.youtube.com/watch?v=dQw4w9WgXcQ"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=dQw4w9WgXcQ"; + "?video_id=dQw4w9WgXcQ" + + "&incognito=false"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -112,9 +133,11 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://music.youtube.com/watch?m=abcdef"; + const doc = undefined; + const options = { "incognito": false }; const expected = null; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -126,10 +149,13 @@ describe("core/scraper/youtube.js", function () { const url = "https://music.youtube.com/watch" + "?v=IOqxarVWKRs" + "&list=RDAMVMIOqxarVWKRs"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=IOqxarVWKRs"; + "?video_id=IOqxarVWKRs" + + "&incognito=true"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -139,10 +165,13 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://invidio.us/watch?v=e6EQwSadpPk"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=e6EQwSadpPk"; + "?video_id=e6EQwSadpPk" + + "&incognito=false"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -152,10 +181,13 @@ describe("core/scraper/youtube.js", function () { browser.storage.local.set({ "youtube-playlist": "video" }); const url = "https://hooktube.com/watch?v=LACbVhgtx9I"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=LACbVhgtx9I"; + "?video_id=LACbVhgtx9I" + + "&incognito=true"; - const file = await extractVideo(new URL(url)); + const file = await extractVideo(new URL(url), doc, options); assert.strictEqual(file, expected); browser.storage.local.clear(); @@ -165,39 +197,50 @@ describe("core/scraper/youtube.js", function () { describe("extractPlaylist()", function () { it("should return null when it's not a playlist", async function () { const url = "https://www.youtube.com/playlist?v=dQw4w9WgXcQ"; + const doc = undefined; + const options = { "incognito": false }; const expected = null; - const file = await extractPlaylist(new URL(url)); + const file = await extractPlaylist(new URL(url), doc, options); assert.strictEqual(file, expected); }); it("should return playlist id", async function () { const url = "https://www.youtube.com/playlist" + "?list=PLd8UclkuwTj9vaRGP3859UHcdmlrkAd-9"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?playlist_id=PLd8UclkuwTj9vaRGP3859UHcdmlrkAd-9"; + "?playlist_id=PLd8UclkuwTj9vaRGP3859UHcdmlrkAd-9" + + "&incognito=false"; - const file = await extractPlaylist(new URL(url)); + const file = await extractPlaylist(new URL(url), doc, options); assert.strictEqual(file, expected); }); it("should return null when it's not a playlist from mobile", async function () { const url = "https://m.youtube.com/playlist" + - "?video=PL3A5849BDE0581B19"; + "?video=PL3A5849BDE0581B19" + + "&incognito=false"; + const doc = undefined; + const options = { "incognito": false }; const expected = null; - const file = await extractPlaylist(new URL(url)); + const file = await extractPlaylist(new URL(url), doc, options); assert.strictEqual(file, expected); }); it("should return playlist id from mobile", async function () { const url = "https://m.youtube.com/playlist" + "?list=PL3A5849BDE0581B19"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?playlist_id=PL3A5849BDE0581B19"; + "?playlist_id=PL3A5849BDE0581B19" + + "&incognito=true"; - const file = await extractPlaylist(new URL(url)); + const file = await extractPlaylist(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); @@ -205,37 +248,49 @@ describe("core/scraper/youtube.js", function () { describe("extractEmbed()", function () { it("should return video id", async function () { const url = "https://www.youtube.com/embed/v3gefWEggSc"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=v3gefWEggSc"; + "?video_id=v3gefWEggSc" + + "&incognito=false"; - const file = await extractEmbed(new URL(url)); + const file = await extractEmbed(new URL(url), doc, options); assert.strictEqual(file, expected); }); it("should return video id without cookie", async function () { const url = "https://www.youtube-nocookie.com/embed/u9gVaeb9le4"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=u9gVaeb9le4"; + "?video_id=u9gVaeb9le4" + + "&incognito=true"; - const file = await extractEmbed(new URL(url)); + const file = await extractEmbed(new URL(url), doc, options); assert.strictEqual(file, expected); }); it("should return video id form invidio.us", async function () { const url = "https://invidio.us/embed/8cmBd7lkunk"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=8cmBd7lkunk"; + "?video_id=8cmBd7lkunk" + + "&incognito=false"; - const file = await extractEmbed(new URL(url)); + const file = await extractEmbed(new URL(url), doc, options); assert.strictEqual(file, expected); }); it("should return video id from hooktube", async function () { const url = "https://hooktube.com/embed/3lPSQ5KjamI"; + const doc = undefined; + const options = { "incognito": true }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=3lPSQ5KjamI"; + "?video_id=3lPSQ5KjamI" + + "&incognito=true"; - const file = await extractEmbed(new URL(url)); + const file = await extractEmbed(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); @@ -243,10 +298,13 @@ describe("core/scraper/youtube.js", function () { describe("extractMinify()", function () { it("should return video id", async function () { const url = "https://youtu.be/NSFbekvYOlI"; + const doc = undefined; + const options = { "incognito": false }; const expected = "plugin://plugin.video.youtube/play/" + - "?video_id=NSFbekvYOlI"; + "?video_id=NSFbekvYOlI" + + "&incognito=false"; - const file = await extractMinify(new URL(url)); + const file = await extractMinify(new URL(url), doc, options); assert.strictEqual(file, expected); }); }); diff --git a/test/unit/core/scrapers.js b/test/unit/core/scrapers.js index 7323055e..09db0ff8 100644 --- a/test/unit/core/scrapers.js +++ b/test/unit/core/scrapers.js @@ -6,35 +6,39 @@ describe("core/scrapers.js", function () { it("should return URL when it's not supported", async function () { const url = "https://kodi.tv/sites/default/themes/kodi/" + "logo-sbs.svg"; + const options = { "depth": 0 }; const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should return media URL", async function () { const url = "https://www.bitchute.com/video/dz5JcCZnJMge/"; + const options = { "depth": 0 }; const expected = "https://seed126.bitchute.com/hU2elaB5u3kB" + "/dz5JcCZnJMge.mp4"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.strictEqual(file, expected); }); it("should support URL", async function () { const url = "http://www.dailymotion.com/video/x17qw0a"; + const options = { "depth": 0 }; const expected = "plugin://plugin.video.dailymotion_com/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected), `"${file}".startsWith(expected)`); }); it("should support uppercase URL", async function () { const url = "HTTPS://VIMEO.COM/195613867"; + const options = { "depth": 0 }; const expected = "plugin://plugin.video.vimeo/"; - const file = await extract(new URL(url), { "depth": 0 }); + const file = await extract(new URL(url), options); assert.ok(file.startsWith(expected), `"${file}".startsWith(expected)`); }); @@ -42,39 +46,50 @@ describe("core/scrapers.js", function () { it("should support correctly question mark in pattern", async function () { const url = "https://vid.ly/i2x4g5.mp4?quality=hd"; + const options = { "depth": 0 }; + const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); - assert.strictEqual(file, url); + const file = await extract(new URL(url), options); + assert.strictEqual(file, expected); }); it("should return the URL when it's a unsupported URL", async function () { const url = "https://kodi.tv/"; + const options = { "depth": 0 }; + const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); - assert.strictEqual(file, url); + const file = await extract(new URL(url), options); + assert.strictEqual(file, expected); }); it("should return the URL when it's not a page HTML", async function () { const url = "https://kodi.tv/sites/default/themes/kodi/" + "logo-sbs.svg"; - const file = await extract(new URL(url), { "depth": 0 }); - assert.strictEqual(file, url); + const options = { "depth": 0 }; + const expected = url; + + const file = await extract(new URL(url), options); + assert.strictEqual(file, expected); }); it("should return the MP3 URL", async function () { const url = "https://fr.wikipedia.org/wiki/awesome.MP3"; + const options = { "depth": 0 }; + const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); - assert.strictEqual(file, url); + const file = await extract(new URL(url), options); + assert.strictEqual(file, expected); }); it("should return the AVI URL", async function () { const url = "http://example.org/video.avi"; + const options = { "depth": 0 }; + const expected = url; - const file = await extract(new URL(url), { "depth": 0 }); - assert.strictEqual(file, url); + const file = await extract(new URL(url), options); + assert.strictEqual(file, expected); }); }); });