Kodi Community Forum
Solved Subtitle list not being ordered as requested - Printable Version

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Add-on Support (https://forum.kodi.tv/forumdisplay.php?fid=27)
+---- Forum: Subtitle Add-ons (https://forum.kodi.tv/forumdisplay.php?fid=143)
+---- Thread: Solved Subtitle list not being ordered as requested (/showthread.php?tid=190531)



Subtitle list not being ordered as requested - tebicenter - 2014-03-27

Hi

I'm porting the argenteam addon to work as a service, so far so good.

The problem that I'm having is that when I set the list of subtitles to show on the results list, I'm not able to set the corrected order.

I'm using the following code:

Code:
def append_subtitle(items):

    items.sort(key=lambda x: x['rating'], reverse=True)

    for item in items:
        listitem = xbmcgui.ListItem(label=item['lang'],
                                label2=item['filename'],
                                iconImage=item['rating'],
                                thumbnailImage=item['image'])

        #listitem.setProperty("sync",  'true' if item["sync"] else 'false')
        #listitem.setProperty("hearing_imp", 'true' if item["hearing_imp"] else 'false')

        ## below arguments are optional, it can be used to pass any info needed in download function
        ## anything after "action=download&" will be sent to addon once user clicks listed subtitle to downlaod
        url = "plugin://%s/?action=download&link=%s&filename=%s&id=%s" % (__scriptid__,
                                                                    item['link'],
                                                                    item['filename'],
                                                                    item['id'])

        ## add it to list, this can be done as many times as needed for all subtitles found
        xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=url, listitem=listitem, isFolder=False)

the list "items" is sorted correctly, I checked that using print to see if values are modified. But once I added to the plugin, they are shown in other order.

What could be wrong?


RE: Subtitle list not being ordered as requested - fape88 - 2014-03-27

I noticed it too. Xbmc (re)orders by path source code. In this case Path is (action) url.
But I have a workaround: source code I manualy added an 'actionsortorder' query param to get the proper sort order on the UI.


RE: Subtitle list not being ordered as requested - tebicenter - 2014-03-28

Thanks!!!! That did the trick!!