mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-22 22:17:58 +01:00
remove bloat
This commit is contained in:
parent
a82ee1daf0
commit
df21981d44
1 changed files with 19 additions and 53 deletions
|
@ -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,7 +66,6 @@ async function video(v) {
|
||||||
return cache[v].result;
|
return cache[v].result;
|
||||||
}
|
}
|
||||||
|
|
||||||
let nightlyRes;
|
|
||||||
var desc = "";
|
var desc = "";
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
@ -127,13 +110,9 @@ async function video(v) {
|
||||||
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,
|
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue