Fix library sync crash on deleting episode with missing season

This commit is contained in:
croneter 2018-09-23 13:45:57 +02:00
parent cbcdc74a8c
commit 35d0f6a49d

View file

@ -1008,18 +1008,24 @@ class TVShows(Items):
# Season verification # Season verification
season = self.plex_db.getItem_byKodiId(parent_id, season = self.plex_db.getItem_byKodiId(parent_id,
v.KODI_TYPE_SEASON) v.KODI_TYPE_SEASON)
if not self.plex_db.getItem_byParentId(parent_id, if season is not None:
v.KODI_TYPE_EPISODE): if not self.plex_db.getItem_byParentId(parent_id,
# No episode left for season - so delete the season v.KODI_TYPE_EPISODE):
self.remove_season(parent_id) # No episode left for season - so delete the season
self.plex_db.removeItem(season[0]) self.remove_season(parent_id)
show = self.plex_db.getItem_byKodiId(season[1], self.plex_db.removeItem(season[0])
v.KODI_TYPE_SHOW) show = self.plex_db.getItem_byKodiId(season[1],
if not self.plex_db.getItem_byParentId(season[1], v.KODI_TYPE_SHOW)
v.KODI_TYPE_SEASON): if show is not None:
# No seasons for show left - so delete entire show if not self.plex_db.getItem_byParentId(season[1],
self.remove_show(season[1]) v.KODI_TYPE_SEASON):
self.plex_db.removeItem(show[0]) # No seasons for show left - so delete entire show
self.remove_show(season[1])
self.plex_db.removeItem(show[0])
else:
LOG.error('No show found in Plex DB for season %s', season)
else:
LOG.error('No season found in Plex DB!')
##### SEASON ##### ##### SEASON #####
elif kodi_type == v.KODI_TYPE_SEASON: elif kodi_type == v.KODI_TYPE_SEASON:
# Remove episodes, season, verify tvshow # Remove episodes, season, verify tvshow