use getChannelData() instead

This commit is contained in:
Ashley 2023-02-26 09:34:24 +00:00
parent 64845ec996
commit 0fa0ad977c

View file

@ -87,7 +87,9 @@ module.exports = function (app, config, renderTemplate) {
didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title); didYouMean = JSON.parse(searchJson.Search.Results.DynamicItem.Title);
} }
const summary = await wiki.summary(query + " ").then((summary_) => const summary = await wiki
.summary(query + " ")
.then((summary_) =>
summary_.title !== "Not found." ? summary_ : "none" summary_.title !== "Not found." ? summary_ : "none"
); );
@ -127,18 +129,17 @@ module.exports = function (app, config, renderTemplate) {
const getChannelData = async (url) => { const getChannelData = async (url) => {
try { try {
const response = await modules.fetch(url); return await modules.fetch(url).then((res) => res.text()).then((txt) => getJson(txt));
return JSON.parse(await response.text());
} catch (error) { } catch (error) {
console.error("Failed to fetch channel data from API:", error); console.error("Failed to fetch channel data from API:", error);
return null; return null;
} }
}; };
const tj = await modules.fetch(`https://inv.zzls.xyz/api/v1/channels/videos/${ID}/?sort_by=${req.query.sort_by || "newest"}` + continuation).then((res) => res.text()).then((txt) => getJson(txt)).catch(" ") const tj = await getChannelData(`https://inv.zzls.xyz/api/v1/channels/videos/${ID}/?sort_by=${req.query.sort_by || "newest"}` + continuation );
const shorts = await modules.fetch(`https://inv.zzls.xyz/api/v1/channels/${ID}/shorts?sort_by=${req.query.sort_by || "newest"}` + continuations).then((res) => res.text()).then((txt) => getJson(txt)).catch(" ") const shorts = await getChannelData(`https://inv.zzls.xyz/api/v1/channels/${ID}/shorts?sort_by=${req.query.sort_by || "newest"}` + continuations );
const stream = await modules.fetch(`https://inv.zzls.xyz/api/v1/channels/${ID}/streams?sort_by=${req.query.sort_by || "newest"}` + continuationl).then((res) => res.text()).then((txt) => getJson(txt)).catch(" ") const stream = await getChannelData(`https://inv.zzls.xyz/api/v1/channels/${ID}/streams?sort_by=${ req.query.sort_by || "newest"}` + continuationl );
const c = await modules.fetch(`https://inv.zzls.xyz/api/v1/channels/community/${ID}/`).then((res) => res.text()) .then((txt) => getJson(txt)); const c = await getChannelData(`https://inv.zzls.xyz/api/v1/channels/community/${ID}/`);
const summary = await wiki.summary(boutJson.Channel.Metadata.Name); const summary = await wiki.summary(boutJson.Channel.Metadata.Name);
const wikiSummary = summary.title !== "Not found." ? summary : "none"; const wikiSummary = summary.title !== "Not found." ? summary : "none";