mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
Small change to the repr and add test.
This commit is contained in:
parent
881a4fc659
commit
d7c215b119
3 changed files with 15 additions and 8 deletions
|
@ -706,9 +706,9 @@ class Marker(PlexObject):
|
|||
|
||||
def __repr__(self):
|
||||
name = self._clean(self.firstAttr('type'))
|
||||
start = utils.millisecondToHuman(self._clean(self.firstAttr('start')))
|
||||
end = utils.millisecondToHuman(self._clean(self.firstAttr('end')))
|
||||
return '<%s>' % ':'.join([p for p in [self.__class__.__name__, name, start, end] if p])
|
||||
start = utils.millisecondToHumanstr(self._clean(self.firstAttr('start')))
|
||||
end = utils.millisecondToHumanstr(self._clean(self.firstAttr('end')))
|
||||
return '<%s:%s %s - %s>' % (self.__class__.__name__, name, start, end)
|
||||
|
||||
def _loadData(self, data):
|
||||
self._data = data
|
||||
|
|
|
@ -204,16 +204,17 @@ def toDatetime(value, format=None):
|
|||
return value
|
||||
|
||||
|
||||
def millisecondToHuman(milliseconds):
|
||||
def millisecondToHumanstr(milliseconds):
|
||||
""" Returns human readable time duration from milliseconds.
|
||||
HH:MM:SS
|
||||
HH:MM:SS:MMMM
|
||||
|
||||
Parameters:
|
||||
milliseconds (str,int): time duration in milliseconds.
|
||||
"""
|
||||
_milliseconds = cast(int, milliseconds)
|
||||
hhmmsssm = timedelta(milliseconds=_milliseconds)
|
||||
return str(hhmmsssm).split(".")[0]
|
||||
milliseconds = int(milliseconds)
|
||||
r = datetime.datetime.utcfromtimestamp(milliseconds / 1000)
|
||||
f = r.strftime("%H:%M:%S.%f")
|
||||
return f[:-2]
|
||||
|
||||
|
||||
def toList(value, itemcast=None, delim=','):
|
||||
|
|
|
@ -76,3 +76,9 @@ def test_utils_download(plex, episode):
|
|||
assert utils.download(
|
||||
episode.thumbUrl, plex._token, filename=episode.title, mocked=True
|
||||
)
|
||||
|
||||
|
||||
|
||||
def test_millisecondToHumanstr():
|
||||
res = utils.millisecondToHumanstr(1000)
|
||||
assert res == "00:00:01:0000"
|
||||
|
|
Loading…
Reference in a new issue