Closed jetblackrx89 closed 3 years ago
@jetblackrx89 That's a neat idea. However, it would be challenging to implement because the AppleScript API for querying the Music app only returns results as individual songs, not albums/artists as singular units. This creates a few problems:
First, thanks a lot for considering this.
Here's what I was thinking. I have no idea about the computational cost to do this:
Also in terms of how to avoid a performance / feasibility from a scripting perspective:
I notice in your script it already has some hard cutoffs. For example, if I search by song and just type "a", I get only the first 15 results in my library even though there's probably hundreds of matching songs. I don't know if that's a limitation of Afred, the API calls to/from Apple Music, or the handler scripts you wrote. Depending on where the limitation lies, then yeah, it could be hard to implement a "universal" search where the results list will only be larger. You can't exactly sort through a data set if the data set that's being returned is incomplete in the first place.
So my idea might only work if Apple Music itself had an API call to return a pre-sorted list in the manner I was describing. and then you could impost the 15 result limit like you're currently doing to truncate that result.¯_(ツ)_/¯
@jetblackrx89 The 15-result cutoff was added as a performance optimization, actually. If you try increasing that number yourself (to something like 30 or 50), you'll notice that my workflow takes more time from the point you finish typing your query to the point Alfred starts displaying results.
From my past testing, I believe the bottleneck here isn't the Music library call itself, but rather the number of results AppleScript must subsequently process in returning the result set to you. I am unsure whether the precise inefficiency lies in the pure AppleScript-native iteration, or in my need to convert each result to a JSON string.
I don't know how much AppleScript experience you have, but if you want to hack away at the code to explore possible optimizations, you are certainly welcome to!
@jetblackrx89 Any other thoughts of my latest feedback?
I think you can close this out as I can't think of an implementation. Thanks again for even just considering this feedback.
@jetblackrx89 Sounds good, and thank you for providing your feedback!
I used to love an app called Coversutra and your script is by far to closest to how it used to work.
One thing that I loved was the simplicity of invoking a hotkey and having my search text return all matches for artists, albums, and song titles, all co-mingled in one giant result. It would show the artist, album (with cover art), and song title in the results. And furthermore, the results would be "bundled" in a pretty logical way. Any albums under the same artist would appear successively in the results. Any songs under the same album would appear successively in the results.
Currently with your script, I've mapped 3 different hotkey combinations to launch "playsongby, "playsongin", and "playsong", but I would like one single hotkey to launch a search in all 3.
Do you think this would be possible? Thanks!