remove bloat

This commit is contained in:
Ashley 2023-05-01 19:26:18 +00:00
parent a82ee1daf0
commit df21981d44

View file

@ -20,21 +20,13 @@ const fetcher = require("../libpoketube/libpoketube-fetcher.js");
const getColors = require("get-image-colors"); const getColors = require("get-image-colors");
const wiki = require("wikipedia"); const wiki = require("wikipedia");
const sqp = "-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBy_x4UUHLNDZtJtH0PXeQGoRFTgw";
const config = {
tubeApi: "https://inner-api.poketube.fun/api/",
invapi: "https://invid-api.poketube.fun/api/v1",
dislikes: "https://returnyoutubedislikeapi.com/votes?videoId=",
t_url: "https://t.poketube.fun/", // def matomo url
};
function initerr(args){
console.error("[LIBPT CORE ERROR]" + args)
}
// Util functions // Util functions
/*
* Api functions
*/
function getJson(str) { function getJson(str) {
try { try {
return JSON.parse(str); return JSON.parse(str);
@ -51,27 +43,19 @@ function checkUnexistingObject(obj) {
} }
} }
/*
* Api functions
*/
async function channel(id, cnt) {
if (id == null) return "Gib ID";
const videos = await fetch(
`${config.tubeApi}channel?id=${id}&tab=videos&continuation=${cnt || ""}`
)
.then((res) => res.text())
.then((xml) => getJson(toJson(xml)));
const about = await fetch(`${config.tubeApi}channel?id=${id}&tab=about`)
.then((res) => res.text())
.then((xml) => getJson(toJson(xml)));
return { videos, about };
}
const cache = {}; const cache = {};
const sqp = "-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBy_x4UUHLNDZtJtH0PXeQGoRFTgw";
const config = {
tubeApi: "https://inner-api.poketube.fun/api/",
invapi: "https://invid-api.poketube.fun/api/v1",
dislikes: "https://returnyoutubedislikeapi.com/votes?videoId=",
t_url: "https://t.poketube.fun/", // def matomo url
};
function initerr(args){
console.error("[LIBPT CORE ERROR]" + args)
}
async function video(v) { async function video(v) {
if (v == null) return "Gib ID"; if (v == null) return "Gib ID";
@ -82,8 +66,7 @@ async function video(v) {
return cache[v].result; return cache[v].result;
} }
let nightlyRes; var desc = "";
var desc = "";
try { try {
var inv_comments = await fetch(`${config.invapi}/comments/${v}`).then( var inv_comments = await fetch(`${config.invapi}/comments/${v}`).then(
@ -126,14 +109,10 @@ async function video(v) {
initerr("Error getting channel info", error); initerr("Error getting channel info", error);
var a = ""; var a = "";
} }
desc = a.Channel?.Contents?.ItemSection?.About?.Description; desc = a.Channel?.Contents?.ItemSection?.About?.Description;
const fe = await fetcher(v); const fe = await fetcher(v);
const nightlyJsonData = getJson(nightlyRes);
try { try {
const summary = await wiki const summary = await wiki
@ -177,17 +156,6 @@ async function video(v) {
} }
} }
async function search(query, cnt) {
if (query == null) return "Gib Query";
const data = await fetch(
`${config.tubeApi}search?query=${query}&continuation=${cnt || ""}`
)
.then((res) => res.text())
.then((xml) => getJson(toJson(xml)));
return data;
}
async function isvalidvideo(v) { async function isvalidvideo(v) {
if (v != "assets") { if (v != "assets") {
@ -198,8 +166,6 @@ async function isvalidvideo(v) {
} }
module.exports = { module.exports = {
search,
video, video,
isvalidvideo, isvalidvideo
channel,
}; };