mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-26 21:50:20 +00:00
Merge pull request #270 from tijder/patch-1
Function update timeline for base.py
This commit is contained in:
commit
f89b8b6966
2 changed files with 21 additions and 1 deletions
|
@ -566,6 +566,24 @@ class Playable(object):
|
|||
self._server.query(key)
|
||||
self.reload()
|
||||
|
||||
def updateTimeline(self, time, state='stopped', duration=None):
|
||||
""" Set the timeline progress for this video.
|
||||
|
||||
Parameters:
|
||||
time (int): milliseconds watched
|
||||
state (string): state of the video, default 'stopped'
|
||||
duration (int): duration of the item
|
||||
"""
|
||||
durationStr = '&duration='
|
||||
if duration != None:
|
||||
durationStr = durationStr + str(duration)
|
||||
else:
|
||||
durationStr = durationStr + str(self.duration)
|
||||
key = '/:/timeline?ratingKey=%s&key=%s&identifier=com.plexapp.plugins.library&time=%d&state=%s%s' % (self.ratingKey, self.key,
|
||||
time, state, durationStr)
|
||||
self._server.query(key)
|
||||
self.reload()
|
||||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Release(PlexObject):
|
||||
|
|
|
@ -284,6 +284,8 @@ def test_video_Episode_unmatch(episode, patched_http_call):
|
|||
def test_video_Episode_updateProgress(episode, patched_http_call):
|
||||
episode.updateProgress(10 * 60 * 1000) # 10 minutes.
|
||||
|
||||
def test_video_Episode_updateTimeline(episode, patched_http_call):
|
||||
episode.updateTimeline(10 * 60 * 1000, state='playing', duration=episode.duration) # 10 minutes.
|
||||
|
||||
def test_video_Episode_stop(episode, mocker, patched_http_call):
|
||||
mocker.patch.object(episode, 'session', return_value=list(mocker.MagicMock(id='hello')))
|
||||
|
|
Loading…
Reference in a new issue