add createdAccountGetDate

This commit is contained in:
ashley 2025-10-06 10:48:57 +02:00
parent 15d069a0b8
commit 2de0c69c70

View File

@ -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(/<feed[\s\S]*?<published>([^<]+)<\/published>/i);
if (!match) throw new Error("feed <published> 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,