From be21c86d89efe8a89f0dea05f77ba68a0b7bbb86 Mon Sep 17 00:00:00 2001 From: wukko Date: Sat, 26 Aug 2023 00:03:24 +0600 Subject: [PATCH] youtube: added support for live links --- package.json | 2 +- src/modules/processing/hostOverrides.js | 8 +++++++- src/test/tests.json | 8 ++++++++ 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 034ca7aa..4c075ad6 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "cobalt", "description": "save what you love", - "version": "7.1.2", + "version": "7.1.3", "author": "wukko", "exports": "./src/cobalt.js", "type": "module", diff --git a/src/modules/processing/hostOverrides.js b/src/modules/processing/hostOverrides.js index 211cd2af..11104bdb 100644 --- a/src/modules/processing/hostOverrides.js +++ b/src/modules/processing/hostOverrides.js @@ -3,10 +3,16 @@ export default function (inHost, inURL) { let url = String(inURL); switch(host) { + case "youtube": + if (url.startsWith("https://youtube.com/live/") || url.startsWith("https://www.youtube.com/")) { + url = url.split("?")[0].replace("www.", ""); + url = `https://youtube.com/watch?v=${url.replace("https://youtube.com/live/", "")}` + } + break; case "youtu": if (url.startsWith("https://youtu.be/")) { host = "youtube"; - url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}`; + url = `https://youtube.com/watch?v=${url.replace("https://youtu.be/", "")}` } break; case "vxtwitter": diff --git a/src/test/tests.json b/src/test/tests.json index 34155509..905f5c7e 100644 --- a/src/test/tests.json +++ b/src/test/tests.json @@ -465,6 +465,14 @@ "code": 200, "status": "stream" } + }, { + "name": "live link, defaults", + "url": "https://www.youtube.com/live/ENxZS6PUDuI?feature=shared", + "params": {}, + "expected": { + "code": 200, + "status": "stream" + } }, { "name": "inexistent video", "url": "https://youtube.com/watch?v=gnjuHYWGEW",