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,6 +1008,7 @@ class TVShows(Items):
# Season verification
season = self.plex_db.getItem_byKodiId(parent_id,
v.KODI_TYPE_SEASON)
if season is not None:
if not self.plex_db.getItem_byParentId(parent_id,
v.KODI_TYPE_EPISODE):
# No episode left for season - so delete the season
@ -1015,11 +1016,16 @@ class TVShows(Items):
self.plex_db.removeItem(season[0])
show = self.plex_db.getItem_byKodiId(season[1],
v.KODI_TYPE_SHOW)
if show is not None:
if not self.plex_db.getItem_byParentId(season[1],
v.KODI_TYPE_SEASON):
# 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 #####
elif kodi_type == v.KODI_TYPE_SEASON:
# Remove episodes, season, verify tvshow