mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-10 06:04:15 +00:00
Add lyricStreams()
convenience method (#1303)
* Move videoStreams, audioStreams, lyricStreams to Playable * Add lyricStreams to Playable * Simplify returning list of streams * Add test for track.lyricStreams()
This commit is contained in:
parent
46c20a598f
commit
f7522afd6b
3 changed files with 28 additions and 36 deletions
|
@ -771,6 +771,30 @@ class Playable:
|
|||
for part in item.parts:
|
||||
yield part
|
||||
|
||||
def videoStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.videoStream` objects for all MediaParts. """
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
return sum((part.videoStreams() for part in self.iterParts()), [])
|
||||
|
||||
def audioStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.AudioStream` objects for all MediaParts. """
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
return sum((part.audioStreams() for part in self.iterParts()), [])
|
||||
|
||||
def subtitleStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.SubtitleStream` objects for all MediaParts. """
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
return sum((part.subtitleStreams() for part in self.iterParts()), [])
|
||||
|
||||
def lyricStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.LyricStream` objects for all MediaParts. """
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
return sum((part.lyricStreams() for part in self.iterParts()), [])
|
||||
|
||||
def play(self, client):
|
||||
""" Start playback on the specified client.
|
||||
|
||||
|
|
|
@ -97,42 +97,6 @@ class Video(PlexPartialObject, PlayedUnplayedMixin):
|
|||
""" Returns str, default title for a new syncItem. """
|
||||
return self.title
|
||||
|
||||
def videoStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.videoStream` objects for all MediaParts. """
|
||||
streams = []
|
||||
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
|
||||
parts = self.iterParts()
|
||||
for part in parts:
|
||||
streams += part.videoStreams()
|
||||
return streams
|
||||
|
||||
def audioStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.AudioStream` objects for all MediaParts. """
|
||||
streams = []
|
||||
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
|
||||
parts = self.iterParts()
|
||||
for part in parts:
|
||||
streams += part.audioStreams()
|
||||
return streams
|
||||
|
||||
def subtitleStreams(self):
|
||||
""" Returns a list of :class:`~plexapi.media.SubtitleStream` objects for all MediaParts. """
|
||||
streams = []
|
||||
|
||||
if self.isPartialObject():
|
||||
self.reload()
|
||||
|
||||
parts = self.iterParts()
|
||||
for part in parts:
|
||||
streams += part.subtitleStreams()
|
||||
return streams
|
||||
|
||||
def uploadSubtitles(self, filepath):
|
||||
""" Upload Subtitle file for video. """
|
||||
url = f'{self.key}/subtitles'
|
||||
|
|
|
@ -394,6 +394,10 @@ def test_audio_Track_artist(album, artist):
|
|||
assert tracks[0].artist() == artist
|
||||
|
||||
|
||||
def test_audio_Track_lyricStreams(track):
|
||||
assert not track.lyricStreams()
|
||||
|
||||
|
||||
def test_audio_Track_mixins_images(track):
|
||||
test_mixins.attr_artUrl(track)
|
||||
test_mixins.attr_posterUrl(track)
|
||||
|
|
Loading…
Reference in a new issue