Skip to content

Commit 37727a6

Browse files
committed
Add rate function to video
1 parent bd033a9 commit 37727a6

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

README.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,12 @@ Usage Examples
131131
print(playlist.title)
132132
133133
134+
.. code-block:: python
135+
136+
# Example 10: Rate Mr. Robot four stars.
137+
plex.library.section('TV Shows').get('Mr. Robot').rate(8.0)
138+
139+
134140
Running tests over PlexAPI
135141
--------------------------
136142

plexapi/video.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,13 @@ def markUnwatched(self):
7878
self._server.query(key)
7979
self.reload()
8080

81+
def rate(self, rate):
82+
""" Rate video. """
83+
key = '/:/rate?key=%s&identifier=com.plexapp.plugins.library&rating=%s' % (self.ratingKey, rate)
84+
85+
self._server.query(key)
86+
self.reload()
87+
8188
def _defaultSyncTitle(self):
8289
""" Returns str, default title for a new syncItem. """
8390
return self.title

tests/test_actions.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,3 +19,10 @@ def test_refresh_section(tvshows):
1919

2020
def test_refresh_video(movie):
2121
movie.refresh()
22+
23+
24+
def test_rate_movie(movie):
25+
oldrate = movie.userRating
26+
movie.rate(10.0)
27+
assert movie.userRating == 10.0, 'User rating 10.0 after rating five stars.'
28+
movie.rate(oldrate)

0 commit comments

Comments
 (0)