diff --git a/src/core/scraper/onetv.js b/src/core/scraper/onetv.js
index c04407c4..1ec0ab00 100644
--- a/src/core/scraper/onetv.js
+++ b/src/core/scraper/onetv.js
@@ -15,14 +15,25 @@ const API_URL = "https://www.1tv.ru/playlist?single=true&video_id=";
/**
* Extrait les informations nécessaire pour lire une vidéo sur Kodi.
*
- * @param {URL} url L'URL d'une page embarquée de Первый канал (1tv.ru).
+ * @param {URL} url L'URL d'une page de Первый канал (1tv.ru).
+ * @param {HTMLDocument} doc Le contenu HTML de la page.
* @returns {Promise.} Une promesse contenant le lien du
* fichier ou null
.
*/
-const action = async function ({ pathname }) {
- const id = pathname.slice(7, pathname.indexOf(":"));
+const action = async function ({ pathname }, doc) {
+ let id;
+ if (pathname.startsWith("/embed/")) {
+ id = pathname.slice(7, pathname.indexOf(":"));
+ } else {
+ const meta = doc.querySelector(`meta[property="ya:ovs:content_id"]`);
+ if (null === meta) {
+ return null;
+ }
+ id = meta.content.split(":")[0];
+ }
+
const response = await fetch(API_URL + id);
const json = await response.json();
return "https:" + json[0].mbr[0].src;
};
-export const extract = matchPattern(action, "*://www.1tv.ru/embed/*");
+export const extract = matchPattern(action, "*://www.1tv.ru/*");
diff --git a/test/integration/scraper/onetv.js b/test/integration/scraper/onetv.js
index 83bbd322..09d79a69 100644
--- a/test/integration/scraper/onetv.js
+++ b/test/integration/scraper/onetv.js
@@ -38,6 +38,24 @@ describe("Scraper: Первый канал (1tv.ru)", function () {
assert.strictEqual(file, expected);
});
+ it("should return show URL from embed", async function () {
+ const url = "https://www.1tv.ru/embed/160522:12";
+ const options = { "depth": 0, "incognito": false };
+ const expected = {
+ "start": "https://balancer-vod.1tv.ru/video/multibitrate/video/",
+ "middle": "_Golos-",
+ "end": ".mp4"
+ };
+
+ const file = await extract(new URL(url), options);
+ assert.ok(file.startsWith(expected.start),
+ `"${file}".startsWith(expected.start) from ${url}`);
+ assert.ok(file.includes(expected.middle),
+ `"${file}".includes(expected.middle) from ${url}`);
+ assert.ok(file.endsWith(expected.end),
+ `"${file}".endsWith(expected.end) from ${url}`);
+ });
+
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 };
diff --git a/test/unit/core/scraper/onetv.js b/test/unit/core/scraper/onetv.js
index 367359f5..a0428ee6 100644
--- a/test/unit/core/scraper/onetv.js
+++ b/test/unit/core/scraper/onetv.js
@@ -10,9 +10,13 @@ describe("core/scraper/onetv.js", function () {
describe("extract()", function () {
it("should return null when there isn't Open Graph", async function () {
const url = "https://www.1tv.ru/foo.html";
+ const doc = new DOMParser().parseFromString(`
+
+