From 2de0c69c705c784023e7e1f0abd9706affc2a6a0 Mon Sep 17 00:00:00 2001 From: ashley Date: Mon, 6 Oct 2025 10:48:57 +0200 Subject: [PATCH] add createdAccountGetDate --- .../init/pages-channel-and-download.js | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/libpoketube/init/pages-channel-and-download.js b/src/libpoketube/init/pages-channel-and-download.js index 7b73eeca..2d6bbf64 100644 --- a/src/libpoketube/init/pages-channel-and-download.js +++ b/src/libpoketube/init/pages-channel-and-download.js @@ -227,6 +227,31 @@ function channelurlfixer(text) { const tab = req.query.tab; const cache = {}; +async function fetchChannelPublishedJSON(id) { + const url = `https://www.youtube.com/feeds/videos.xml?channel_id=${encodeURIComponent(id)}`; + const res = await fetch(url, { headers: { accept: "application/atom+xml" } }); + if (!res.ok) throw new Error(`HTTP ${res.status} for ${url}`); + + const xml = await res.text(); + const match = xml.match(/([^<]+)<\/published>/i); + if (!match) throw new Error("feed not found"); + + const iso = match[1].trim(); + const date = new Date(iso); + if (Number.isNaN(date.getTime())) throw new Error(`invalid date: ${iso}`); + + const published = new Intl.DateTimeFormat("en-GB", { + day: "numeric", + month: "long", + year: "numeric", + timeZone: "UTC" + }).format(date); + + return { ID: id, published }; +} + +const createdAccountGetDate = await fetchChannelPublishedJSON(ID); + const continuation = req.query.continuation ? `&continuation=${req.query.continuation}` : ""; @@ -352,6 +377,7 @@ function channelurlfixer(text) { stream, tj, c, + createdAccountGetDate, cinv, convert, turntomins,