Code optimizations for PlaylistItem
This commit is contained in:
parent
95b469efb5
commit
a4526080db
1 changed files with 10 additions and 66 deletions
|
@ -151,21 +151,20 @@ class PlaylistItem(object):
|
||||||
force_transcode [bool] defaults to False
|
force_transcode [bool] defaults to False
|
||||||
"""
|
"""
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
self._id = None
|
self.id = None
|
||||||
self._plex_id = None
|
self._plex_id = None
|
||||||
self.plex_type = None
|
self.plex_type = None
|
||||||
self.plex_uuid = None
|
self.kodi_id = None
|
||||||
self._kodi_id = None
|
|
||||||
self.kodi_type = None
|
self.kodi_type = None
|
||||||
self.file = None
|
self.file = None
|
||||||
self.uri = None
|
self.uri = None
|
||||||
self.guid = None
|
self.guid = None
|
||||||
self.xml = None
|
self.xml = None
|
||||||
self.playmethod = None
|
self.playmethod = None
|
||||||
self._playcount = None
|
self.playcount = None
|
||||||
self._offset = None
|
self.offset = None
|
||||||
# If Plex video consists of several parts; part number
|
# If Plex video consists of several parts; part number
|
||||||
self._part = 0
|
self.part = 0
|
||||||
self.force_transcode = False
|
self.force_transcode = False
|
||||||
# Shall we ask user to resume this item?
|
# Shall we ask user to resume this item?
|
||||||
# None: ask user to resume
|
# None: ask user to resume
|
||||||
|
@ -179,62 +178,10 @@ class PlaylistItem(object):
|
||||||
|
|
||||||
@plex_id.setter
|
@plex_id.setter
|
||||||
def plex_id(self, value):
|
def plex_id(self, value):
|
||||||
if not isinstance(value, int) and value is not None:
|
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
|
||||||
self._plex_id = value
|
self._plex_id = value
|
||||||
|
|
||||||
@property
|
def __unicode__(self):
|
||||||
def id(self):
|
return ("{{"
|
||||||
return self._id
|
|
||||||
|
|
||||||
@id.setter
|
|
||||||
def id(self, value):
|
|
||||||
if not isinstance(value, int) and value is not None:
|
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
|
||||||
self._id = value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def kodi_id(self):
|
|
||||||
return self._kodi_id
|
|
||||||
|
|
||||||
@kodi_id.setter
|
|
||||||
def kodi_id(self, value):
|
|
||||||
if not isinstance(value, int) and value is not None:
|
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
|
||||||
self._kodi_id = value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def playcount(self):
|
|
||||||
return self._playcount
|
|
||||||
|
|
||||||
@playcount.setter
|
|
||||||
def playcount(self, value):
|
|
||||||
if not isinstance(value, int) and value is not None:
|
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
|
||||||
self._playcount = value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def offset(self):
|
|
||||||
return self._offset
|
|
||||||
|
|
||||||
@offset.setter
|
|
||||||
def offset(self, value):
|
|
||||||
if not isinstance(value, (int, float)) and value is not None:
|
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
|
||||||
self._offset = value
|
|
||||||
|
|
||||||
@property
|
|
||||||
def part(self):
|
|
||||||
return self._part
|
|
||||||
|
|
||||||
@part.setter
|
|
||||||
def part(self, value):
|
|
||||||
if not isinstance(value, int) and value is not None:
|
|
||||||
raise TypeError('Passed %s instead of int!' % type(value))
|
|
||||||
self._part = value
|
|
||||||
|
|
||||||
def __repr__(self):
|
|
||||||
answ = ("{{"
|
|
||||||
"'id': {self.id}, "
|
"'id': {self.id}, "
|
||||||
"'plex_id': {self.plex_id}, "
|
"'plex_id': {self.plex_id}, "
|
||||||
"'plex_type': '{self.plex_type}', "
|
"'plex_type': '{self.plex_type}', "
|
||||||
|
@ -248,13 +195,10 @@ class PlaylistItem(object):
|
||||||
"'playcount': {self.playcount}, "
|
"'playcount': {self.playcount}, "
|
||||||
"'offset': {self.offset}, "
|
"'offset': {self.offset}, "
|
||||||
"'force_transcode': {self.force_transcode}, "
|
"'force_transcode': {self.force_transcode}, "
|
||||||
"'part': {self.part}, ".format(self=self))
|
"'part': {self.part}".format(self=self))
|
||||||
answ = answ.encode('utf-8')
|
|
||||||
# etree xml.__repr__() could return string, not unicode
|
|
||||||
return answ + b"'xml': \"{self.xml}\"}}".format(self=self)
|
|
||||||
|
|
||||||
def __str__(self):
|
def __repr__(self):
|
||||||
return self.__repr__()
|
return self.__unicode__().encode('utf-8')
|
||||||
|
|
||||||
def plex_stream_index(self, kodi_stream_index, stream_type):
|
def plex_stream_index(self, kodi_stream_index, stream_type):
|
||||||
"""
|
"""
|
||||||
|
|
Loading…
Reference in a new issue