Add rate function to video

This commit is contained in:
Ty Hahn 2019-08-07 04:53:31 +09:00
parent bd033a9f7e
commit 37727a69ed
3 changed files with 20 additions and 0 deletions

View file

@ -131,6 +131,12 @@ Usage Examples
print(playlist.title)
.. code-block:: python
# Example 10: Rate Mr. Robot four stars.
plex.library.section('TV Shows').get('Mr. Robot').rate(8.0)
Running tests over PlexAPI
--------------------------

View file

@ -78,6 +78,13 @@ class Video(PlexPartialObject):
self._server.query(key)
self.reload()
def rate(self, rate):
""" Rate video. """
key = '/:/rate?key=%s&identifier=com.plexapp.plugins.library&rating=%s' % (self.ratingKey, rate)
self._server.query(key)
self.reload()
def _defaultSyncTitle(self):
""" Returns str, default title for a new syncItem. """
return self.title

View file

@ -19,3 +19,10 @@ def test_refresh_section(tvshows):
def test_refresh_video(movie):
movie.refresh()
def test_rate_movie(movie):
oldrate = movie.userRating
movie.rate(10.0)
assert movie.userRating == 10.0, 'User rating 10.0 after rating five stars.'
movie.rate(oldrate)