Container.SetSortMethod....
#1
Okay, this really shouldn't be as difficult as it is... All of the info is years old and there is plenty of it conflicting.

Firstly, I have noticed that there are two lists. One is SortUtils.h, which seems to carry the IDs for Container.SetSortMethod(). The other is SortFileItem.h, which has its values copied to xbmcplugin.py and is used to add sort methods to a ListItem. They are different, and that's really aggravating for one thing, but I understand that you guys are busy, breaking API...okay you guys seem fine with that one lately if it has more benefits than drawbacks, and migrating enums that aren't exactly 1 to 1 is just a pain. 

What I am trying to do:
I build a list. I add some sort items to it. Yes, these items are pretty simple and from what I can tell, they work. Things stop going smoothly from here.
I built this Beautiful Class that does the mapping for me. Based on certain conditions, a script calls string2id.get(name) and feeds it to 'Container.SetSortMethod(id)'. This should work, I think. The issue is that it sometimes works.... I can't set some of the sorting IDs for Container.SetSortMethod(). The one in particular that I noticed is not working is Episode. The container ID should be 23 and the listitem ID should be 24. It gets added to the sort list, but it isn't selected. It seems to select 'Date', but not the same 'Date' that is already there. Selecting it manually does work.

python:

xbmcplugin.addSortMethod(handle, Sorting.none.listitem_id)
xbmcplugin.addSortMethod(handle, Sorting.episode_number.listitem_id)
xbmcplugin.addSortMethod(handle, Sorting.date.listitem_id)
xbmcplugin.addSortMethod(handle, Sorting.title.listitem_id)
xbmcplugin.addSortMethod(handle, Sorting.rating.listitem_id)
xbmcplugin.addSortMethod(handle, Sorting.year.listitem_id)
I add items to the sort list like so. The directory content type is 'episodes'. It is filled with playable items, and the infolabels are all set as needed.

Any input would be useful. I would prefer not to change the order in which I add things to the Sort List.
Developer for Shoko and Nakamori. Long time user of Kodi, before it was even called Kodi. My XBOX died long ago, but Windows is still just as broken and necessary. I obviously watch anime, given my first comment. Video games, manga, music, you name it.
Reply
#2
An update on what I've been trying:
It seems to work when you do things in this order exactly:
python:
xbmcplugin.setContent(handle, content_type)
xbmcplugin.addSortMethod(handle, listitem_id)
-- add items to directory --
-- endOfDirectory --
xbmc.executebuiltin('Container.SetSortMethod(id)')

It still needs the conversion class, as they take different values.

EDIT: I seem to be having a different issue. Default sorting, which is the state of not changing the order in which items are added from code has an item in SortFileItem.h called SORT_METHOD_UNSORTED. By sheer guesswork, I'd assume that the item called Random in SortUtils.h corresponds to it. Using it does nothing, however. I understand the concept of not being able to unsort a list if we didn't store the previous state, but it's still annoying that we can't programmatically select it. If it's not selected, then it forces lists to use the sort method that Kodi cached from the last time that the list was opened. If we can at least select Default, then that should prevent the caching from interfering.
I don't think it's possible, but if anyone knows, it'd be nice.
Developer for Shoko and Nakamori. Long time user of Kodi, before it was even called Kodi. My XBOX died long ago, but Windows is still just as broken and necessary. I obviously watch anime, given my first comment. Video games, manga, music, you name it.
Reply

Logout Mark Read Team Forum Stats Members Help
Container.SetSortMethod....0