Add offset as optional playMedia() argument; Document it; Clenaup old tests as its the only way to test client actions right now

This commit is contained in:
Michael Shepanski 2017-02-02 01:32:38 -05:00
parent 60ba091ecb
commit 0aac1156a1
3 changed files with 15 additions and 14 deletions

View file

@ -391,13 +391,15 @@ class PlexClient(object):
"""
self.setStreams(videoStreamID=videoStreamID, mtype=mtype)
def playMedia(self, media, **params):
""" Start playback of the specified media item.
def playMedia(self, media, offset=0, **params):
""" Start playback of the specified media item. See also:
Parameters:
media (:class:`~plexapi.media.Media`): Media item to be played back (movie, music, photo).
**params (TYPE): Additional parameters to include in the request. Useful
to specify things such as offset, audio, or subtitle streams.
offset (int): Number of milliseconds at which to start playing with zero representing
the beginning (default 0).
**params (dict): Optional additional parameters to include in the playback request. See
also: https://github.com/plexinc/plex-media-player/wiki/Remote-control-API#modified-commands
Raises:
:class:`~plexapi.exceptions.Unsupported`: When no PlexServer specified in this object.
@ -410,6 +412,7 @@ class PlexClient(object):
'machineIdentifier': self.server.machineIdentifier,
'address': server_url[1].strip('/'),
'port': server_url[-1],
'offset': offset,
'key': media.key,
'containerKey': '/playQueues/%s?window=100&own=1' % playqueue.playQueueID,
}, **params))

View file

@ -192,10 +192,8 @@ class Show(Video):
int, data.attrib.get('viewedLeafCount', NA))
self.year = utils.cast(int, data.attrib.get('year', NA))
if self.isFullObject(): # will be fixed with docs.
self.genres = [media.Genre(self.server, e)
for e in data if e.tag == media.Genre.TYPE]
self.roles = [media.Role(self.server, e)
for e in data if e.tag == media.Role.TYPE]
self.genres = [media.Genre(self.server, e) for e in data if e.tag == media.Genre.TYPE]
self.roles = [media.Role(self.server, e) for e in data if e.tag == media.Role.TYPE]
@property
def actors(self):

View file

@ -4,10 +4,10 @@
You can run this test suite with the following command:
>> python tests.py -u <USERNAME> -p <PASSWORD> -s <SERVERNAME>
"""
import argparse, os, pkgutil, sys, time, traceback
import argparse, pkgutil, sys, time, traceback
from os.path import dirname, abspath
sys.path.append(dirname(dirname(abspath(__file__))))
from plexapi import CONFIG
from plexapi.server import PlexServer
from plexapi.myplex import MyPlexAccount
from utils import log, itertests
@ -15,9 +15,9 @@ from utils import log, itertests
def runtests(args):
# Get username and password from environment
username = args.username or os.environ.get('PLEX_TEST_USERNAME')
password = args.password or os.environ.get('PLEX_TEST_PASSWORD')
resource = args.resource or os.environ.get('PLEX_TEST_RESOURCE')
username = args.username or CONFIG.get('authentication.username')
password = args.password or CONFIG.get('authentication.password')
resource = args.resource or CONFIG.get('authentication.resource')
# Register known tests
for loader, name, ispkg in pkgutil.iter_modules([dirname(abspath(__file__))]):
if name.startswith('test_'):