-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feat: Change current track's favorited state #13
Feat: Change current track's favorited state #13
Conversation
With this change, you'll be able to chanage the favorited/loved state of your currently playing track.
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 love this feature!
I left some notes. Here's what I'd like to see to merge:
get_current_track
should just return the name, and leave it to users to decide what they want.- Split up
set_current_track_favorited
tofavorite_current_track
andunfavorite_current_track
.
Optional:
What do you think about naming the split functions just favorite()
and unfavorite()
?
I don't think you can favorite anything besides tracks, and I doubt anyone will be trying to favorite/unfavorite anything besides the currently playing track.
In the future we could add favorite_track_by_name(name)
or something if it is desired.
I left some other small suggestions like get_current_artist
, I actually think I'd prefer those in separate PRs.
I'm active pretty much every day and am a fan of many tiny easy PRs over smushing everything together.
As I've just checked you can also favorite playlists and albums as well. But I tried this in the app (iPhone) and it seems those don't show up in the built-in favorite songs playlist (I assume it only fetches the favorite tracks in the background), which is weird because then we can't see the favorited albums and playlists in a summary (at least in the app). Anyway, I think this should be included in another PR later on. |
Ha well I stand corrected on this part! I still think we start with assuming just songs and then we can add albums or playlists later. |
8e34acc
to
0c4126c
Compare
@ducktordanny When you're all set just re-request review from me. |
Better name for general function which handles the favorite state changes. `set_favorite_track_by_name` -> `set_track_favorited_state`
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.
Looks great! ❤️
You are welcome to merge as is and I can do the minor refactor (moving the get_current_trackname()
outside of M
) if you want. Otherwise, if you do that refactor I'll also approve.
I also reworded some comments. Feel free to disagree if you feel strongly about them.
Thanks, I made the suggested changes I think those make it better. 👌 |
Awesome! I'm merging this as is. I haven't really tested it much so I'll do that tonight and will put it in the next release probably with something for #17 as well. |
With the included changes we'll be able to mark a track as favorited or undo this via the following examples:
require('apple-music').set_current_track_favorited(true)
require('apple-music').set_current_track_favorited(false)
This command will also handle if the OS version is below 14 (Sonoma) where the
favorited
property was calledloved
. This is done via theosascript
that @p5quared provided in the related issue's comment.If the command succeeds it will prompt the change and the name plus the author of the track it was applied for.
With these changes, we're now also able to get the current track with
require('apple-music').get_current_track()
and it will return the name and author of the track in the following format<name> - <author>
.