Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Ordering albums in artist tab #147

Closed
FLchs opened this issue Nov 12, 2024 · 7 comments · Fixed by #173
Closed

Ordering albums in artist tab #147

FLchs opened this issue Nov 12, 2024 · 7 comments · Fixed by #173
Labels
enhancement New feature or request

Comments

@FLchs
Copy link

FLchs commented Nov 12, 2024

Description

Hello it's me again,
In artists and album artist panes, albums are ordered alphabetically.
Ordering them by release date makes more sense to me, I know I could add the release date to the folder name but I think it clutters the view.

Proposed solution

Afaik MPD protocol doesn't allow to get an ordered or "rich" list from the list command so it is not as trivial as it seems.

I tried to make a proof of concept of a solution but it makes browsing the library quite slower as I have to get all the songs of an artist and then process it rather than getting a list of album names from MPD...
I think ncmpcpp add some kind of delay before rendering the album column as a workaround.

So here is my POC, be aware I'm by no way familiar with Rust so I'm 100% sure that if you find this request pertinent you will find a more elegant way.
master...FLchs:rmpc:feat/order-album-by-date

@FLchs FLchs added the enhancement New feature or request label Nov 12, 2024
@FLchs
Copy link
Author

FLchs commented Nov 12, 2024

I put some more thoughts in this issue and I may have a better idea:
Allowing (via config/theme) to format the Artist/Album/Tracks column, including some kind of trim to remove year/track number/anything else ?

For example, with a library structured like this :

Library
└── ArtistA
    ├── 2023 - Album1
    │   ├── 01 - Song1
    │   ├── 02 - Song2
    │   └── ...
    └── 2024 - Album2
        └── ...

rmpc will display a table looking like this:

ArtistA 2023 - Album1 01 - Song1
2023 - Album2 01 - Song2
01 - Song3
...

But adding support for library formatting (and another property) :

library_table_format :
        rows: [
            (
                artist: [
                    (style: (modifiers: "Bold", fg: "red")),
                ],
                album: [
                (style: (modifiers: "TrimDate") // Weird ?
                        triml: 6 // remove the first 6 chars ?
                        regex: "^\d{4} - " // fancy/best :) )
                ],
                track: [
                    (style: (fg: "blue"), regex: "^\d{2} - "),
                ]
            ),
        ]

would render:
rmpc will display a table looking like this:

ArtistA (bold,red) Album1 Song1
Album2 Song2
Song3 (blue)
...

Column formatting would look nice as added bonus.

And maybe :
library_sorting ; asc | desc in the config that could be used in the sorted() functions...

@mierak
Copy link
Owner

mierak commented Nov 12, 2024

Hello!
I like the idea of allowing sort by albums date, but there are a few problems with trying to implement this.

As you have found out, there is no such thing as "album date" in mpd, so we have to approximate it from the songs inside the album, but a single album can have songs with different dates. There are a few strategies that we can take to tackle this.

  1. We simply take the first returned song in the album and declare it the albums date
  2. We take the most recent(or the oldest) song in the album and declare it the albums date
  3. We split the album into multiple ones by date

But no matter the path, we will still have to fetch all the songs for the artist, which is fine in the artists/album artists tab, but what about the Album tab? We would have to fetch the whole library I think.

The formats idea is interesting, there already is browser_song_format, but it does not allow for styling.

I am unsure on how to tackle all this at the moment, but I agree that it makes sense to have them sorted by date or other means.

@FLchs
Copy link
Author

FLchs commented Nov 12, 2024

The "fetching all songs" seems very inefficient indeed.
The browser_song format exists but as you said it does not allow for styling nor custom formatting, but what I think is a bigger issue is that it used both in the Artist/AlbumArtist/Album panes but also in the playlist pane.

I didn't want to have artists and track number in my album but then playlists look a bit weird with only the track name...

I'm going to try what I can do on my side, as an excuse to learn a bit more Rust, I will let you know if I think i have something nice.

@mierak
Copy link
Owner

mierak commented Nov 12, 2024

Yeah, I initially planned to have different format for songs in playlists but did not get around to it. The no styling was done intentionally, but I am not too stuck on it.

@FLchs
Copy link
Author

FLchs commented Nov 13, 2024

master...FLchs:rmpc:feat/browser-regexes

Probably ugly code but with album names prefixed with release date it works enough for my own usage... I'm really not good enough at Rust to try anything more complicated sorry.

@mierak
Copy link
Owner

mierak commented Nov 14, 2024

Great to hear that you found solution that works for you for now! I want to solve this properly but am unsure of how just yet, so I am gonna leave this issue open for now if you dont mind.

@mierak
Copy link
Owner

mierak commented Dec 12, 2024

Sorry I took ages to resolve this. I have decided to to only show album dates in the artists panes, which solves the issue of having to fetch the whole library. I have also added new config values. You can choose to hide or show the album date as well as whether to sort them by name or date.

One edge case is when album contains songs with different dates:
If SplitByDate is configured, the album gets split into two, for example (2020) AlbumName and (2024) AlbumName.
And if NameOnly is configured together with sort by Date, the albums get sorted according to the earliest date in the album.

Definitely had to make some trade offs there, but hopefully it fits your use case. Dont hesitate to reopen this if you have any issues with this!

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants