Fix deleting items after Plex library removal

This commit is contained in:
tomkat83 2017-02-01 18:55:22 +01:00
parent 38a6c1eae6
commit 524a36d9eb

View file

@ -863,21 +863,26 @@ class LibrarySync(Thread):
for view in self.old_views: for view in self.old_views:
plex_db.removeView(view) plex_db.removeView(view)
delete_items.extend(plex_db.get_items_by_viewid(view)) delete_items.extend(plex_db.get_items_by_viewid(view))
# All video removals are the same, so pick Movies() class delete_movies = []
with itemtypes.Movies() as movie: delete_tv = []
for item in (i for i in delete_items delete_music = []
if i['kodi_type'] == v.KODI_TYPE_MOVIE): for item in delete_items:
if item['kodi_type'] == v.KODI_TYPE_MOVIE:
delete_movies.append(item)
elif item['kodi_type'] in v.KODI_VIDEOTYPES:
delete_tv.append(item)
elif item['kodi_type'] in v.KODI_AUDIOTYPES:
delete_music.append(item)
for item in delete_movies:
with itemtypes.Movies() as movie:
movie.remove(item['plex_id']) movie.remove(item['plex_id'])
with itemtypes.TVShows() as tv: for item in delete_tv:
for item in (i for i in delete_items with itemtypes.TVShows() as tv:
if i['kodi_type'] in (v.KODI_TYPE_EPISODE,
v.KODI_TYPE_SEASON,
v.KODI_TYPE_SHOW)):
tv.remove(item['plex_id']) tv.remove(item['plex_id'])
# And for the music DB: # And for the music DB:
with itemtypes.Music() as music: for item in delete_music:
for item in (i for i in delete_items with itemtypes.Music() as music:
if i['kodi_type'] in v.KODI_AUDIOTYPES):
music.remove(item['plex_id']) music.remove(item['plex_id'])
def GetUpdatelist(self, xml, itemType, method, viewName, viewId): def GetUpdatelist(self, xml, itemType, method, viewName, viewId):