From 9363f5481c60f2791643a5ade1b637e7b662c0d2 Mon Sep 17 00:00:00 2001 From: Ashley //// Date: Tue, 9 Apr 2024 17:57:47 +0000 Subject: [PATCH] use youtubei.js for comments --- src/libpoketube/libpoketube-core.js | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/libpoketube/libpoketube-core.js b/src/libpoketube/libpoketube-core.js index 31f5a809..09bd9707 100644 --- a/src/libpoketube/libpoketube-core.js +++ b/src/libpoketube/libpoketube-core.js @@ -11,6 +11,8 @@ const { curly } = require("node-libcurl"); const getdislikes = require("../libpoketube/libpoketube-dislikes.js"); const getColors = require("get-image-colors"); const config = require("../../config.json") +const { Innertube, UniversalCache } = require('youtubei.js'); + /** * Class representing PokeTube's core functionality. @@ -69,7 +71,8 @@ class InnerTubePokeVidious { async getYouTubeApiVideo(f, v, contentlang, contentregion) { const { fetch } = await import("undici"); - + const yt = await Innertube.create({ cache: new UniversalCache(false), generate_session_locally: true }); + if (v == null) return "Gib ID"; // Check if result is already cached @@ -81,8 +84,7 @@ class InnerTubePokeVidious { let desc = ""; try { - const [invComments, videoInfo, videoData] = await Promise.all([ - fetch(`${this.config.invapi}/comments/${v}?hl=${contentlang}®ion=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()), + const [videoInfo, videoData] = await Promise.all([ fetch(`${this.config.invapi}/videos/${v}?hl=${contentlang}®ion=${contentregion}&h=${btoa(Date.now())}`).then((res) => res.text()), curly .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 { json, video } = videoData;