Skip to content

best way to save what you love

youtube: added support for live links

wukkobe21c86d89ef
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",