[GH-ISSUE #76] Change sort order of playlist #51

Open
opened 2026-02-28 14:46:37 +03:00 by kerem · 10 comments
Owner

Originally created by @t89 on GitHub (Oct 17, 2019).
Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/76

An option to sort the playlist in different ways would be nice: Show the most recently added songs on top for example.

Originally created by @t89 on GitHub (Oct 17, 2019). Original GitHub issue: https://github.com/Rigellute/spotify-tui/issues/76 An option to sort the playlist in different ways would be nice: Show the most recently added songs on top for example.
Author
Owner

@Rigellute commented on GitHub (Oct 18, 2019):

Intereting point 👍

<!-- gh-comment-id:543621577 --> @Rigellute commented on GitHub (Oct 18, 2019): Intereting point 👍
Author
Owner

@SgiobairOg commented on GitHub (Oct 18, 2019):

Completely new to Rust but, as this is a super interesting project could I offer to take a crack at this issue?

<!-- gh-comment-id:543731055 --> @SgiobairOg commented on GitHub (Oct 18, 2019): Completely new to Rust but, as this is a super interesting project could I offer to take a crack at this issue?
Author
Owner

@jfaltis commented on GitHub (Oct 18, 2019):

I would suggest to use Shift+S or Alt+s to enter a "sort mode" which basically just listens for the next keypress and processes it to decide to sort by what criteria. E.g t for title, a for artist, l for length etc. Maybe it could also show some kind of "Statusbar" with the sorting criterias and corresponding keys while being in "sort mode"

<!-- gh-comment-id:543760444 --> @jfaltis commented on GitHub (Oct 18, 2019): I would suggest to use Shift+S or Alt+s to enter a "sort mode" which basically just listens for the next keypress and processes it to decide to sort by what criteria. E.g t for title, a for artist, l for length etc. Maybe it could also show some kind of "Statusbar" with the sorting criterias and corresponding keys while being in "sort mode"
Author
Owner

@Rigellute commented on GitHub (Oct 18, 2019):

Upper case S (i.e. <Shift+S>) sounds like a good binding to me.

And if you want to take a crack at it @SgiobairOg, be my guest!

<!-- gh-comment-id:543883427 --> @Rigellute commented on GitHub (Oct 18, 2019): Upper case `S` (i.e. `<Shift+S>`) sounds like a good binding to me. And if you want to take a crack at it @SgiobairOg, be my guest!
Author
Owner

@SgiobairOg commented on GitHub (Oct 27, 2019):

So, handling the key inputs is straightforward enough, even with no Rust experience.

Could someone point me to the code that handles populating the track table though? I'm assuming I can just grab the tracks from app.track_table.tracks, and sort them with slice::sort_by. Not sure how to update the display and set the current track if one is playing.

<!-- gh-comment-id:546740933 --> @SgiobairOg commented on GitHub (Oct 27, 2019): So, handling the key inputs is straightforward enough, even with no Rust experience. Could someone point me to the code that handles populating the track table though? I'm assuming I can just grab the tracks from `app.track_table.tracks`, and sort them with `slice::sort_by`. Not sure how to update the display and set the current track if one is playing.
Author
Owner

@debdutto commented on GitHub (Nov 26, 2019):

@SgiobairOg Are you still working on this? Was hoping to have a crack at it over the weekend?

<!-- gh-comment-id:558715682 --> @debdutto commented on GitHub (Nov 26, 2019): @SgiobairOg Are you still working on this? Was hoping to have a crack at it over the weekend?
Author
Owner

@SgiobairOg commented on GitHub (Nov 26, 2019):

I was, but don’t actually know how to do the sort and haven’t had time to figure it out. I can commit a branch if you want so you can have what I’ve got so far.

<!-- gh-comment-id:558719272 --> @SgiobairOg commented on GitHub (Nov 26, 2019): I was, but don’t actually know how to do the sort and haven’t had time to figure it out. I can commit a branch if you want so you can have what I’ve got so far.
Author
Owner

@luiswirth commented on GitHub (Nov 26, 2019):

I've been spending some time on this issue and there seem to be some obstacles in implementing this...

I was successful in sorting the tracks by Title, Artist, Album and Duration depending on the keyboard input. But the difficulty lies in starting the playback and have the tracks play in the same order as they are in the TrackTable. If I'm right I must pass all the URIs of all tracks in the correct order to the spotify-api. So far we've just passed None as argument, since we just used the default ordering. I hope this doesn't have any noticeable performance implications when playing big playlists.

I will continue working on it.

If somebody wants to follow along: My Fork. Feedback is very welcome!

<!-- gh-comment-id:558821592 --> @luiswirth commented on GitHub (Nov 26, 2019): I've been spending some time on this issue and there seem to be some obstacles in implementing this... I was successful in sorting the tracks by Title, Artist, Album and Duration depending on the keyboard input. But the difficulty lies in starting the playback and have the tracks play in the same order as they are in the `TrackTable`. If I'm right I must pass all the `URI`s of all tracks in the correct order to the spotify-api. So far we've just passed `None` as argument, since we just used the default ordering. I hope this doesn't have any noticeable performance implications when playing big playlists. I will continue working on it. If somebody wants to follow along: [My Fork](https://github.com/LU15W1R7H/spotify-tui/tree/sorting-tracks). Feedback is very welcome!
Author
Owner

@Rigellute commented on GitHub (Nov 27, 2019):

You are right @LU15W1R7H, we can sort the display for the tracks and can even get the playback to work in that order - but the limitation is that Spotify will only play those tracks that have been sorted (once you get to the end of that list, playback will stop).

Perhaps this is intentional, but means we will need to correctly manage unsorted (i.e. default) mode, which has the full context of the current playback (playlist/album etc.). That is to say we don't specify an array of URLs.

Totally doable, but more state to manage!

<!-- gh-comment-id:559028781 --> @Rigellute commented on GitHub (Nov 27, 2019): You are right @LU15W1R7H, we can sort the display for the tracks and can even get the playback to work in that order - but the limitation is that Spotify will only play those tracks that have been sorted (once you get to the end of that list, playback will stop). Perhaps this is intentional, but means we will need to correctly manage unsorted (i.e. default) mode, which has the full context of the current playback (playlist/album etc.). That is to say we don't specify an array of URLs. Totally doable, but more state to manage!
Author
Owner

@luiswirth commented on GitHub (Nov 27, 2019):

@Rigellute yeah, thats totally true. I would also prefer another solution, I just haven't found one so far. It seems the spotify-api just doesn't provide the ability the play the songs in some predefined order...

<!-- gh-comment-id:559044008 --> @luiswirth commented on GitHub (Nov 27, 2019): @Rigellute yeah, thats totally true. I would also prefer another solution, I just haven't found one so far. It seems the spotify-api just doesn't provide the ability the play the songs in some predefined order...
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/spotify-tui#51
No description provided.