General questions about xbmcplugin.addSortMethod()
#1
I'm currently trying to add some sort methods to my addon (plugin.audio.addict) and I'm running into problems in terms of xbmcplugin.addSortMethod() usage.

I have a list of radio channels which I map to xbmcgui.ListItem() objects. About these channels I know the date when they've been created so I thought it would be nice to add a sort method which allows to sort the list according to the creation date of the channels, so the users can see what channels are new just by sorting the list descending.

Now I was studying the API and found xbmcplugin.addSortMethod() which seems to do what I want.
If I understand this API correct, than it allows only to add pre-defined sort methods? So it seems not possible to add a 'custom sort' with custom name and custom sort function?

What I did so far to add this kind of sorting is:

Code:
list_item.setInfo('video', {'dateadded': date})
xbmcplugin.addSortMethod(addon.handle, xbmcplugin.SORT_METHOD_DATEADDED)

This works but that might be not the way how it is correct? For 'setInfo' I used 'video' since 'music' was giving me errors in the log that 'dateadded' isn't supported for 'music'. But my addon is an audio addon, so I wonder if this is the way to do it? About the other question I mentioned earlier I'm curious too if it is possible to define total custom sort methods?
Reply
#2
Try this before:
xbmcplugin.setContent(int(sys.argv[1]), 'music')
Reply
#3
(2017-07-21, 22:48)antrrax Wrote: Try this before:
xbmcplugin.setContent(int(sys.argv[1]), 'music')

This doesn't work, I think the explanation is that 'dateadded' is just not supported for audio content, see: ListItem (method=setInfo)!

The snippet I showed earlier works even if my addon isn't providing 'video' content. My question is if there is a better way to achieve what I want or if my shown snippet could cause some side-effects? Maybe another solution would be:

Code:
list_item.setInfo('audio', {'date': date})
xbmcplugin.addSortMethod(addon.handle, xbmcplugin.SORT_METHOD_DATE)

But date (d.m.Y) isn't that precise as dateadded (Y-m-d h:m: s) but maybe in my case I wouldn't need it anyway that precise.
Reply

Logout Mark Read Team Forum Stats Members Help
General questions about xbmcplugin.addSortMethod()0