mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 14:14:19 +00:00
Only pass stream object to function
This commit is contained in:
parent
1c95e7165c
commit
5270395b3a
1 changed files with 18 additions and 22 deletions
|
@ -125,44 +125,40 @@ class MediaPart(PlexObject):
|
|||
""" Returns a list of :class:`~plexapi.media.SubtitleStream` objects in this MediaPart. """
|
||||
return [stream for stream in self.streams if stream.streamType == SubtitleStream.STREAMTYPE]
|
||||
|
||||
def setDefaultAudioStream(self, stream=None, streamID=None):
|
||||
def setDefaultAudioStream(self, stream):
|
||||
""" Set the default :class:`~plexapi.media.AudioStream` for this MediaPart.
|
||||
|
||||
Parameters:
|
||||
stream (:class:`~plexapi.media.AudioStream`): AudioStream to set as default
|
||||
(default:None; required if streamID is not specified).
|
||||
streamID (int): ID of the AudioStream to set
|
||||
(default:None; required if stream is not specified).
|
||||
|
||||
Raises:
|
||||
:class:`plexapi.exceptions.BadRequest`: If both stream and streamID are missing.
|
||||
:class:`plexapi.exceptions.BadRequest`: If stream is not an AudioStream.
|
||||
"""
|
||||
if stream:
|
||||
if type(stream) == AudioStream:
|
||||
key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self.id, stream.id)
|
||||
elif streamID:
|
||||
key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self.id, streamID)
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
else:
|
||||
raise BadRequest('Missing argument: stream or streamID is required')
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
raise BadRequest("Object 'stream' is not an AudioStream.")
|
||||
|
||||
def setDefaultSubtitleStream(self, stream=None, streamID=None):
|
||||
def setDefaultSubtitleStream(self, stream):
|
||||
""" Set the default :class:`~plexapi.media.SubtitleStream` for this MediaPart.
|
||||
(Note: pass no parameters to disable subtitles)
|
||||
|
||||
|
||||
Parameters:
|
||||
stream (:class:`~plexapi.media.SubtitleStream`): SubtitleStream to set as default
|
||||
(default:None).
|
||||
streamID (int): ID of the AudioStream to set
|
||||
(default:None).
|
||||
stream (:class:`~plexapi.media.SubtitleStream`): SubtitleStream to set as default.
|
||||
|
||||
Raises:
|
||||
:class:`plexapi.exceptions.BadRequest`: If stream is not a SubtitleStream.
|
||||
"""
|
||||
if stream:
|
||||
if type(stream) == SubtitleStream:
|
||||
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, stream.id)
|
||||
elif streamID:
|
||||
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, streamID)
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
else:
|
||||
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, 0)
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
raise BadRequest("Object 'stream' is not a SubtitleStream.")
|
||||
|
||||
def resetSubtitles(self):
|
||||
""" Set default subtitle of this MediaPart to 'none'. """
|
||||
key = "/library/parts/%d?subtitleStreamID=0&allParts=1" % (self.id)
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
|
||||
class MediaPartStream(PlexObject):
|
||||
""" Base class for media streams. These consist of video, audio and subtitles.
|
||||
|
|
Loading…
Reference in a new issue