From 1a444335e01b1fe2b7de18bcdaf1b2864336fd36 Mon Sep 17 00:00:00 2001 From: phanirithvij Date: Sun, 6 Mar 2022 02:11:47 +0530 Subject: [PATCH] fix bug for plan to watch series. - reported by sloke123 on discord --- src/js/background/sync.js | 45 ++++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/js/background/sync.js b/src/js/background/sync.js index 47c61ab..f6904f8 100644 --- a/src/js/background/sync.js +++ b/src/js/background/sync.js @@ -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(