1
0
Fork 0
mirror of https://github.com/sussy-code/smov.git synced 2024-12-29 16:07:40 +01:00

lightbulb moment! next episode logic

This commit is contained in:
James Hawkins 2021-08-07 19:43:21 +01:00
parent 9d21124379
commit 765749a956

View file

@ -154,27 +154,31 @@ export function SearchView() {
// begin next episode logic // begin next episode logic
} else { } else {
// we can't do next episode for movies! // we can't do next episode for movies!
if (!subselection.show) return; if (!subselection.show) continue;
let newShow = {};
// if the current season has a next episode, load it // if the current season has a next episode, load it
if (subselection.meta.episodes[subselection.show.season].includes(`${parseInt(subselection.show.episode) + 1}`)) { if (subselection.meta.episodes[subselection.show.season].includes(`${parseInt(subselection.show.episode) + 1}`)) {
subselection.show = { newShow.season = subselection.show.season;
season: subselection.show.season, newShow.episode = `${parseInt(subselection.show.episode) + 1}`;
episode: `${parseInt(subselection.show.episode) + 1}`
}
entry.percentageDone = 0; entry.percentageDone = 0;
// if the current season does not have a next epsiode, and the next season has a first episode, load that // if the current season does not have a next epsiode, and the next season has a first episode, load that
} else if (subselection.meta.episodes[`${parseInt(subselection.show.season) + 1}`][0]) { } else if (subselection.meta.episodes[`${parseInt(subselection.show.season) + 1}`][0]) {
subselection.show = { newShow.season = `${parseInt(subselection.show.season) + 1}`;
season: `${parseInt(subselection.show.season) + 1}`, newShow.episode = subselection.meta.episodes[`${parseInt(subselection.show.season) + 1}`][0];
episode: subselection.meta.episodes[`${parseInt(subselection.show.season) + 1}`][0] entry.percentageDone = 0;
// the next episode does not exist
} else {
continue;
} }
entry.percentageDone = 0; // assign the new episode and season data
} else { entry.data.show = { ...newShow };
return;
} // if the next episode exists, continue. we don't want to end up with duplicate data.
let nextEpisode = progressData?.[source]?.show?.[slug]?.[`${entry.data.show.season}-${entry.data.show.episode}`];
if (nextEpisode) continue;
newContinueWatching.push(entry); newContinueWatching.push(entry);
} }