Merge pull request #270 from tijder/patch-1

Function update timeline for base.py
This commit is contained in:
Hellowlol 2018-06-27 20:51:45 +02:00 committed by GitHub
commit f89b8b6966
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 21 additions and 1 deletions

View file

@ -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):

View file

@ -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')))