Enable playqueue elements comparison

This commit is contained in:
croneter 2019-04-13 13:05:52 +02:00
parent fe52efd88e
commit b11ca48294

View file

@ -149,6 +149,11 @@ class Playlist_Item(object):
offset = None [int] the item's view offset UPON START in Plex time offset = None [int] the item's view offset UPON START in Plex time
part = 0 [int] part number if Plex video consists of mult. parts part = 0 [int] part number if Plex video consists of mult. parts
force_transcode [bool] defaults to False force_transcode [bool] defaults to False
Playlist_items compare as equal, if they
- have the same plex_id
- OR: have the same kodi_id AND kodi_type
- OR: have the same file
""" """
def __init__(self): def __init__(self):
self._id = None self._id = None
@ -168,6 +173,21 @@ class Playlist_Item(object):
self._part = 0 self._part = 0
self.force_transcode = False self.force_transcode = False
def __eq__(self, item):
if self.plex_id is not None and item.plex_id is not None:
return self.plex_id == item.plex_id
elif (self.kodi_id is not None and item.kodi_id is not None and
self.kodi_type and item.kodi_type):
return (self.kodi_id == item.kodi_id and
self.kodi_type == item.kodi_type)
elif self.file and item.file:
return self.file == item.file
raise RuntimeError('playlist items not fully defined: %s, %s' %
(self, item))
def __ne__(self, item):
return not self == item
@property @property
def plex_id(self): def plex_id(self):
return self._plex_id return self._plex_id