poke/src/libpoketube/libpoketube-video.js

75 lines
1.5 KiB
JavaScript
Raw Normal View History

2023-01-10 16:59:43 +01:00
/*
2023-09-13 22:06:04 +02: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 don't remove this comment while sharing this code
2023-02-25 18:48:15 +01:00
*/
2023-01-10 16:59:43 +01: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");
2023-09-13 22:06:04 +02:00
// Function to convert an array to an object, ignoring undefined values
function toObject(arr) {
return arr.reduce((acc, cur, i) => {
if (cur !== undefined) {
acc[i] = cur;
}
return acc;
}, {});
}
2023-01-10 16:59:43 +01:00
2023-09-13 22:06:04 +02:00
// Gets Invidious instances
const invInstanceList = [
2023-12-08 21:19:21 +01:00
"https://tube.kuylar.dev"
2023-09-13 22:06:04 +02:00
];
2023-01-10 16:59:43 +01:00
2023-09-13 22:06:04 +02:00
// Gets a random instance from the list
2023-09-14 17:53:17 +02:00
const instance =
invInstanceList[Math.floor(Math.random() * invInstanceList.length)];
2023-01-10 16:59:43 +01:00
2023-09-13 22:06:04 +02:00
let url;
2023-09-14 17:53:17 +02:00
if (instance.startsWith("https://")) {
url = instance;
2023-09-13 22:06:04 +02:00
} else {
url = "https://tube.kuylar.dev";
}
2023-09-13 22:06:04 +02:00
const isInvidiousURL = url === "https://tube.kuylar.dev" ? false : true;
const videoProxyObject = {
isInvidiousURL,
cacheBuster: "d0550b6e28c8f93533a569c314d5b4e2",
InvidiousPoketube: "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8",
2023-11-04 09:41:25 +01:00
url: url,
2023-11-27 20:50:39 +01:00
losslessurl: "https://lossless-proxy.poketube.fun"
2023-09-13 22:06:04 +02:00
};
module.exports = async function (video_id) {
2023-05-08 17:51:23 +02:00
return videoProxyObject;
2023-01-10 16:59:43 +01:00
};