Skip to content

Commit 807d833

Browse files
committed
move update progress so we can use it on music.
1 parent f5af5d0 commit 807d833

File tree

3 files changed

+20
-14
lines changed

3 files changed

+20
-14
lines changed

plexapi/base.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -541,6 +541,22 @@ def stop(self, reason=''):
541541
key = '/status/sessions/terminate?sessionId=%s&reason=%s' % (self.session[0].id, quote_plus(reason))
542542
return self._server.query(key)
543543

544+
def updateProgress(self, time, state='stopped'):
545+
""" Set the watched progress for this video.
546+
547+
Note that setting the time to 0 will not work.
548+
Use `markWatched` or `markUnwatched` to achieve
549+
that goal.
550+
551+
Parameters:
552+
time (int): milliseconds watched
553+
state (string): state of the video, default 'stopped'
554+
"""
555+
key = '/:/progress?key=%s&identifier=com.plexapp.plugins.library&time=%d&state=%s' % (self.ratingKey,
556+
time, state)
557+
self._server.query(key)
558+
self.reload()
559+
544560

545561
@utils.registerPlexObject
546562
class Release(PlexObject):

plexapi/video.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -77,20 +77,6 @@ def markUnwatched(self):
7777
self._server.query(key)
7878
self.reload()
7979

80-
def updateProgress(self, time, state='stopped'):
81-
""" Set the watched progress for this video.
82-
83-
Note that setting the time to 0 will not work.
84-
Use `markWatched` or `markUnwatched` to achieve
85-
that goal.
86-
87-
Parameters:
88-
time (int): milliseconds watched
89-
state (string): state of the video, default 'stopped'
90-
"""
91-
key = '/:/progress?key=%s&identifier=com.plexapp.plugins.library&time=%d&state=%s' % (self.ratingKey, time, state)
92-
self._server.query(key)
93-
self.reload()
9480

9581

9682
@utils.registerPlexObject

tests/test_video.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -281,6 +281,10 @@ def test_video_Episode_unmatch(episode, patched_http_call):
281281
episode.unmatch()
282282

283283

284+
def test_video_Episode_updateProgress(episode, patched_http_call):
285+
episode.updateProgress(10 * 60 * 1000) # 10 minutes.
286+
287+
284288
def test_video_Episode_stop(episode, mocker, patched_http_call):
285289
mocker.patch.object(episode, 'session', return_value=list(mocker.MagicMock(id='hello')))
286290
episode.stop(reason="It's past bedtime!")

0 commit comments

Comments
 (0)