-
Notifications
You must be signed in to change notification settings - Fork 200
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
Add sonicallySimilar method to Audio class #1288
Conversation
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.
@JonnyWong16 What is recommendation here, give up on typehinting by removing the import or add a dependency? or is there another way of hinting self in python 3.8 that I am missing?
-> "list[Audio]"
does not serve the same purpose as -> "list[Self]"
in this case
You can use a https://realpython.com/python-type-self/#annotating-with-typevar
|
- fixes import error
Co-Authors @JonnyWong16
- makes it so that params can be None and use the server default
plexapi/audio.py
Outdated
params = {"maxDistance": maxDistance, "limit": limit} | ||
key += utils.joinArgs( | ||
{k: v for k, v in params.items() if v is not None} | ||
) |
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.
It is more clear to add params instead of removing params.
params = {"maxDistance": maxDistance, "limit": limit} | |
key += utils.joinArgs( | |
{k: v for k, v in params.items() if v is not None} | |
) | |
params = {} | |
if limit is not None: | |
params['limit'] = limit | |
if maxDistance is not None: | |
params['maxDistance'] = maxDistance | |
key += utils.joinArgs(params) |
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.
I have a way to maintain the adding of param as well as make it add programmatically so that it is scalable and avoid code repetition of if
statements for every key
all_args = {"limit": limit, "maxDistance": maxDistance}
params = {k: v for k, v in all_args.items() if v is not None} # add if not None
Co-authored-by: JonnyWong16 <[email protected]>
test_audio.py
closes #1183
Description
This pull request adds a new method,
sonicallySimilar
, to theAudio
class. This method allows users to find sonically similar audio items based on a maximum distance between tracks. The method takes in optional parameters forlimit
andmaxDistance
and returns a list of sonically similar audio items.Audio
class now contains a new attributedistance
which is the sonic distance from the seed item.Type of change
Please delete options that are not relevant.
Checklist: