mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
move update progress so we can use it on music.
This commit is contained in:
parent
f5af5d0e10
commit
807d833ceb
3 changed files with 20 additions and 14 deletions
|
@ -541,6 +541,22 @@ class Playable(object):
|
|||
key = '/status/sessions/terminate?sessionId=%s&reason=%s' % (self.session[0].id, quote_plus(reason))
|
||||
return self._server.query(key)
|
||||
|
||||
def updateProgress(self, time, state='stopped'):
|
||||
""" Set the watched progress for this video.
|
||||
|
||||
Note that setting the time to 0 will not work.
|
||||
Use `markWatched` or `markUnwatched` to achieve
|
||||
that goal.
|
||||
|
||||
Parameters:
|
||||
time (int): milliseconds watched
|
||||
state (string): state of the video, default 'stopped'
|
||||
"""
|
||||
key = '/:/progress?key=%s&identifier=com.plexapp.plugins.library&time=%d&state=%s' % (self.ratingKey,
|
||||
time, state)
|
||||
self._server.query(key)
|
||||
self.reload()
|
||||
|
||||
|
||||
@utils.registerPlexObject
|
||||
class Release(PlexObject):
|
||||
|
|
|
@ -77,20 +77,6 @@ class Video(PlexPartialObject):
|
|||
self._server.query(key)
|
||||
self.reload()
|
||||
|
||||
def updateProgress(self, time, state='stopped'):
|
||||
""" Set the watched progress for this video.
|
||||
|
||||
Note that setting the time to 0 will not work.
|
||||
Use `markWatched` or `markUnwatched` to achieve
|
||||
that goal.
|
||||
|
||||
Parameters:
|
||||
time (int): milliseconds watched
|
||||
state (string): state of the video, default 'stopped'
|
||||
"""
|
||||
key = '/:/progress?key=%s&identifier=com.plexapp.plugins.library&time=%d&state=%s' % (self.ratingKey, time, state)
|
||||
self._server.query(key)
|
||||
self.reload()
|
||||
|
||||
|
||||
@utils.registerPlexObject
|
||||
|
|
|
@ -281,6 +281,10 @@ def test_video_Episode_unmatch(episode, patched_http_call):
|
|||
episode.unmatch()
|
||||
|
||||
|
||||
def test_video_Episode_updateProgress(episode, patched_http_call):
|
||||
episode.updateProgress(10 * 60 * 1000) # 10 minutes.
|
||||
|
||||
|
||||
def test_video_Episode_stop(episode, mocker, patched_http_call):
|
||||
mocker.patch.object(episode, 'session', return_value=list(mocker.MagicMock(id='hello')))
|
||||
episode.stop(reason="It's past bedtime!")
|
||||
|
|
Loading…
Reference in a new issue