From 84d7e753725fe53596e9180c4379a875a8a81f45 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 08:57:05 +0530 Subject: [PATCH] Fix getWatchSources slug matching after injectSourceSlugs mutation - Match slug against last segment of ep.id (after injectSourceSlugs) - Use rawPipeId + translateId to recover original decoded ID - Fixes 'Episode slug not found' error for all providers --- src/helpers/pipe.js | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/helpers/pipe.js b/src/helpers/pipe.js index e94b72c..11b1720 100644 --- a/src/helpers/pipe.js +++ b/src/helpers/pipe.js @@ -408,15 +408,20 @@ const getWatchSources = async (provider, anilistId, category, slug) => { const episodes = provData.episodes?.[category] || []; let targetId = null; - // NOTE: fetchRawEpisodes returns raw pipe IDs (e.g. "animedao:cowboy-bebop:1") - // Build the slug from the prefix and episode number to match against the URL slug + // NOTE: After injectSourceSlugs, ep.id becomes "watch/{provider}/{anilistId}/{category}/{prefix}-{number}" + // Match the slug portion (last segment after the final "/") against the input slug. + // Use rawPipeId to get the original decoded ID for the pipe sources call. for (const ep of episodes) { - const origId = ep.id || ""; - const prefix = origId.includes(":") ? origId.split(":")[0] : origId; - const generated = `${prefix}-${ep.number}`; + const idParts = (ep.id || "").split("/"); + const slugSuffix = idParts[idParts.length - 1]; - if (generated === slug) { - targetId = ep.id; // getSources expects decoded ID, it will base64url-encode + if (slugSuffix === slug) { + // Decode rawPipeId back to original pipe format (e.g. "animedao:witch-hat-atelier:1") + if (ep.rawPipeId) { + targetId = translateId(ep.rawPipeId); + } else { + targetId = ep.id; + } break; } }