From a65138e575888fd711e8b8a4b85ac2bb50a345bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=CA=9C=C9=AA=C9=B4=E1=B4=87=C9=AA=20N=E1=B4=8F=E1=B4=9C?= =?UTF-8?q?=E1=B4=A2=E1=B4=87=C9=B4?= <157171073+Shineii86@users.noreply.github.com> Date: Thu, 25 Jun 2026 03:51:13 +0530 Subject: [PATCH] fix: preserve rawPipeId for stream resolution + fix creatorInfo message overwrite + match slug against tail of episode ID --- src/helpers/pipe.js | 17 +++++++++-------- src/middleware/creatorInfo.js | 4 +++- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/helpers/pipe.js b/src/helpers/pipe.js index fe15793..94e572a 100644 --- a/src/helpers/pipe.js +++ b/src/helpers/pipe.js @@ -174,6 +174,8 @@ const injectSourceSlugs = (data, anilistId) => { for (const ep of epList) { if (ep.id && ep.number) { const origId = ep.id; + // NOTE: Preserve the raw pipe ID so getWatchSources can resolve it later + ep.rawPipeId = origId; // NOTE: Take only the prefix before ":" for the slug const prefix = origId.includes(":") ? origId.split(":")[0] : origId; ep.id = `watch/${provName}/${anilistId}/${category}/${prefix}-${ep.number}`; @@ -304,15 +306,14 @@ const getWatchSources = async (provider, anilistId, category, slug) => { const episodes = provData.episodes?.[category] || []; let targetId = null; - // NOTE: Resolve slug back to the original pipe episode ID + // NOTE: Match slug against the tail of the episode ID (e.g. "animedao-1") for (const ep of episodes) { - const origId = ep.id || ""; - const prefix = origId.includes(":") ? origId.split(":")[0] : origId; - const generated = `${prefix}-${ep.number}`; - - if (generated === slug) { - targetId = origId; - break; + if (ep.id) { + const epSlug = ep.id.split("/").pop(); + if (epSlug === slug && ep.rawPipeId) { + targetId = ep.rawPipeId; + break; + } } } diff --git a/src/middleware/creatorInfo.js b/src/middleware/creatorInfo.js index 03e4619..719b0d5 100644 --- a/src/middleware/creatorInfo.js +++ b/src/middleware/creatorInfo.js @@ -58,7 +58,9 @@ const addCreatorInfo = (req, res, next) => { if (typeof data === "object" && data !== null && !data.creator) { data = { ...data, - ...creatorInfo, + creator: creatorInfo.creator, + github: creatorInfo.github, + telegram: creatorInfo.telegram, timestamp: new Date().toLocaleString("en-IN", { timeZone: "Asia/Kolkata", hour12: true }), }; }