mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
Add rate function to video
This commit is contained in:
parent
bd033a9f7e
commit
37727a69ed
3 changed files with 20 additions and 0 deletions
|
@ -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
|
||||
--------------------------
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in a new issue