mirror of
https://github.com/Shineii86/MiruroAPI.git
synced 2026-10-22 10:15:10 +00:00
fix: preserve rawPipeId for stream resolution + fix creatorInfo message overwrite + match slug against tail of episode ID
This commit is contained in:
+8
-7
@@ -174,6 +174,8 @@ const injectSourceSlugs = (data, anilistId) => {
|
|||||||
for (const ep of epList) {
|
for (const ep of epList) {
|
||||||
if (ep.id && ep.number) {
|
if (ep.id && ep.number) {
|
||||||
const origId = ep.id;
|
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
|
// NOTE: Take only the prefix before ":" for the slug
|
||||||
const prefix = origId.includes(":") ? origId.split(":")[0] : origId;
|
const prefix = origId.includes(":") ? origId.split(":")[0] : origId;
|
||||||
ep.id = `watch/${provName}/${anilistId}/${category}/${prefix}-${ep.number}`;
|
ep.id = `watch/${provName}/${anilistId}/${category}/${prefix}-${ep.number}`;
|
||||||
@@ -304,17 +306,16 @@ const getWatchSources = async (provider, anilistId, category, slug) => {
|
|||||||
const episodes = provData.episodes?.[category] || [];
|
const episodes = provData.episodes?.[category] || [];
|
||||||
let targetId = null;
|
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) {
|
for (const ep of episodes) {
|
||||||
const origId = ep.id || "";
|
if (ep.id) {
|
||||||
const prefix = origId.includes(":") ? origId.split(":")[0] : origId;
|
const epSlug = ep.id.split("/").pop();
|
||||||
const generated = `${prefix}-${ep.number}`;
|
if (epSlug === slug && ep.rawPipeId) {
|
||||||
|
targetId = ep.rawPipeId;
|
||||||
if (generated === slug) {
|
|
||||||
targetId = origId;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!targetId) throw new Error(`Episode slug '${slug}' not found for provider ${provider}`);
|
if (!targetId) throw new Error(`Episode slug '${slug}' not found for provider ${provider}`);
|
||||||
return getSources(targetId, provider, anilistId, category);
|
return getSources(targetId, provider, anilistId, category);
|
||||||
|
|||||||
@@ -58,7 +58,9 @@ const addCreatorInfo = (req, res, next) => {
|
|||||||
if (typeof data === "object" && data !== null && !data.creator) {
|
if (typeof data === "object" && data !== null && !data.creator) {
|
||||||
data = {
|
data = {
|
||||||
...data,
|
...data,
|
||||||
...creatorInfo,
|
creator: creatorInfo.creator,
|
||||||
|
github: creatorInfo.github,
|
||||||
|
telegram: creatorInfo.telegram,
|
||||||
timestamp: new Date().toLocaleString("en-IN", { timeZone: "Asia/Kolkata", hour12: true }),
|
timestamp: new Date().toLocaleString("en-IN", { timeZone: "Asia/Kolkata", hour12: true }),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user