use youtubei.js for comments

This commit is contained in:
Ashley //// 2024-04-09 17:57:47 +00:00
parent a4ab2adcc5
commit 9363f5481c

View file

@ -11,6 +11,8 @@ 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');
/** /**
* Class representing PokeTube's core functionality. * Class representing PokeTube's core functionality.
@ -69,7 +71,8 @@ class InnerTubePokeVidious {
async getYouTubeApiVideo(f, v, contentlang, contentregion) { async getYouTubeApiVideo(f, v, contentlang, contentregion) {
const { fetch } = await import("undici"); const { fetch } = await import("undici");
const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true });
if (v == null) return "Gib ID"; if (v == null) return "Gib ID";
// Check if result is already cached // Check if result is already cached
@ -81,8 +84,7 @@ class InnerTubePokeVidious {
let desc = ""; let desc = "";
try { try {
const [invComments, videoInfo, videoData] = await Promise.all([ const [videoInfo, videoData] = await Promise.all([
fetch(`${this.config.invapi}/comments/${v}?hl=${contentlang}&region=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()),
fetch(`${this.config.invapi}/videos/${v}?hl=${contentlang}&region=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()), fetch(`${this.config.invapi}/videos/${v}?hl=${contentlang}&region=${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}`, {
@ -95,7 +97,9 @@ class InnerTubePokeVidious {
}), }),
]); ]);
const comments = await this.getJson(invComments);
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;