extensions icon indicating copy to clipboard operation
extensions copied to clipboard

Apple Music: Added artwork for tracks, albums, and playlists in grid view.

Open yug2005 opened this issue 2 years ago • 24 comments

Description

Added optional grid view for tracks, albums, and playlists. There are options for grid item size as well.

Showing the artwork using AppleScript. However due to performance reasons, I need to :

  • Resize some images (this increases loading time)
  • Limit the number of shown results.
  • Removed the loadAll feature for albums.

Let me know if you have any ideas to improve performance. Perhaps another method to resize the images faster.

However, that being said, I still think this is awesome!

Screencast

music 2022-06-29 at 16 19 27 music 2022-06-29 at 16 19 53 music 2022-06-29 at 16 22 38

Checklist

yug2005 avatar Jun 29 '22 20:06 yug2005

Thank you for your contribution! :tada:

🔔 @Rawnly you might want to have a look.

raycastbot avatar Jun 29 '22 20:06 raycastbot

Thank you! This looks dope! I’ll try it in the afternoon 💪

rawnly avatar Jun 30 '22 07:06 rawnly

I left a few comments. Feel free to ignore them. These are not hard requirements I can fix those things in a new PR next time!

rawnly avatar Jun 30 '22 10:06 rawnly

@Rawnly is it possible to play a track on repeat through applescript? I couldn't get it to work. Also, I am planning to add a push action for playlists, to see the songs of the playlist.

yug2005 avatar Jun 30 '22 19:06 yug2005

I don't know honestly, there's a website which references a lot of scripts (right now I don't remember the name)

rawnly avatar Jun 30 '22 19:06 rawnly

http://dougscripts.com/itunes/index.php

rawnly avatar Jun 30 '22 19:06 rawnly

Is this ready to be merged @Rawnly or would you help @yug2005 implement TaskEither first?

pernielsentikaer avatar Jun 30 '22 20:06 pernielsentikaer

Not ready to merge yet. I will add a few features soon.

yug2005 avatar Jul 01 '22 02:07 yug2005

May I ask what is the reason/advantage of using TaskEither?

yug2005 avatar Jul 01 '22 02:07 yug2005

Added some awesome new features!

  • You can see songs in a playlist.
    • However the results still have to be limited.
    • The list view is best for seeing more results because the artworks are really small.
    • You can see up to 100 results.
  • List detail view with a lot of information.
  • Preferences for new features in extension configurations

https://user-images.githubusercontent.com/77864399/176850353-93c5b990-b4e1-4edb-b834-01b44c6f1aeb.mov

yug2005 avatar Jul 01 '22 07:07 yug2005

Added some awesome new features!

Love it!

rawnly avatar Jul 01 '22 12:07 rawnly

May I ask what is the reason/advantage of using TaskEither?

Sure! TaskEither is the composition of 2 types, Task and Either.

The Task type "represents an asynchronous computation that yields a value of type A and never fails". But what about the errors? Here it comes our TaskEither which is an alias for type TaskEither<E, A> = Task<Either<E, A>>.

The Either is a union type that can holds 2 values, an error (left) and the return value of the function (right). You might see some similarities with the Result type in languages like rust and swift.

Everything is done to be type-safe. Since the error in the try/catch cannot be typed. You can see an example usage in the src/utils/apple-script.ts file.

This explanation might not be super complete but it should clear the difference between a Promise and a TaskEither. Once you've done your edits, if you want, I can contribute your PR by converting the code (if you're having difficulties with it).

I don't want this to be a problem for new contributors so, is fine for me if you want to learn something new or if you find it interesting. But if not, don't worry 😉

rawnly avatar Jul 01 '22 13:07 rawnly

I tried the new updates. I'm having troubles when trying to "start playlist"

Error: Command failed with exit code 1: osascript -e
      tell application "Music"
        set playlistArtwork to first artwork of first playlist of (every playlist whose id is 4283)
        set playlistImage to data of playlistArtwork
      end tell
      return playlistImage

I would also like to leave the List as default view since the Grid is empty until you don't perform a search. I thinks is a better UX, for example i'm not the kind of user who knows what to listen, and I like to scroll and then pick. So an empty view with the search is not the best for my experience 😅

rawnly avatar Jul 01 '22 14:07 rawnly

Hello I haven't been able to reproduce the error for start playlist. Could you see if that playlist does not have any artwork? Maybe running the script in script editor to see what the issue is.

For the previous implementation of the list view, the loadAll feature was only there for the albums right? I removed that feature because when you started to search for something while loadAll was running, it would show you the results for the search query but then flicker back to show all songs once loadAll was complete. List view is default for the playlist tracks view but I do think grid view looks really nice for the other views. Are you thinking about bringing back the loadAll feature for tracks and albums?

For Task Either, if you would like to implement it, please do. I am busy with some other things now.

yug2005 avatar Jul 01 '22 18:07 yug2005

@yug2005

Hello I haven't been able to reproduce the error for start playlist. Could you see if that playlist does not have any artwork? Maybe running the script in script editor to see what the issue is.

Yes it was caused by a Playlist without artwork. Can you please handle this? (Also for some tracks i'm having the same problems)

rawnly avatar Jul 02 '22 09:07 rawnly

@Rawnly fixed the issue.

yug2005 avatar Jul 02 '22 10:07 yug2005

I'm having trouble when trying to "show tracks" inside "start playlist". Error isn't logged but I believe is with artwork. I'm trying to implement TaskEither so maybe i can fix that too. I'll let you know asap.

music-1

rawnly avatar Jul 02 '22 11:07 rawnly

Make sure you are not using the id of the track as that sometimes varies (especially with tracks of playlists). That's why I made the switch to using database ID as that is always consistent.

yug2005 avatar Jul 02 '22 18:07 yug2005

@yug2005 I think too much stuff is going on here. Maybe we should split this PR.. Unfortunately I don't have enough time to implement TaskEither, but i'd like to reintroduce the loadAll maybe with pagination and infinite scrolling. You can do a little trick via onSelectedId to make it work. Specific code can be found in the Github Gist extension source code

rawnly avatar Jul 06 '22 21:07 rawnly

@Rawnly I tried using onSelectedId but it was difficult to implement and did not work well. I was trying to implement it for the grid view. Fetching the artwork takes a long time and once you have a lot of artworks, unless you resize to something very small, you will run out of memory very quickly.

I guess that it would be doable for the list view if you resized to about 32x32 or smaller but even then it is possible to run out of memory. As for the grid view, its impossible if you want the artwork to look decent.

I think unless TaskEither has performance benefits, it is probably okay to skip for this PR as you could implement in a future one.

yug2005 avatar Jul 06 '22 22:07 yug2005

What are the status here now? 🙂

pernielsentikaer avatar Jul 13 '22 10:07 pernielsentikaer

What are the status here now? 🙂

@pernielsentikaer

As i said before, the idea is cool but doesn't convince me 100%. Starting from the memory problem (due to images). I'm sorry but I'd wait for a better solution, maybe some other way to fetch images. The current implementation is slower and I don't think that images are worth the lack of speed :/

(i would like to keep the extensions dead simple and fast to use)

rawnly avatar Jul 13 '22 23:07 rawnly

Thanks for the update 🔥 I'm converting this to a draft for now 🙂

pernielsentikaer avatar Jul 14 '22 03:07 pernielsentikaer

This issue/pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs in the next 7 days to keep our backlog clean. Thanks for your contributions.

stale[bot] avatar Sep 02 '22 03:09 stale[bot]