mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
commit
cdda56b548
5 changed files with 22 additions and 2 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
|
||||
--------------------------
|
||||
|
||||
|
|
|
@ -713,7 +713,7 @@ class ShowSection(LibrarySection):
|
|||
'guid', 'duplicate', 'label', 'show.title', 'show.year', 'show.userRating',
|
||||
'show.viewCount', 'show.lastViewedAt', 'show.actor', 'show.addedAt', 'episode.title',
|
||||
'episode.originallyAvailableAt', 'episode.resolution', 'episode.subtitleLanguage',
|
||||
'episode.unwatched', 'episode.addedAt','episode.userRating', 'episode.viewCount',
|
||||
'episode.unwatched', 'episode.addedAt', 'episode.userRating', 'episode.viewCount',
|
||||
'episode.lastViewedAt')
|
||||
ALLOWED_SORT = ('addedAt', 'lastViewedAt', 'originallyAvailableAt', 'titleSort',
|
||||
'rating', 'unwatched')
|
||||
|
|
|
@ -334,7 +334,7 @@ class PlexServer(PlexObject):
|
|||
up the result listing. For example: datetime.now() - timedelta(days=7)
|
||||
"""
|
||||
results, subresults = [], '_init'
|
||||
args = {'sort':'viewedAt:desc'}
|
||||
args = {'sort': 'viewedAt:desc'}
|
||||
if mindate:
|
||||
args['viewedAt>'] = int(mindate.timestamp())
|
||||
args['X-Plex-Container-Start'] = 0
|
||||
|
|
|
@ -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