@@ -125,22 +125,42 @@ def subtitleStreams(self):
125125 """ Returns a list of :class:`~plexapi.media.SubtitleStream` objects in this MediaPart. """
126126 return [stream for stream in self .streams if stream .streamType == SubtitleStream .STREAMTYPE ]
127127
128- def setDefaultAudioStream (self , id ):
128+ def setDefaultAudioStream (self , stream = None , streamID = None ):
129129 """ Set the default :class:`~plexapi.media.AudioStream` for this MediaPart.
130130
131131 Parameters:
132- id (int): ID of the AudioStream to set
132+ stream (:class:`~plexapi.media.AudioStream`): AudioStream to set as default
133+ (default:None; required if streamID is not specified).
134+ streamID (int): ID of the AudioStream to set
135+ (default:None; required if stream is not specified).
136+
137+ Raises:
138+ :class:`plexapi.exceptions.BadRequest`: If both stream and streamID are missing.
133139 """
134- key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self .id , id )
140+ if stream :
141+ key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self .id , stream .id )
142+ elif streamID :
143+ key = "/library/parts/%d?audioStreamID=%d&allParts=1" % (self .id , streamID )
144+ else :
145+ raise BadRequest ('Missing argument: stream or streamID is required' )
135146 self ._server .query (key , method = self ._server ._session .put )
136-
137- def setDefaultSubtitleStream (self , id ):
147+
148+ def setDefaultSubtitleStream (self , stream = None , streamID = None ):
138149 """ Set the default :class:`~plexapi.media.SubtitleStream` for this MediaPart.
150+ (Note: pass no parameters to disable subtitles)
139151
140152 Parameters:
141- id (int): ID of the SubtitleStream to set (0 for no subtitles)
153+ stream (:class:`~plexapi.media.SubtitleStream`): SubtitleStream to set as default
154+ (default:None).
155+ streamID (int): ID of the AudioStream to set
156+ (default:None).
142157 """
143- key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self .id , id )
158+ if stream :
159+ key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self .id , stream .id )
160+ elif streamID :
161+ key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self .id , streamID )
162+ else :
163+ key = "/library/parts/%d?subtitleStreamID=%d&allParts=1" % (self .id , 0 )
144164 self ._server .query (key , method = self ._server ._session .put )
145165
146166
0 commit comments