1
Fork 0
mirror of https://codeberg.org/ashley/poke.git synced 2025-02-12 01:48:48 -05:00
poke/src/libpoketube/libpoketube-video.js

88 lines
2.2 KiB
JavaScript
Raw Normal View History

2023-01-10 15:59:43 +00:00
/*
PokeTube is a Free/Libre youtube front-end !
Copyright (C) 2021-2023 POKETUBE
This file is Licensed under LGPL-3.0-or-later. Poketube itself is GPL, Only this file is LGPL.
see a copy here:https://www.gnu.org/licenses/lgpl-3.0.txt
please dont remove this comment while sharing this code
2023-02-25 17:48:15 +00:00
*/
2023-01-10 15:59:43 +00:00
const {
fetcher,
core,
wiki,
musicInfo,
modules,
version,
initlog,
init,
} = require("./libpoketube-initsys.js");
const {
IsJsonString,
convert,
getFirstLine,
capitalizeFirstLetter,
turntomins,
getRandomInt,
getRandomArbitrary,
} = require("./ptutils/libpt-coreutils.js");
module.exports = async function (video_id) {
2023-02-25 17:48:15 +00:00
// function to convert an array to an object, ignoring undefined values
2023-01-10 15:59:43 +00:00
function toObject(arr) {
2023-02-25 17:48:15 +00:00
return arr.reduce((acc, cur, i) => {
if (cur !== undefined) {
acc[i] = cur;
}
return acc;
}, {});
2023-01-10 15:59:43 +00:00
}
// gets invidious instances
const invInstanceList = require("./invapi.json");
2023-01-10 15:59:43 +00:00
// gets random instances from the list
const instance =
invInstanceList[Math.floor(Math.random() * invInstanceList.length)];
2023-01-10 15:59:43 +00:00
let url;
if (instance[1].type != "https") {
2023-05-08 15:51:23 +00:00
url = "https://tube.kuylar.dev";
} else {
2023-03-19 18:00:32 +00:00
//replaces bad proxys (e.g the proxys that do not support media proxys, or the proxys that are down )
url = instance[1].uri
2023-03-19 18:00:32 +00:00
.replace("invidious.tiekoetter.com", "inv.odyssey346.dev")
2023-03-27 19:52:13 +00:00
.replace("invidious.slipfox.xyz", "y.com.sb")
.replace("yewtu.be", "y.com.sb")
2023-03-19 18:00:32 +00:00
.replace("iv.melmac.space", "inv.vern.cc")
.replace("yt.oelrichsgarcia.de", "y.com.sb")
2023-03-20 20:17:04 +00:00
.replace("yt.funami.tech", "y.com.sb")
2023-03-19 18:00:32 +00:00
.replace("invidious.lidarshield.cloud", "inv.odyssey346.dev")
.replace("vid.priv.au", "inv.vern.cc")
2023-05-08 15:51:23 +00:00
.replace("invidious.privacydev.net", "tube.kuylar.dev")
2023-03-19 18:00:32 +00:00
.replace("watch.thekitty.zone", "y.com.sb")
.replace("invidious.snopyta.org", "inv.odyssey346.dev")
2023-03-27 19:52:13 +00:00
.replace("invidious.weblibre.org", "y.com.sb")
2023-03-19 18:00:32 +00:00
.replace("invidious.sethforprivacy.com", "y.com.sb")
2023-02-05 12:30:17 +00:00
}
2023-05-08 15:51:23 +00:00
if(url == "https://tube.kuylar.dev") {
var isInvidiousURL = false
} else {
isInvidiousURL = true;
}
const videoProxyObject = {
isInvidiousURL,
url
}
return videoProxyObject;
2023-01-10 15:59:43 +00:00
};