Thank you for your donation!


Cloudsmith graciously provides open-source package management and distribution for our project.


Sort Logic for Playlists
#1
Is there a logic to the display order of playlists in the browse panel?

It doesn't appear to be alphabetical or by modification time. I can't see a logic to it.

It is the same order given by mpc lsplaylists so it is probably a MPD thing rather than a moOde thing but I wondered if anybody here has an idea how it works?
Reply
#2
I'd love to be able to sort listings into date, reverse date order, or alphabetical order in the browse panel

Reply
#3
Sort the entire list or would directories still be listed at the top as they currently are?

moOde just uses the list generated by MPD as-is, example below. It appears to be an alpha sort till you get to the Default Playlist entry which should be below the Aaa entry but instead is above it. Very odd.

directory: NAS
directory: RADIO
directory: SDCARD
playlist: Default Playlist
playlist: Aaa
playlist: Eee
playlist: Favorites
playlist: Test

Code:
pi@rp3:~ $ telnet localhost 6600
Trying ::1...
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
OK MPD 0.20.0
lsinfo
directory: NAS
Last-Modified: 2018-07-08T18:04:14Z
directory: RADIO
Last-Modified: 2018-07-24T23:33:06Z
directory: SDCARD
Last-Modified: 2018-07-12T16:01:41Z
playlist: Default Playlist
Last-Modified: 2018-07-24T23:33:06Z
playlist: Aaa
Last-Modified: 2018-07-25T12:44:21Z
playlist: Eee
Last-Modified: 2018-07-25T12:44:37Z
playlist: Favorites
Last-Modified: 2018-07-25T03:41:30Z
playlist: Test
Last-Modified: 2018-07-24T23:32:16Z
OK

I'll have to play around with this a bit and see whats possible as far as sorts go.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#4
I would say directories should stay at top like now.

My list is clearly neither sorted alphabetically or by time if I compare output from
Code:
mpc playlists

ls -l /var/lib/mpd/playlists/

ls -lt /var/lib/mpd/playlists/

Even just knowing why they are ordered the way they are would be helpful. But I can't figure out what's going on tbh.
Reply
#5
The order is given by the natural directory order as can be seen by:
ls -lU /var/lib/mpd/playlists/

As far as I know that can not be rearranged easily. For FAT filesystem there is a utility fatsort. See for example:
https://superuser.com/questions/368623/h...ed-in-ls-u

Additionally see last post in:
https://serverfault.com/questions/406229...g-in-linux

Quote:
Modern Linux (ext4) adds a B-tree index for file lists. One of his effect is default files order depends on a hash of their names.
To disable this feature use :
Quote:tune2fs -O^dir_index
But I don't know, what this really does. Perhaps someone knows.

Regards
  Duke.g

2x RPi 3B, 1x RPi 4, Moode 8; 4k flac Songs; 180k MP3 Songs; Asset-UpnP 184k Songs
The blues has got a hold of me, I believe I'm gettin' dizzy - ZZ Top
Reply
#6
(07-25-2018, 06:12 PM)duke.g Wrote: The order is given by the natural directory order as can be seen by:
ls -lU /var/lib/mpd/playlists/

...

Quote:
Modern Linux (ext4) adds a B-tree index for file lists. One of his effect is default files order depends on a hash of their names.
To disable this feature use :
Quote:tune2fs -O^dir_index
But I don't know, what this really does. Perhaps someone knows.

Regards
  Duke.g

Good observation about the "natural" order.

The man page for tune2fs says that setting the dir_index parameter means "Use hashed b-trees to speed up lookups for large directories". Apparently, the ext4 filesystem is the first in which this parameter is enabled by default.

What qualifies as a large directory? Don't know. Will unsetting the parameter result in an ordering you like? Don't know. Will it result in a noticeable slowdown using the filesystem? Don't know.  Does unsetting it mean the filesystem has to be forceably reindexed before it can be used? Don't know.

Regards,
Kent
Reply
#7
Interesting and thanks @duke.g :-)

For Browse panel output I should be able to do a simple array sort in the JS.

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply
#8
Well I just made a copy of my SD-Card and tried it.
The playlist are now alphabetically ordered and for me it makes no performance difference while using the (small) local library of my player. Small means:
Artists:    873
Albums:     856
Songs:     4301

You first have to find out your device: I used lsblk
Output:
NAME        MAJ:MIN RM   SIZE RO TYPE MOUNTPOINT
sda           8:0    0 238.5G  0 disk
sda1        8:1    0 238.5G  0 part /media/M_MUSIC
mmcblk0     179:0    0  14.9G  0 disk
mmcblk0p1 179:1    0  43.2M  0 part /boot
mmcblk0p2 179:2    0  14.4G  0 part /  -> This is my SD-Card where the playlists reside!

I issued: sudo tune2fs -O ^dir_index /dev/mmcblk0p2

Then I rebooted. After that the playlists are in the "correct" order.

Regards
   Duke.g

2x RPi 3B, 1x RPi 4, Moode 8; 4k flac Songs; 180k MP3 Songs; Asset-UpnP 184k Songs
The blues has got a hold of me, I believe I'm gettin' dizzy - ZZ Top
Reply
#9
(07-25-2018, 09:15 PM)duke.g Wrote: Well I just made a copy of my SD-Card and tried it.
The playlist are now alphabetically ordered and for me it makes no performance difference while using the (small) local library of my player. Small means:
Artists:    873
Albums:     856
Songs:     4301

...

Regards
   Duke.g

There ya go!

Not eager to try it on my NAS, however.
Reply
#10
Thats cool but probably not necessary once the sorts are done in code.

The advantage of using PHP/JS code and array sorting is:

1. Directories can easily be separated from files
2. The removeArticles() and ToLowerCase() functions can be used to yield an optimal sort
3. Additional array elements can be added to produce any sort order

-Tim
Enjoy the Music!
moodeaudio.org | Mastodon Feed | GitHub
Reply


Forum Jump: