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) self.setStreams(videoStreamID=videoStreamID, mtype=mtype)
def playMedia(self, media, **params): def playMedia(self, media, offset=0, **params):
""" Start playback of the specified media item. """ Start playback of the specified media item. See also:
Parameters: Parameters:
media (:class:`~plexapi.media.Media`): Media item to be played back (movie, music, photo). media (:class:`~plexapi.media.Media`): Media item to be played back (movie, music, photo).
**params (TYPE): Additional parameters to include in the request. Useful offset (int): Number of milliseconds at which to start playing with zero representing
to specify things such as offset, audio, or subtitle streams. 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: Raises:
:class:`~plexapi.exceptions.Unsupported`: When no PlexServer specified in this object. :class:`~plexapi.exceptions.Unsupported`: When no PlexServer specified in this object.
@ -410,6 +412,7 @@ class PlexClient(object):
'machineIdentifier': self.server.machineIdentifier, 'machineIdentifier': self.server.machineIdentifier,
'address': server_url[1].strip('/'), 'address': server_url[1].strip('/'),
'port': server_url[-1], 'port': server_url[-1],
'offset': offset,
'key': media.key, 'key': media.key,
'containerKey': '/playQueues/%s?window=100&own=1' % playqueue.playQueueID, 'containerKey': '/playQueues/%s?window=100&own=1' % playqueue.playQueueID,
}, **params)) }, **params))

View file

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

View file

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