mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Merge pull request #336 from gstacks13/set_default_streams
Closes #334 - set default audio & subtitle stream Thanks for the updates!
This commit is contained in:
commit
99efddf49f
1 changed files with 28 additions and 0 deletions
|
@ -124,7 +124,35 @@ class MediaPart(PlexObject):
|
|||
def subtitleStreams(self):
|
||||
""" 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):
|
||||
""" Set the default :class:`~plexapi.media.AudioStream` for this MediaPart.
|
||||
|
||||
Parameters:
|
||||
stream (:class:`~plexapi.media.AudioStream`): AudioStream to set as default
|
||||
"""
|
||||
if isinstance(stream, AudioStream):
|
||||
key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self.id, stream.id)
|
||||
else:
|
||||
key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self.id, stream)
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
|
||||
def setDefaultSubtitleStream(self, stream):
|
||||
""" Set the default :class:`~plexapi.media.SubtitleStream` for this MediaPart.
|
||||
|
||||
Parameters:
|
||||
stream (:class:`~plexapi.media.SubtitleStream`): SubtitleStream to set as default.
|
||||
"""
|
||||
if isinstance(stream, SubtitleStream):
|
||||
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, stream.id)
|
||||
else:
|
||||
key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self.id, stream)
|
||||
self._server.query(key, method=self._server._session.put)
|
||||
|
||||
def resetDefaultSubtitleStream(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