mirror of
https://codeberg.org/ashley/poke
synced 2025-06-04 21:42:10 +00:00
Update src/libpoketube/init/pages-api.js
This commit is contained in:
parent
4b33b38e1f
commit
4acf840d80
@ -33,25 +33,28 @@ const innertube = require("../libpoketube-youtubei-objects.json");
|
|||||||
const { execSync } = require('child_process');
|
const { execSync } = require('child_process');
|
||||||
|
|
||||||
const verfull = "v24.1906-sho-MAJOR_UPDATE-stable-dev-nonLTS-git-MTcxODc5NDY3NQ==";
|
const verfull = "v24.1906-sho-MAJOR_UPDATE-stable-dev-nonLTS-git-MTcxODc5NDY3NQ==";
|
||||||
const versmol = "v24.1906-sho"
|
const versmol = "v24.1906-sho";
|
||||||
const branch = "dev/master";
|
const branch = "dev/master";
|
||||||
const codename = "sho";
|
const codename = "sho";
|
||||||
const versionnumber = "293";
|
const versionnumber = "293";
|
||||||
const relaseunixdate = "MTcxODc5NDY3NQ=="
|
const relaseunixdate = "MTcxODc5NDY3NQ==";
|
||||||
const updatequote = "pls fund vennie plush -Bims"
|
const updatequote = "pls fund vennie plush -Bims";
|
||||||
|
|
||||||
|
|
||||||
module.exports = function (app, config, renderTemplate) {
|
module.exports = function (app, config, renderTemplate) {
|
||||||
|
|
||||||
|
const headers = {
|
||||||
|
'User-Agent': config.useragent, // Set User-Agent from config
|
||||||
|
};
|
||||||
|
|
||||||
app.get("/vi/:v/:t", async function (req, res) {
|
app.get("/vi/:v/:t", async function (req, res) {
|
||||||
var url = `https://i.ytimg.com/vi/${req.params.v}/${req.params.t}`
|
var url = `https://i.ytimg.com/vi/${req.params.v}/${req.params.t}`;
|
||||||
|
|
||||||
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
app.get("/avatars/:v", async function (req, res) {
|
app.get("/avatars/:v", async function (req, res) {
|
||||||
@ -59,6 +62,7 @@ app.get("/avatars/:v", async function (req, res) {
|
|||||||
|
|
||||||
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
@ -69,32 +73,23 @@ app.get("/avatars/:v", async function (req, res) {
|
|||||||
|
|
||||||
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get("/avatars/ytc/:v", async function (req, res) {
|
app.get("/avatars/ytc/:v", async function (req, res) {
|
||||||
var url = `https://vid.puffyan.us/ggpht/ytc/${req.params.v.replace("ytc", "")}`;
|
var url = `https://vid.puffyan.us/ggpht/ytc/${req.params.v.replace("ytc", "")}`;
|
||||||
|
|
||||||
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
app.get("/api/search", async (req, res) => {
|
|
||||||
const query = req.query.query;
|
|
||||||
|
|
||||||
if (!query) {
|
|
||||||
return res.redirect("/");
|
|
||||||
}
|
|
||||||
return res.redirect(`/search?query=${query}`);
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/api/video/download", async function (req, res) {
|
app.get("/api/video/download", async function (req, res) {
|
||||||
var v = req.query.v;
|
var v = req.query.v;
|
||||||
|
|
||||||
@ -115,7 +110,10 @@ app.get("/avatars/:v", async function (req, res) {
|
|||||||
try {
|
try {
|
||||||
let url = `https://eu-proxy.poketube.fun/api/v1/captions/${id}?label=${l}`;
|
let url = `https://eu-proxy.poketube.fun/api/v1/captions/${id}?label=${l}`;
|
||||||
|
|
||||||
let f = await fetch(url);
|
let f = await fetch(url, {
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
|
});
|
||||||
|
|
||||||
const body = await f.text();
|
const body = await f.text();
|
||||||
|
|
||||||
res.send(body);
|
res.send(body);
|
||||||
@ -131,7 +129,9 @@ app.get("/avatars/:v", async function (req, res) {
|
|||||||
if (id) {
|
if (id) {
|
||||||
const apiUrl = `https://ryd-proxy.kavin.rocks/votes/${id}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
|
const apiUrl = `https://ryd-proxy.kavin.rocks/votes/${id}&hash=d0550b6e28c8f93533a569c314d5b4e2`;
|
||||||
|
|
||||||
const response = await fetch(apiUrl);
|
const response = await fetch(apiUrl, {
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
|
});
|
||||||
|
|
||||||
if (response.status === 400) {
|
if (response.status === 400) {
|
||||||
const error = await response.json();
|
const error = await response.json();
|
||||||
@ -224,48 +224,6 @@ app.get("/avatars/:v", async function (req, res) {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
app.use("/sb/i/:v/:imagePath/:img", async function (req, res) {
|
|
||||||
const { v, imagePath, img } = req.params;
|
|
||||||
const { sqp, xywh } = req.query;
|
|
||||||
const sighMatch = req.url.match(/&sigh=([^&#]+)/);
|
|
||||||
const sigh = sighMatch ? sighMatch[1] : undefined;
|
|
||||||
|
|
||||||
|
|
||||||
const url = `https://yt.miruku.cafe/sb/i/${v}/${imagePath}/${img}?sqp=${sqp}&sigh=${sigh}&xywh=${req.query.xywh}`;
|
|
||||||
|
|
||||||
try {
|
|
||||||
let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, {
|
|
||||||
method: req.method,
|
|
||||||
});
|
|
||||||
|
|
||||||
f.body.pipe(res);
|
|
||||||
console.log(url)
|
|
||||||
} catch (error) {
|
|
||||||
console.error("Error fetching image:", error);
|
|
||||||
res.status(500).send("Error fetching image");
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/api/storyboards", async (req, res) => {
|
|
||||||
const { fetch } = await import("undici");
|
|
||||||
|
|
||||||
const id = req.query.v;
|
|
||||||
const l = req.query.h;
|
|
||||||
|
|
||||||
try {
|
|
||||||
let url = `https://yt.miruku.cafe/api/v1/storyboards/${id}?width=320&height=180`;
|
|
||||||
|
|
||||||
let f = await fetch(url);
|
|
||||||
let body = await f.text();
|
|
||||||
|
|
||||||
body = body.replace(/#xywh=(\d+),(\d+),(\d+),(\d+)/g, (match, x, y, w, h) => {
|
|
||||||
return `&xywh=${x},${y},${w},${h}`;
|
|
||||||
});
|
|
||||||
|
|
||||||
res.send(body);
|
|
||||||
} catch {}
|
|
||||||
});
|
|
||||||
|
|
||||||
app.get("/feeds/videos.xml", async (req, res) => {
|
app.get("/feeds/videos.xml", async (req, res) => {
|
||||||
const id = req.query.channel_id;
|
const id = req.query.channel_id;
|
||||||
|
|
||||||
@ -273,6 +231,7 @@ app.use("/sb/i/:v/:imagePath/:img", async function (req, res) {
|
|||||||
|
|
||||||
let f = await modules.fetch(url, {
|
let f = await modules.fetch(url, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
@ -285,13 +244,12 @@ app.use("/sb/i/:v/:imagePath/:img", async function (req, res) {
|
|||||||
|
|
||||||
let f = await modules.fetch(url, {
|
let f = await modules.fetch(url, {
|
||||||
method: req.method,
|
method: req.method,
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
});
|
});
|
||||||
|
|
||||||
f.body.pipe(res);
|
f.body.pipe(res);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
app.get("/api/redirect", async (req, res) => {
|
app.get("/api/redirect", async (req, res) => {
|
||||||
const red_url = atob(req.query.u);
|
const red_url = atob(req.query.u);
|
||||||
|
|
||||||
@ -314,7 +272,9 @@ app.use("/sb/i/:v/:imagePath/:img", async function (req, res) {
|
|||||||
let latestCommitHash;
|
let latestCommitHash;
|
||||||
|
|
||||||
const invidious = await modules
|
const invidious = await modules
|
||||||
.fetch("https://invid-api.poketube.fun/bHj665PpYhUdPWuKPfZuQGoX/api/v1/stats")
|
.fetch("https://invid-api.poketube.fun/bHj665PpYhUdPWuKPfZuQGoX/api/v1/stats", {
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
|
})
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((txt) => getJson(txt));
|
.then((txt) => getJson(txt));
|
||||||
|
|
||||||
@ -335,7 +295,7 @@ execSync('git rev-list HEAD -n 1 --abbrev-commit', (error, stdout, stderr) => {
|
|||||||
pt_version: {
|
pt_version: {
|
||||||
version: versmol,
|
version: versmol,
|
||||||
version_full: verfull,
|
version_full: verfull,
|
||||||
commit: latestCommitHash
|
commit: latestCommitHash,
|
||||||
},
|
},
|
||||||
branch,
|
branch,
|
||||||
updatequote,
|
updatequote,
|
||||||
@ -374,7 +334,9 @@ execSync('git rev-list HEAD -n 1 --abbrev-commit', (error, stdout, stderr) => {
|
|||||||
try {
|
try {
|
||||||
const url = `https://raw.githubusercontent.com/ashley0143/poke/main/instances.json`;
|
const url = `https://raw.githubusercontent.com/ashley0143/poke/main/instances.json`;
|
||||||
|
|
||||||
let f = await fetch(url)
|
let f = await fetch(url, {
|
||||||
|
headers: headers, // Add headers to the fetch request
|
||||||
|
})
|
||||||
.then((res) => res.text())
|
.then((res) => res.text())
|
||||||
.then((json) => JSON.parse(json));
|
.then((json) => JSON.parse(json));
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user