owntone / owntone-server

Linux/FreeBSD DAAP (iTunes) and MPD audio server with support for AirPlay 1 and 2 speakers (multiroom), Apple Remote (and compatibles), Chromecast, Spotify and internet radio.
https://owntone.github.io/owntone-server
GNU General Public License v2.0
2.07k stars 237 forks source link

Default Sorting Behaviour #522

Closed Wawsax closed 6 years ago

Wawsax commented 6 years ago

Is there any way to force a default sorting behaviour?

I like to, in the iTunes album view, sort albums by album artist and then by year. (Using 'View Options' - ⌘J.) Unfortunately, it doesn't stick on the forked-daapd shared library, so I have to change the view options each time I connect. And the forked-daapd shared library appears to default to sorting by artist and then by title.

Ideally, I'd like to be able to force a default sorting behaviour in the forked-daapd configuration file that would be respected by iTunes and, if possible, Remote on iOS. Is this possible? Can forked-daapd control any kind of sorting behaviour or is that all client-side?

ejurgensen commented 6 years ago

iTunes is client-side, while Remote is server-side, as I remember. I don't understand why you in the album view want to sort by artist? Why don't you use the artist view?

The album view in Remote should be sorted by album name, disc number and then track number (I don't remember the reason for the latter).

Wawsax commented 6 years ago

It fits with the way I visualise my music collection. In the album view I can see all the albums together, with all their pretty pictures, and in that view I prefer them to be sorted by artist, and within the artist by year. iTunes lets me do it that way and I've been doing it for years. In the artist view you can only see albums for the selected artist and even then they're huge and much of the view is full of track names. It's nice to just flick through albums like they're up on a wall or in a binder and have something catch your eye and decide to play it. When you're looking at a bunch of albums from one artist it just feels more natural to me that they would be in chronological order.

I'm not asking you to change any default settings, I'd just like the option of tweaking those settings in the configuration file so I can set things up how I like them. Is it difficult to make settings like these configurable?

ejurgensen commented 6 years ago

Ok, I understand what you are after, but as I mentioned, it is client-side on iTunes, so not much I can do.

Wawsax commented 6 years ago

You mentioned that it was server-side for the iOS Remote, though. If there's a way to tweak it, I'd be interested to know. I'm already building from source, so if you can give me a hint as to what to edit in the code or where to look, I'd at least be interested in fiddling around with it. Seems like there's some code dealing with sorting at httpd_daap.c#1630?

But yes, if iTunes is just client-side then it seems there's an oversight or bug on Apple's side with not saving view preferences for shared libraries.

Thanks for your time! (And for the great software, of course.)

ejurgensen commented 6 years ago

You can play around with sorting for albums in Remote by editing this line: https://github.com/ejurgensen/forked-daapd/blob/master/src/db.c#L305

Sorting for artists is the next line. You should probably turn of the cache while playing with this (uncomment cache_daap_threshold in the config and set it to 0).

Note that if you change the sorting, the database indices will be off, so you will see a decline in performance. If your music library is large this will quite significant, but if you then re-enable the cache it should help.

Wawsax commented 6 years ago

Thanks! Will do.

Wawsax commented 6 years ago

Changed db.c#305 to: "f.album_artist_sort, f.year, f.album_sort, f.disc, f.track",

Does exactly what I was looking for! Thanks for the help. Closing as it seems unlikely anyone but me is interested.

sstallion commented 1 year ago

Just wanted to mention I've been looking for a method to do this for my collection as well. Thanks for the tip! It would be nice if this could be rolled into a configuration option so I don't need to carry around a patch for this one feature. If I put up a PR to address this more generally, would it be accepted?

sstallion commented 1 year ago

If I put up a PR to address this more generally, would it be accepted?

I may have spoken too soon. It looks like Apple Music no longer honors the order returned by OwnTone.