mirror of
https://codeberg.org/ashley/poke.git
synced 2024-11-10 07:38:24 +01:00
fix issues
This commit is contained in:
parent
f593fbd876
commit
72f2c1b862
1 changed files with 75 additions and 91 deletions
|
@ -10,8 +10,9 @@ const { toJson } = require("xml2json");
|
||||||
const { curly } = require("node-libcurl");
|
const { curly } = require("node-libcurl");
|
||||||
const getdislikes = require("../libpoketube/libpoketube-dislikes.js");
|
const getdislikes = require("../libpoketube/libpoketube-dislikes.js");
|
||||||
const getColors = require("get-image-colors");
|
const getColors = require("get-image-colors");
|
||||||
const config = require("../../config.json");
|
const config = require("../../config.json")
|
||||||
const { Innertube, UniversalCache } = require("youtubei.js");
|
const { Innertube, UniversalCache } = require('youtubei.js');
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class representing PokeTube's core functionality.
|
* Class representing PokeTube's core functionality.
|
||||||
|
@ -30,11 +31,10 @@ class InnerTubePokeVidious {
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.cache = {};
|
this.cache = {};
|
||||||
this.language = "hl=en-US";
|
this.language = "hl=en-US";
|
||||||
this.apikey = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8";
|
this.apikey = "AIzaSyAO_FJ2SlqU8Q4STEHLGCilw_Y9_11qcW8"
|
||||||
this.INNERTUBE_CONTEXT_CLIENT_VERSION = "1";
|
this.INNERTUBE_CONTEXT_CLIENT_VERSION = "1"
|
||||||
this.region = "region=US";
|
this.region = "region=US";
|
||||||
this.sqp =
|
this.sqp = "-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBy_x4UUHLNDZtJtH0PXeQGoRFTgw";
|
||||||
"-oaymwEbCKgBEF5IVfKriqkDDggBFQAAiEIYAXABwAEG&rs=AOn4CLBy_x4UUHLNDZtJtH0PXeQGoRFTgw";
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -69,26 +69,9 @@ class InnerTubePokeVidious {
|
||||||
* @returns {Promise<object>} Promise resolving to the video information.
|
* @returns {Promise<object>} Promise resolving to the video information.
|
||||||
*/
|
*/
|
||||||
async getYouTubeApiVideo(f, v, contentlang, contentregion) {
|
async getYouTubeApiVideo(f, v, contentlang, contentregion) {
|
||||||
/**
|
|
||||||
* Fetch data from the specified URL with the given headers.
|
|
||||||
* @param {string} url - The URL to fetch data from.
|
|
||||||
* @param {Object} headers - The headers to include in the fetch request.
|
|
||||||
* @returns {Promise<string>} A promise that resolves to the text content of the response.
|
|
||||||
*/
|
|
||||||
async function fetchData(url, headers) {
|
|
||||||
/**
|
|
||||||
* @type {Response}
|
|
||||||
*/
|
|
||||||
const response = await fetch(url, { headers });
|
|
||||||
|
|
||||||
return response.text();
|
|
||||||
}
|
|
||||||
|
|
||||||
const { fetch } = await import("undici");
|
const { fetch } = await import("undici");
|
||||||
const yt = await Innertube.create({
|
const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true });
|
||||||
cache: new UniversalCache(false),
|
|
||||||
generate_session_locally: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
if (v == null) return "Gib ID";
|
if (v == null) return "Gib ID";
|
||||||
|
|
||||||
|
@ -102,7 +85,7 @@ class InnerTubePokeVidious {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const [videoInfo, videoData] = await Promise.all([
|
const [videoInfo, videoData] = await Promise.all([
|
||||||
fetchData(`${this.config.invapi}/videos/${v}?hl=${contentlang}®ion=${contentregion}&h=${btoa(Date.now())}`),
|
fetch(`${this.config.invapi}/videos/${v}?hl=${contentlang}®ion=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()),
|
||||||
curly
|
curly
|
||||||
.get(`${this.config.tubeApi}video?v=${v}`, {
|
.get(`${this.config.tubeApi}video?v=${v}`, {
|
||||||
httpHeader: Object.entries(headers).map(([k, v]) => `${k}: ${v}`),
|
httpHeader: Object.entries(headers).map(([k, v]) => `${k}: ${v}`),
|
||||||
|
@ -114,12 +97,13 @@ class InnerTubePokeVidious {
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
|
|
||||||
|
|
||||||
const comments = await yt.getComments(v);
|
const comments = await yt.getComments(v);
|
||||||
|
|
||||||
const vid = await this.getJson(videoInfo);
|
const vid = await this.getJson(videoInfo);
|
||||||
const { json, video } = videoData;
|
const { json, video } = videoData;
|
||||||
|
|
||||||
var channel_uploads = {};
|
var channel_uploads = { };
|
||||||
if (f == "true") {
|
if (f == "true") {
|
||||||
channel_uploads = await fetch(
|
channel_uploads = await fetch(
|
||||||
`${this.config.invapi}/channels/${vid.authorId}?hl=${contentlang}®ion=${contentregion}`
|
`${this.config.invapi}/channels/${vid.authorId}?hl=${contentlang}®ion=${contentregion}`
|
||||||
|
@ -165,8 +149,11 @@ class InnerTubePokeVidious {
|
||||||
this.initError("Error getting video", error);
|
this.initError("Error getting video", error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {}
|
} catch {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Check if a video ID is valid.
|
* Check if a video ID is valid.
|
||||||
|
@ -195,10 +182,7 @@ class InnerTubePokeVidious {
|
||||||
const pokeTubeApiCore = new InnerTubePokeVidious({
|
const pokeTubeApiCore = new InnerTubePokeVidious({
|
||||||
tubeApi: "https://inner-api.poketube.fun/api/",
|
tubeApi: "https://inner-api.poketube.fun/api/",
|
||||||
invapi: "https://invid-api.poketube.fun/api/v1",
|
invapi: "https://invid-api.poketube.fun/api/v1",
|
||||||
invapi_alt:
|
invapi_alt: config.proxylocation === "EU" ? "https://invid-api.poketube.fun/api/v1" : "https://iv.ggtyler.dev/api/v1",
|
||||||
config.proxylocation === "EU"
|
|
||||||
? "https://invid-api.poketube.fun/api/v1"
|
|
||||||
: "https://iv.ggtyler.dev/api/v1",
|
|
||||||
dislikes: "https://returnyoutubedislikeapi.com/votes?videoId=",
|
dislikes: "https://returnyoutubedislikeapi.com/votes?videoId=",
|
||||||
t_url: "https://t.poketube.fun/",
|
t_url: "https://t.poketube.fun/",
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue