diff --git a/mediafusion/mediafusion.js b/mediafusion/mediafusion.js index cc3c8b1..632799e 100644 --- a/mediafusion/mediafusion.js +++ b/mediafusion/mediafusion.js @@ -1,4 +1,3 @@ - // Settings start const preferedQualityOption = "Auto"; // ["Auto", "2160p", "1080p", "720p", "480p"] const debridService = "realdebrid"; // ["realdebrid", "alldebrid", "premiumize", "torbox", "debridlink"] @@ -96,19 +95,31 @@ async function extractEpisodes(ID) { const videos = data.meta.videos || []; + const shouldAdjust = videos.length > 0 && videos[0].season === 0; + let currentSeason = 0; let episodeCounter = 0; for (const video of videos) { - if (video.season !== currentSeason) { - currentSeason = video.season; + const adjustedSeason = shouldAdjust ? video.season + 1 : video.season; + if (adjustedSeason !== currentSeason) { + currentSeason = adjustedSeason; episodeCounter = 0; } episodeCounter++; + let adjustedId = video.id || ""; + if (adjustedId && shouldAdjust) { + const idParts = adjustedId.split(':'); + if (idParts.length === 3) { + idParts[1] = String(adjustedSeason); + adjustedId = idParts.join(':'); + } + } + results.push({ - href: "TV: " + (video.id || ""), + href: "TV: " + adjustedId, number: episodeCounter }); }