Skip to content

Commit

Permalink
fix bug for plan to watch series.
Browse files Browse the repository at this point in the history
- reported by sloke123 on discord
  • Loading branch information
phanirithvij committed Mar 5, 2022
1 parent a1154c2 commit 1a44433
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions src/js/background/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -594,30 +594,31 @@ const startBgSync = async (signal) => {
// detect if a season has been fully watched
// if so need to be careful with sending too many requests to plex
console.log(`Show ${plxShow[0].title}`);
smkShow.seasons.forEach(async (smkSeason) => {
console.log(`Season ${smkSeason.number}`);
if ("total" in smkSeason) {
if (smkSeason.total == smkSeason.episodes.length) {
await __API__.plex.apis.markSeasonWatched({
...pconf,
seasonKey: smkSeason.ratingKey,
name: `${plxShow[0].title}: ${smkSeason.title}`,
});
return;
}
}
smkSeason.episodes.forEach(async (smkEpisode) => {
let plexEpkey = `${plxShow[0].ratingKey}-s${smkSeason.number}e${smkEpisode.number}`;
if (plexEpkey in episodeSeasonS0mE0nLut) {
await __API__.plex.apis.markEpisodeWatched({
...pconf,
episodeKey:
episodeSeasonS0mE0nLut[plexEpkey].ratingKey,
name: `${smkShow.show.title} S${smkSeason.number}E${smkEpisode.number}`,
});
if ("seasons" in smkShow)
smkShow.seasons.forEach(async (smkSeason) => {
console.log(`Season ${smkSeason.number}`);
if ("total" in smkSeason) {
if (smkSeason.total == smkSeason.episodes.length) {
await __API__.plex.apis.markSeasonWatched({
...pconf,
seasonKey: smkSeason.ratingKey,
name: `${plxShow[0].title}: ${smkSeason.title}`,
});
return;
}
}
smkSeason.episodes.forEach(async (smkEpisode) => {
let plexEpkey = `${plxShow[0].ratingKey}-s${smkSeason.number}e${smkEpisode.number}`;
if (plexEpkey in episodeSeasonS0mE0nLut) {
await __API__.plex.apis.markEpisodeWatched({
...pconf,
episodeKey:
episodeSeasonS0mE0nLut[plexEpkey].ratingKey,
name: `${smkShow.show.title} S${smkSeason.number}E${smkEpisode.number}`,
});
}
});
});
});
}
if (smkShow.user_rating) {
await __API__.plex.apis.rateMediaItem(
Expand Down

0 comments on commit 1a44433

Please sign in to comment.