Detect Plex item deletion more reliably

This commit is contained in:
croneter 2017-09-08 12:34:13 +02:00
parent 1f0baf5128
commit 060bc6f1d1

View file

@ -1240,13 +1240,25 @@ class LibrarySync(Thread):
# movie or episode) # movie or episode)
continue continue
typus = v.PLEX_TYPE_FROM_WEBSOCKET[int(item['type'])] typus = v.PLEX_TYPE_FROM_WEBSOCKET[int(item['type'])]
if typus == v.PLEX_TYPE_CLIP:
# No need to process extras or trailers
continue
status = int(item['state']) status = int(item['state'])
if status == 9 or (typus in (v.PLEX_TYPE_MOVIE, if status == 9:
v.PLEX_TYPE_EPISODE, # Immediately and always process deletions (as the PMS will
v.PLEX_TYPE_SONG) and status == 5): # send additional message with other codes)
# Only process deleted items OR movies, episodes, tracks/songs self.itemsToProcess.append({
'state': status,
'type': typus,
'ratingKey': str(item['itemID']),
'timestamp': getUnixTimestamp(),
'attempt': 0
})
elif typus in (v.PLEX_TYPE_MOVIE,
v.PLEX_TYPE_EPISODE,
v.PLEX_TYPE_SONG) and status == 5:
plex_id = str(item['itemID']) plex_id = str(item['itemID'])
# Have we already added this element? # Have we already added this element for processing?
for existingItem in self.itemsToProcess: for existingItem in self.itemsToProcess:
if existingItem['ratingKey'] == plex_id: if existingItem['ratingKey'] == plex_id:
break break