Update src/libpoketube/init/pages-channel-and-download.js

This commit is contained in:
ashley 2024-07-15 20:21:59 +00:00
parent 7767c69ad1
commit 51a2f042c1

View file

@ -184,9 +184,7 @@ module.exports = function (app, config, renderTemplate) {
}); });
app.get("/web", async (req, res) => { app.get("/web", async (req, res) => {
res.redirect("/");
res.redirect("/");
}); });
app.get("/channel/", async (req, res) => { app.get("/channel/", async (req, res) => {
@ -260,7 +258,7 @@ module.exports = function (app, config, renderTemplate) {
const channelINVUrl = `${apiUrl}${ID}/`; const channelINVUrl = `${apiUrl}${ID}/`;
const pronoun = "no pronouns :c" const pronoun = "no pronouns :c";
var [tj, shorts, playlist, stream, c, cinv] = await Promise.all([ var [tj, shorts, playlist, stream, c, cinv] = await Promise.all([
getChannelData(channelUrl), getChannelData(channelUrl),
@ -283,8 +281,6 @@ module.exports = function (app, config, renderTemplate) {
} }
} }
cache[ID] = { cache[ID] = {
result: { result: {
tj, tj,
@ -309,29 +305,47 @@ module.exports = function (app, config, renderTemplate) {
); );
const dnoreplace = about?.Description.toString(); const dnoreplace = about?.Description.toString();
if (continuation) {
const currentAuthorId = String(cinv.authorId).trim();
const firstVideoAuthorId = String(tj.videos[0].authorId).trim();
if (currentAuthorId.localeCompare(firstVideoAuthorId) !== 0) {
res.status(400).send("Continuation does not match the channel :c");
}
}
let ChannelFirstVideoObject;
if (continuation) { if (tj && tj.videos && tj.videos.length > 0) {
const currentAuthorId = String(cinv.authorId).trim(); ChannelFirstVideoObject = await fetch(
const firstVideoAuthorId = String(tj.videos[0].authorId).trim(); `${config.invapi}/videos/${tj.videos[0].videoId}`
)
if (currentAuthorId.localeCompare(firstVideoAuthorId) !== 0) { .then((res) => res.text())
res.status(400).send("Continuation does not match the channel :c"); .then((txt) => JSON.parse(txt));
} } else if (shorts && shorts.videos && shorts.videos.length > 0) {
} ChannelFirstVideoObject = await fetch(
`${config.invapi}/videos/${shorts.videos[0].videoId}`
const ChannelFirstVideoObject = await fetch( )
`${config.invapi}/videos/${tj.videos[0].videoId}` .then((res) => res.text())
) .then((txt) => JSON.parse(txt));
.then((res) => res.text()) } else if (stream && stream.videos && stream.videos.length > 0) {
.then((txt) => getJson(txt)); ChannelFirstVideoObject = await fetch(
`${config.invapi}/videos/${stream.videos[0].videoId}`
)
.then((res) => res.text())
.then((txt) => JSON.parse(txt));
} else {
ChannelFirstVideoObject = {
subCountText: "0",
authorVerified: false,
};
}
renderTemplate(res, req, "channel.ejs", { renderTemplate(res, req, "channel.ejs", {
ID, ID,
tab, tab,
shorts, shorts,
firstVideo:ChannelFirstVideoObject, firstVideo: ChannelFirstVideoObject,
j: boutJson, j: boutJson,
sort: sort_by, sort: sort_by,
stream, stream,