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
This commit is contained in:
Sʜɪɴᴇɪ Nᴏᴜᴢᴇɴ
2026-06-25 08:57:05 +05:30
parent e35d934190
commit 84d7e75372
+12 -7
View File
@@ -408,15 +408,20 @@ const getWatchSources = async (provider, anilistId, category, slug) => {
const episodes = provData.episodes?.[category] || []; const episodes = provData.episodes?.[category] || [];
let targetId = null; let targetId = null;
// NOTE: fetchRawEpisodes returns raw pipe IDs (e.g. "animedao:cowboy-bebop:1") // NOTE: After injectSourceSlugs, ep.id becomes "watch/{provider}/{anilistId}/{category}/{prefix}-{number}"
// Build the slug from the prefix and episode number to match against the URL slug // 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) { for (const ep of episodes) {
const origId = ep.id || ""; const idParts = (ep.id || "").split("/");
const prefix = origId.includes(":") ? origId.split(":")[0] : origId; const slugSuffix = idParts[idParts.length - 1];
const generated = `${prefix}-${ep.number}`;
if (generated === slug) { if (slugSuffix === slug) {
targetId = ep.id; // getSources expects decoded ID, it will base64url-encode // 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; break;
} }
} }