diff --git a/README.md b/README.md index 443d5ee0..273f0e3e 100644 --- a/README.md +++ b/README.md @@ -96,7 +96,7 @@ Once everythings installed, start your server with the following command: node server.js ``` -Congrats, Poketube should now be running on `localhost:3000`! +Congrats, Poketube should now be running on `localhost:6003`! ## PokeTube community! diff --git a/html/channel.ejs b/html/channel.ejs index 7bce5978..93ad01b5 100644 --- a/html/channel.ejs +++ b/html/channel.ejs @@ -553,8 +553,8 @@ margin-right: -79px; <% } %>
- - Channel Avatar + " class="avatar"> + " alt="Channel Avatar"> <% if (cinv?.authorVerified) { %> @@ -594,7 +594,7 @@ margin-right: -79px;

<% try { %> - <%- getFirstLine(desc).slice(0, 60) %> + <%- getFirstLine(cinv.description).slice(0, 60) %> <% } catch (error) { %> @@ -808,7 +808,7 @@ width: fit-content;

- <%-getFirstLine(desc)%> + <%-getFirstLine(cinv.description)%>

@@ -1019,7 +1019,7 @@ width: fit-content; <% tj.videos.forEach (x => { %> -
<%- turntomins(x.lengthSeconds) %>
+
<%- turntomins(x.lengthSeconds) %>
<%- x.title %> @@ -1067,7 +1067,7 @@ margin-left: 8em;" > <% shorts.videos.forEach (x => { %> - + @@ -1142,7 +1142,7 @@ margin-left: 8em;" > <% stream.videos.forEach (x => { %> -
<%- turntomins(x.lengthSeconds) %>
+
<%- turntomins(x.lengthSeconds) %>
<%- x.title %> @@ -1218,7 +1218,7 @@ margin-left: 8em;" >
<% } %> diff --git a/html/discover.ejs b/html/discover.ejs index 825f6bae..a1e5a0a2 100644 --- a/html/discover.ejs +++ b/html/discover.ejs @@ -493,10 +493,10 @@ Discover Popular videos on poketube! -
+
<% inv.forEach(x => { %> -
<%- turntomins(x.lengthSeconds) %>
+
<%- turntomins(x.lengthSeconds) %>
<%- x.title %> By <%- x.author %> diff --git a/html/download.ejs b/html/download.ejs index 9a765cc6..fb75fbe8 100644 --- a/html/download.ejs +++ b/html/download.ejs @@ -210,11 +210,11 @@ font-family:Ubuntu
<% if (!isMobile) { %> - + <% } %> <% if (isMobile) { %> - + <% } %>
@@ -267,7 +267,7 @@ font-family:Ubuntu

- gfhefdhgrdfhdfshfgddfsfdgdfsds gfhefdhgrdfhdfshfgddfsfdgdfsds + we dont see the videos that you are downloading :P

diff --git a/html/landing.ejs b/html/landing.ejs index 7f327f5a..881471e4 100644 --- a/html/landing.ejs +++ b/html/landing.ejs @@ -61,7 +61,8 @@

The Ultimate Privacy App

diff --git a/html/poketube.ejs b/html/poketube.ejs index 108bd76f..cb763daf 100644 --- a/html/poketube.ejs +++ b/html/poketube.ejs @@ -29,7 +29,7 @@ --> - + <% if (e === false) { %> @@ -40,7 +40,6 @@ - @@ -51,9 +50,11 @@ <% } %> + poketube.eventloader = this.eventloader load() + <%=inv_vid.title%> | PokeTube <% if(dm) { %> @@ -2265,7 +2316,7 @@ font-size: 13px;margin:0;padding:0;white-space: nowrap; @@ -2574,8 +2625,8 @@ More Epic options owo~
- - + "> +
<% if (!x.authorIsChannelOwner) { %> @@ -2682,11 +2733,11 @@ More Epic options owo~
<% if (!optout) { %> - <%=x.duration %> + <%=x.duration %> <% } %> <% if (optout) { %> - <%=x.duration %> + <%=x.duration %> <% } %>
diff --git a/html/search.ejs b/html/search.ejs index ed4b1d98..32ee96fc 100644 --- a/html/search.ejs +++ b/html/search.ejs @@ -507,7 +507,7 @@ Web <%=x.duration %>
{ let url; try { - url = new URL("https://" + req.originalUrl.slice(10)); + url = new URL("https://" + req.originalUrl.slice(8)); } catch (e) { console.log("==> Cannot parse URL: " + e); return res.status(400).send("Malformed URL"); @@ -93,7 +94,7 @@ const listener = (req, res) => { app.get("/", (req, res) => { var json = { status: "200", - version: "1.0.0", + version: "1.1.0", URL_WHITELIST, cache: "max-age-1848", }; @@ -101,42 +102,70 @@ app.get("/", (req, res) => { res.json(json); }); -const apiUrl = "https://returnyoutubedislikeapi.com/votes?videoId="; +const apiUrls = [ + "https://returnyoutubedislikeapi.com/votes?videoId=", + "https://prod-poketube.testing.poketube.fun/api?v=", + "https://ipv6-t.poketube.fun/api?v=" +]; // Define a cache object const cache = {}; app.get("/api", async (req, res) => { - if (req.query.hash && req.query.hash === "d0550b6e28c8f93533a569c314d5b4e2") { - try { - const cacheKey = req.query.v; +const { fetch } = await import("undici") - // Check if the result is already cached - if (cache[cacheKey] && Date.now() - cache[cacheKey].timestamp < 3600000) { - // If the cached result is less than 1 hour old, return it - const cachedData = cache[cacheKey].data; - const cachedDate = new Date(cache[cacheKey].timestamp); - return res.json({ data: cachedData, cachedDate }); + try { + const cacheKey = req.query.v; + + // Check if the result is already cached + if (cache[cacheKey] && Date.now() - cache[cacheKey].timestamp < 3600000) { + // If the cached result is less than 1 hour old, return it + const cachedData = cache[cacheKey].data; + const cachedDate = new Date(cache[cacheKey].timestamp); + return res.json(cachedData); + } + + // Initialize an array to store errors when trying different URLs + const errors = []; + + for (const apiUrl of apiUrls) { + try { + // Fetch data from the current URL + const engagement = await fetch(apiUrl + req.query.v).then((res) => res.json()); + + // Cache the result for future requests + cache[cacheKey] = { + data: engagement, + timestamp: Date.now(), + }; + + res.json(engagement); + return; // Exit the loop if successful + } catch (err) { + // Log the error for this URL and continue to the next URL + console.log(`Error fetching data from ${apiUrl}: ${err.message}`); + errors.push(err.message); + return ""; } + } - // If the result is not cached or is older than 1 hour, fetch it from the API - const engagement = await fetch(apiUrl + req.query.v).then((res) => - res.json() - ); - - // Cache the result for future requests - cache[cacheKey] = { - data: engagement, - timestamp: Date.now(), - }; - - res.json({ data: engagement, cachedDate: new Date() }); - } catch {} - } else { - return res.send("no hash query found"); + // If all URLs fail, return an error response + res.status(500).json({ error: "All API endpoints failed", errors }); + } catch (err) { + console.log(err); } }); +app.get("/bangs", async (req, res) => { + + let f = await fetch("https://lite.duckduckgo.com/lite/?q=" + req.query.q, { + method: req.method, + }); + + res.redirect(f); + +}); + app.all("/*", listener); -app.listen(3000, () => console.log("Listening on 0.0.0.0:3000")); +app.listen(6014, () => console.log("Listening on 0.0.0.0:6014")); \ No newline at end of file diff --git a/src/libpoketube/init/pages-api.js b/src/libpoketube/init/pages-api.js index 1ecaef89..1815785c 100644 --- a/src/libpoketube/init/pages-api.js +++ b/src/libpoketube/init/pages-api.js @@ -37,7 +37,39 @@ module.exports = function (app, config, renderTemplate) { app.get("/embed/:v", async function (req, res) { res.send("Disabled until further notice"); }); + + app.get("/vi/:v/:t", async function (req, res) { + var url = `https://yt.sudovanilla.com/vi/${req.params.v}/${req.params.t}` + + let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, { + method: req.method, + }); + f.body.pipe(res); + + }); + +app.get("/avatars/:v", async function (req, res) { + var url = `https://yt.sudovanilla.com/ggpht/${req.params.v}`; + + let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, { + method: req.method, + }); + + f.body.pipe(res); + }); + + app.get("/avatars/ytc/:v", async function (req, res) { + var url = `https://yt.sudovanilla.com/ggpht/ytc/${req.params.v.replace("ytc", "")}`; + + let f = await modules.fetch(url + `?cachefixer=${btoa(Date.now())}`, { + method: req.method, + }); + + f.body.pipe(res); + }); + + app.get("/api/search", async (req, res) => { const query = req.query.query; diff --git a/src/libpoketube/init/pages-video.js b/src/libpoketube/init/pages-video.js index 8347bb80..5424f87f 100644 --- a/src/libpoketube/init/pages-video.js +++ b/src/libpoketube/init/pages-video.js @@ -229,6 +229,10 @@ module.exports = function (app, config, renderTemplate) { if(inv_vid.genre === "Music") { var vidurl = u.losslessurl + } + + if(req.useragent.source.includes("Pardus")){ + var vidurl = "https://yt.sudovanilla.com" } let badges = ""; diff --git a/src/libpoketube/libpoketube-initsys.js b/src/libpoketube/libpoketube-initsys.js index 92fb6562..a2557964 100644 --- a/src/libpoketube/libpoketube-initsys.js +++ b/src/libpoketube/libpoketube-initsys.js @@ -43,7 +43,7 @@ function initlog(args) { * @param {string} [port="3000"] - The port to listen on */ function init(app, port) { - if (!port) port = "3000"; + if (!port) port = "6003"; try { app.listen(port, () => { initlog("Loading Poketube: success!" + " on port " + port);