hrkfdn / ncspot

Cross-platform ncurses Spotify client written in Rust, inspired by ncmpc and the likes.
BSD 2-Clause "Simplified" License
5.06k stars 211 forks source link

Sort Albums in Library View #747

Open TheWonkyTestube opened 2 years ago

TheWonkyTestube commented 2 years ago

I tend to mostly listen to albums, and I add new albums to my library on a regular basis. When using Ncspot, if I can't remember exactly what I added, if the album is by an artist I don't know well, then it is very difficult to find the albums that have been added. It would be really great if it was possible to sort albums by other characteristics than just their titles, such as their date of addition to the library, the artist title, or even the albums own date of release.

Ncspot is an amazing app, and this is very much just a suggestion of a possible improvement that could be made!

zain-raza commented 2 years ago

Just want to echo that this is a great app and that I would also love this enhancement!

t-nil commented 2 years ago

I looked into the source code and, unfortunately, it seems that currently the SavedAlbum struct from rspotify is unpacked to Album which makes it lose the added_on information. That means the time of addition is no longer present during sorting. Furthermore, since ncspot pulls albums per page and directly strips the information inside the loop, as a newbie to rust and the codebase, a quick fix seems to be beyond my fix.

ncspot propably needs to handle Saved{Albums,Artists,Tracks,Playlists,Podcasts} internally to enable sorting by added time to happen.

t-nil commented 2 years ago

Ok, seems I was half right. The SavedAlbum struct used in internal storage is not the one from rspotify, but one defined in the project, which retains all needed fields, including added_on. I created a patch which works on my working tree (should be clean).

https://gist.github.com/t-nil/b798096d213258a3e66c98dac7a7445a

If someone would verify that it works, I would be glad also. But it's definitely just a hack, it has no config option etc.

EDIT: You could probably use the same hack to sort the other library views.