-
Notifications
You must be signed in to change notification settings - Fork 198
add support for fetching loudness levels of audio streams #1529
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -433,10 +433,34 @@ def setSelected(self): | |||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
return self._parent().setSelectedAudioStream(self) | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
def levels(self, subSample=128): | ||||||||||||||||||||||||||||||||||||||||||
""" Load time series loudness levels. | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Attributes: | ||||||||||||||||||||||||||||||||||||||||||
subSample: (int): the number of loudness segments to load | ||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
key = f'/library/streams/{self.id}/levels' | ||||||||||||||||||||||||||||||||||||||||||
params = {'subsample': subSample} | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
levels = self.fetchItems(ekey=key, cls=Level, params=params) | ||||||||||||||||||||||||||||||||||||||||||
return levels | ||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+442
to
+447
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
@deprecated('Use "setSelected" instead.') | ||||||||||||||||||||||||||||||||||||||||||
def setDefault(self): | ||||||||||||||||||||||||||||||||||||||||||
return self.setSelected() | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
@utils.registerPlexObject | ||||||||||||||||||||||||||||||||||||||||||
class Level(PlexObject): | ||||||||||||||||||||||||||||||||||||||||||
""" Represents an instance of loudness for an audio stream. | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Attributes: | ||||||||||||||||||||||||||||||||||||||||||
loudness (float): loudness level in db | ||||||||||||||||||||||||||||||||||||||||||
""" | ||||||||||||||||||||||||||||||||||||||||||
def _loadData(self, data): | ||||||||||||||||||||||||||||||||||||||||||
""" Load attribute values from Plex XML response. """ | ||||||||||||||||||||||||||||||||||||||||||
self.loudness = data.attrib.get('v') | ||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
Comment on lines
+453
to
+463
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Move to the bottom of the file.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||
@utils.registerPlexObject | ||||||||||||||||||||||||||||||||||||||||||
class SubtitleStream(MediaPartStream): | ||||||||||||||||||||||||||||||||||||||||||
|
Original file line number | Diff line number | Diff line change | ||||||
---|---|---|---|---|---|---|---|---|
|
@@ -397,6 +397,7 @@ def test_audio_Track_attrs(album): | |||||||
assert stream.lra is None | ||||||||
assert stream.peak is None | ||||||||
assert stream.startRamp is None | ||||||||
assert len(stream.levels(subSample=32)) == 32 | ||||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||||
|
||||||||
|
||||||||
def test_audio_Track_album(album): | ||||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.