add new protobufs for channels

This commit is contained in:
Ashley 2023-11-16 06:15:20 +00:00
parent 3171afa18f
commit f72c4d503f

View file

@ -22,6 +22,11 @@ const {
const sha384 = modules.hash; const sha384 = modules.hash;
/**
* Parses a string to JSON, returns null if parsing fails.
* @param {string} str - The input string to be parsed as JSON.
* @returns {Object|null} - The parsed JSON object or null if parsing fails.
*/
function getJson(str) { function getJson(str) {
try { try {
return JSON.parse(str); return JSON.parse(str);
@ -30,11 +35,24 @@ function getJson(str) {
} }
} }
/**
* Object representing base64-encoded protobuf values for channel tabs.
* @typedef {Object} ChannelTabs
* @property {string} community - Base64-encoded value for the community tab.
* @property {string} shorts - Base64-encoded value for the shorts tab.
* @property {string} videos - Base64-encoded value for the videos tab.
* @property {string} streams - Base64-encoded value for the streams tab.
*/
// see https://developers.google.com/youtube/v3/docs/channels/
const ChannelTabs = { const ChannelTabs = {
community: "Y29tbXVuaXR5", community: "Y29tbXVuaXR5",
shorts: "c2hvcnRz", shorts: "c2hvcnRz",
videos: "dmlkZW9z", videos: "dmlkZW9z",
streams: "c3RyZWFtcw==", streams: "c3RyZWFtcw==", // or "live"
channels:"Y2hhbm5lbHM=",
store:"c3RvcmU=",
released:"cmVsZWFzZWQ="
}; };
module.exports = function (app, config, renderTemplate) { module.exports = function (app, config, renderTemplate) {
@ -62,6 +80,10 @@ module.exports = function (app, config, renderTemplate) {
res.redirect(`/watch?v=${v}`); res.redirect(`/watch?v=${v}`);
}); });
app.get("/api/getchanneltabs", async function (req, res) {
res.json(ChannelTabs);
});
app.get("/search", async (req, res) => { app.get("/search", async (req, res) => {
const query = req.query.query; const query = req.query.query;