Incorrect default sort order
#1
When I play a music album in Kodi 18.4 that pulls the songs from my TwonkyMedia server v8.5.1, the default order is not what I would expect i.e. sort by track number, it seems the default sort order is by track name. If I bring up the "cogwheel" menu it does say "Sort by: Track" and "Sort: Ascending." From there, if I switch to "Descending" and then back to "Ascending" I get the desired sort order.

How do I get the proper default sort order i.e. by ascending track number?
Reply
#2
(2019-12-27, 18:11)sba923 Wrote: When I play a music album in Kodi 18.4 that pulls the songs from my TwonkyMedia server v8.5.1, the default order is not what I would expect i.e. sort by track number, it seems the default sort order is by track name. If I bring up the "cogwheel" menu it does say "Sort by: Track" and "Sort: Ascending." From there, if I switch to "Descending" and then back to "Ascending" I get the desired sort order.

How do I get the proper default sort order i.e. by ascending track number?

Anyone out there?
Reply
#3
Have you tried viewing a list of songs from a (local) album and setting the sort order in there to be sort by track.  Unfortunately that's about all I have to offer as I don't use uPnP for sharing my media. Usually, Kodi sorts using the last specified sort order but I don't know if that applies to uPnP.
Learning Linux the hard way !!
Reply
#4
I'm guessing not many people have a TwonkyMedia server to begin with and to verify/reproduce your problem.
Sometimes topics aren't picked up for whatever reason. Perhaps @DaveBlake can have a peek at it.

EDIT: never mind... Smile
Got a Kodi problem? Provide us with a full Debug log (wiki) || Usefull pages: First time user (wiki) || Troubleshooting (wiki) || Free content (wiki) || Forum rules (wiki) || VPN policy (wiki)
Reply
#5
When you use a UPnP server I believe the default sorting is supposed to be handled by the server.
Reply
#6
(2020-04-07, 13:53)black_eagle Wrote: Have you tried viewing a list of songs from a (local) album and setting the sort order in there to be sort by track.  Unfortunately that's about all I have to offer as I don't use uPnP for sharing my media. Usually, Kodi sorts using the last specified sort order but I don't know if that applies to uPnP.

I'm willing to try but how do I create a local album and populate it with a few songs (say, a copy of a couple full albums from my UPnP-served collection)?
Reply
#7
Assuming that your files are tagged correctly then all you need to do is copy a couple of albums from the UPnP server to a directory that Kodi can access.  Then you need to
  1. Add the directory as a music source (settings->media->music (under manage sources) ->Add music)
  2. After selecting the directory as above, answer Yes to "Do you want to add the media from this source to your library?"
  3. Wait for Kodi to scan in the album(s)
Then just navigate via albums or artists to whatever you just added and view the songs in it. Make sure that sort by is set to track and then try it with your UPnP server.

However, some googling reveals that jjd-uk could indeed be right and it is related to the server.  For instance, https://community.netgear.com/t5/Using-y...d-p/982613 and https://community.wd.com/t/twonky-sortin...till/57163
Learning Linux the hard way !!
Reply
#8
(2020-04-08, 16:42)black_eagle Wrote: Assuming that your files are tagged correctly then all you need to do is copy a couple of albums from the UPnP server to a directory that Kodi can access.  Then you need to
  1. Add the directory as a music source (settings->media->music (under manage sources) ->Add music)
  2. After selecting the directory as above, answer Yes to "Do you want to add the media from this source to your library?"
  3. Wait for Kodi to scan in the album(s)
Then just navigate via albums or artists to whatever you just added and view the songs in it. Make sure that sort by is set to track and then try it with your UPnP server.

However, some googling reveals that jjd-uk could indeed be right and it is related to the server.  For instance, https://community.netgear.com/t5/Using-y...d-p/982613 and https://community.wd.com/t/twonky-sortin...till/57163    

Thanks for the instructions.

I've made the test (see video at https://1drv.ms/v/s!AjBPRo9wXw9s7ptYeHTw...w?e=fRkqeo), and for local albums it seems that the default is "sort by (song) name" but when you change the sort order it is remembered on a per-album basis.

I have other DLNA players and they do abide by the track number tag in my MP3 files. And BTW the filenames use a "track number - song title.mp3" convention so as to be compatible with other players that sort by filename. 

It seems that playing from a UPnP source shows a default of "sort by track" but actually sorts by "song title" (and not by filename as suggested in the Netgear thread). 

If that's a server-side issue, then it means the UPnP player in Kodi doesn't initially sort as specified (i.e. by Track), but just plays in the order the tracks are returned by the server, and performs a sort only if one changes the sort order (see video).

I've looked at my TwonkyServer configuration files and they actually specify to return the tracks in Track order to the UPnP client:


            <container name='artist' id='music/artists' class='object.container' createClass='object.item.audioItem.musicTrack'>
                <container buildon='upnp:artist[7]' class='object.container' createClass='object.item.audioItem.musicTrack'>
                    <container buildon='upnp:artist[2]' class='object.container.person.musicArtist' createClass='object.item.audioItem.musicTrack'>
                        <container buildon='upnp:artist' class='object.container.person.musicArtist' createClass='object.item.audioItem.musicTrack'>
                            <container name='allname' createClass='object.item.audioItem.musicTrack' class='object.container' />
                            <container buildon='upnp:album' albumart='1' sortcriteria='+pv:numberOfThisDisc,+upnp:originalTrackNumber' createClass='object.item.audioItem.musicTrack' class='object.container.album.musicAlbum' /></container>
                    </container>


and VLC's UPnP player, which defaults to "no sort" IOW "play in order tracks are returned by server" does reflect that, see https://1drv.ms/u/s!AjBPRo9wXw9s7ptc768R...A?e=UuqXVF
(I've verified this by intentionally changing the order in TwonkyServer's configuration file and checking the effect on VLC).
Reply
#9
(2020-04-08, 18:19)sba923 Wrote:
(2020-04-08, 16:42)black_eagle Wrote: Assuming that your files are tagged correctly then all you need to do is copy a couple of albums from the UPnP server to a directory that Kodi can access.  Then you need to
  1. Add the directory as a music source (settings->media->music (under manage sources) ->Add music)
  2. After selecting the directory as above, answer Yes to "Do you want to add the media from this source to your library?"
  3. Wait for Kodi to scan in the album(s)
Then just navigate via albums or artists to whatever you just added and view the songs in it. Make sure that sort by is set to track and then try it with your UPnP server.

However, some googling reveals that jjd-uk could indeed be right and it is related to the server.  For instance, https://community.netgear.com/t5/Using-y...d-p/982613 and https://community.wd.com/t/twonky-sortin...till/57163     

Thanks for the instructions.

I've made the test (see video at https://1drv.ms/v/s!AjBPRo9wXw9s7ptYeHTw...w?e=fRkqeo), and for local albums it seems that the default is "sort by (song) name" but when you change the sort order it is remembered on a per-album basis.

I have other DLNA players and they do abide by the track number tag in my MP3 files. And BTW the filenames use a "track number - song title.mp3" convention so as to be compatible with other players that sort by filename. 

It seems that playing from a UPnP source shows a default of "sort by track" but actually sorts by "song title" (and not by filename as suggested in the Netgear thread). 

If that's a server-side issue, then it means the UPnP player in Kodi doesn't initially sort as specified (i.e. by Track), but just plays in the order the tracks are returned by the server, and performs a sort only if one changes the sort order (see video).

I've looked at my TwonkyServer configuration files and they actually specify to return the tracks in Track order to the UPnP client:


            <container name='artist' id='music/artists' class='object.container' createClass='object.item.audioItem.musicTrack'>
                <container buildon='upnp:artist[7]' class='object.container' createClass='object.item.audioItem.musicTrack'>
                    <container buildon='upnp:artist[2]' class='object.container.person.musicArtist' createClass='object.item.audioItem.musicTrack'>
                        <container buildon='upnp:artist' class='object.container.person.musicArtist' createClass='object.item.audioItem.musicTrack'>
                            <container name='allname' createClass='object.item.audioItem.musicTrack' class='object.container' />
                            <container buildon='upnp:album' albumart='1' sortcriteria='+pv:numberOfThisDisc,+upnp:originalTrackNumber' createClass='object.item.audioItem.musicTrack' class='object.container.album.musicAlbum' /></container>
                    </container>


and VLC's UPnP player, which defaults to "no sort" IOW "play in order tracks are returned by server" does reflect that, see https://1drv.ms/u/s!AjBPRo9wXw9s7ptc768R...A?e=UuqXVF
(I've verified this by intentionally changing the order in TwonkyServer's configuration file and checking the effect on VLC). 

I've started to look at the code, actually setting breakpoints and single-stepping.

In GUIViewStateMusic.cpp CGUIViewStateWindowMusicNav::CGUIViewStateWindowMusicNav forcibly sets the sorting method to SortByLabel.

This works fine with the default configuration, because the default "Track naming template" is [%N.]%A - %T

But given my small screen constraint, I've changed that to just %T

As a result, sorting by label sorts by... track name, not by track number.

Even though the default sorting method/order in the global view state class is "sort by ascending track number", as the configuration menu shows.

If I change SetSortMethod(SortByLabel) on line 550 of GUIViewStateMusic.cpp to SetSortMethod(SortByTrackNumber) I obviously get the expected result, but that's hardcoding the sort method, whereas it should be inherited from whatever default is set earlier.

I need to go deeper in understanding the whole design to think about what the fix should be.
Reply
#10
(2020-04-12, 09:36)sba923 Wrote: But given my small screen constraint, I've changed that to just %T

Can you not use [%N.] %T which will just add the track number at the front of the track name ?  Sorting should then work correctly for you.
Learning Linux the hard way !!
Reply
#11
(2020-04-12, 11:56)black_eagle Wrote:
(2020-04-12, 09:36)sba923 Wrote: But given my small screen constraint, I've changed that to just %T

Can you not use [%N.] %T which will just add the track number at the front of the track name ?  Sorting should then work correctly for you.  
I confirm this is a usable workaround. But this uses precious space in the tiles, and there's still a bug if you ask me  Wink
Reply
#12
(2020-04-12, 12:36)sba923 Wrote: I confirm this is a usable workaround. But this uses precious space in the tiles, and there's still a bug if you ask me  Wink

I'm not sure that it's a bug.  Kodi is working by design (or at least, the current design Wink ).  You should be only using/losing 3 or 4 chars at most so even on a small screen that shouldn't be too much of an issue.  There is a possible issue that your posts have thrown up but I need to dig further into it before committing myself as to whether it is indeed an issue.
Learning Linux the hard way !!
Reply
#13
(2020-04-12, 14:26)black_eagle Wrote:
(2020-04-12, 12:36)sba923 Wrote: I confirm this is a usable workaround. But this uses precious space in the tiles, and there's still a bug if you ask me  Wink

I'm not sure that it's a bug.  Kodi is working by design (or at least, the current design Wink ).  You should be only using/losing 3 or 4 chars at most so even on a small screen that shouldn't be too much of an issue.  There is a possible issue that your posts have thrown up but I need to dig further into it before committing myself as to whether it is indeed an issue. 

Well... The cogwheel menu for an album (list of songs therein) defaults to "Sort by: Track, Sort: Ascending", and there is no "Sort by: Label" option in the list (the "Name" choice actually maps to SortByLabel, see line 276 of GUIViewStateMusic.cpp, but would a user understand that "Name" corresponds to "whatever has been set as the 'Track naming template'"? Maybe...).

So, with my user hat on, I consider that if the UI says "Sort by: Track, Sort: Ascending" then sorting must be done by "Track" not by "Name."

Before I open an actual bug on GH, I'm still looking for:
- the place where that (default? last set? setting of) "Sort by: Track, Sort: Ascending" is coming from
- where the code at line 550 of GUIViewStateMusic.cpp should retrieve the current (configured / default) sorting specification from instead of forcing it to SortByLabel
Reply
#14
(2020-04-12, 16:45)sba923 Wrote:
(2020-04-12, 14:26)black_eagle Wrote:
(2020-04-12, 12:36)sba923 Wrote: I confirm this is a usable workaround. But this uses precious space in the tiles, and there's still a bug if you ask me  Wink

I'm not sure that it's a bug.  Kodi is working by design (or at least, the current design Wink ).  You should be only using/losing 3 or 4 chars at most so even on a small screen that shouldn't be too much of an issue.  There is a possible issue that your posts have thrown up but I need to dig further into it before committing myself as to whether it is indeed an issue.  

Well... The cogwheel menu for an album (list of songs therein) defaults to "Sort by: Track, Sort: Ascending", and there is no "Sort by: Label" option in the list (the "Name" choice actually maps to SortByLabel, see line 276 of GUIViewStateMusic.cpp, but would a user understand that "Name" corresponds to "whatever has been set as the 'Track naming template'"? Maybe...).

So, with my user hat on, I consider that if the UI says "Sort by: Track, Sort: Ascending" then sorting must be done by "Track" not by "Name."

Before I open an actual bug on GH, I'm still looking for:
- the place where that (default? last set? setting of) "Sort by: Track, Sort: Ascending" is coming from
- where the code at line 550 of GUIViewStateMusic.cpp should retrieve the current (configured / default) sorting specification from instead of forcing it to SortByLabel 

Can someone help me find the information I need to file an issue on GH?
Reply
#15
It's only set to SortByLabel the first time the view is opened.  Any alteration to the view (that a user has made) will be loaded by line 557, overriding the earlier default settings.  Anytime you change the default sorting rules in the sideblade they are saved into a database along with the (internal) path to the items you are viewing.  This means that when you open a view, the defaults get set up and then the database is checked for that path and if there is a match, the defaults are overridden by the order, sort by etc for that path.  If the path doesn't exist the defaults are used.

@DaveBlake may be able to explain it better than me.
Learning Linux the hard way !!
Reply
 
Thread Rating:
  • 0 Vote(s) - 0 Average



Logout Mark Read Team Forum Stats Members Help
Incorrect default sort order00
This forum uses Lukasz Tkacz MyBB addons.