youtube: added support for live links

This commit is contained in:
wukko 2023-08-26 00:03:24 +06:00
parent b56edfc193
commit be21c86d89
3 changed files with 16 additions and 2 deletions

View file

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

View file

@ -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":

View file

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