Problems blending DirectoryObject & VideoClipObject within the same container

I'm running into an awkward issue with objects displaying out of their assigned order. Basically what's happening is that when I add a bunch of objects to the container, the results seem to be placing all of my VideoClipObjects to the top of the list, while the DirectoryObjects are at the bottom of the list; instead of in their correct blended position. At this menu level, the container may contain a VideoClipObject or a DirectoryObject (for either a playlist or error message). Although the index numbers are assigned correctly, the actual display order seems to put all DirectoryObjects to the bottom (kind of how windows filters folders to the top of a file list) and it is driving me crazy!!

 

I've check all logic and all assignments are made during the loop so I do not understand how this is happening unless Plex is re-ordering it on it's own based on the type of object. If this is to be expected, can I stop it? It's completely destroying my alphabetical order and the only other workaround would be to add an extra level for video clips to keep them all as DirectoryObjects and retain the order. That said, this would cause unnecessary extra clicks for the user to do that so I'd like to keep that as a last resort.

 

Below is an example of the code, as you can see it all falls under the for loop so the order should be retained automatically (note that I have removed some unrelated code to keep it simple. If this issue is self generated, then it would have to be within the try/except clauses and not within random string definitions).

 

Sample Code:

for i, key in enumerate(keys):
    i = i+1
    item = {"title": "%s. " % (i), "thumb_url": ICON, "summary": "",
            "ratings": "0.0", "votes": "0", "url": "", "genre": ""}
    try:
        #(...variable definitions go here...)
        if "youtube" in item["url"]:
            if y_id[1] == TYPE_PLAYLIST:
                oc.add(DirectoryObject(
                    key     = Callback(PlaylistMenu, pl_id=y_id[0], heading=genre, url=item["url"], page=1, items=items["data"]),
                    title   = item["title"],
                    thumb   = Resource.ContentsOfURLWithFallback(url=item["thumb_url"], fallback=ICON),
                    summary = item["summary"],
                    ))
            else:
                if "status" in url:
                    raise Ex.MediaNotAvailable
                else:
                    oc.add(VideoClipObject(
                        url     = "http://www.youtube.com/watch?v=%s" % (y_id[0]),
                        title   = item["title"],
                        summary = item["summary"],
                        thumb   = Resource.ContentsOfURLWithFallback(url=item["thumb_url"], fallback=ICON)
                        ))
        elif URLService.ServiceIdentifierForURL(item["url"]):
            oc.add(VideoClipObject(
                url     = item["url"],
                title   = item["title"],
                summary = item["summary"],
                thumb   = Resource.ContentsOfURLWithFallback(url=item["thumb_url"], fallback=ICON)
                ))
        else:
            raise Ex.MediaNotAvailable
    except Ex.HTTPError, error:
        Log(str(error.code))
        Log(i)
        if error.code == 403:
            Log("MediaNotAuthorized2")
            head_msg = ("MediaNotAuthorized Error", "The selected media has been made unavailable by the author")
        elif error.code == 404:
            Log("MediaNotAvailable3")
            head_msg = ("MediaNotAvailable Error", "The selected media has been removed by the author.")
        oc.add(DirectoryObject(
            key     = Callback(ErrorMessage, header=head_msg[0], message=head_msg[1]),
            title   = item["title"],
            thumb   = Resource.ContentsOfURLWithFallback(url=item["thumb_url"], fallback=ICON),
            summary = item["summary"],
            ))
    except:
        Log("MediaNotAvailable4")
        Log(format_exc())
        Log("")
        Log("")
        oc.add(DirectoryObject(
            key     = Callback(ErrorMessage, header="MediaNotAvailable Error", message="The selected media is unavailable."),
            title   = item["title"],
            thumb   = Resource.ContentsOfURLWithFallback(url=item["thumb_url"], fallback=ICON),
            summary = item["summary"],
            ))

Screenshots of the issue:

(If you pay close attention to "order2.png" you will see that although they are out of order, their index numbers are correct which implies the loop did it job fine and something else is taking over. I can also verify that it is ONLY DirectoryObjects being moved around, all VideoClipObject's are in proper order)

 

 

Any thoughts?

Hi,

The best way I have found to order directory and video objects etc is to add them to a list in the order you require, then add the list to the container when you create the container, rather than adding the objects to the container one by one. Having said this, I still have some clients that display the objects in the incorrect order, such as the plex player on the Samsung Smart TV. So I came to the conclusion because of this that the ordering is ultimately determined by the client being used. This code is lifted from my dreambox plugin

    items = []

    ....

    ....

    items.append(DirectoryObject(key=Callback(Display_Bouquets),
                                   title=Locale.LocalString('Live'),
                                   thumb = R(LIVE),
                                   tagline=Locale.LocalString('LiveTag')))
     ...
     ...
     oc = ObjectContainer(objects=items, view_group='List', no_cache=True)

Hi,

The best way I have found to order directory and video objects etc is to add them to a list in the order you require, then add the list to the container when you create the container, rather than adding the objects to the container one by one. Having said this, I still have some clients that display the objects in the incorrect order, such as the plex player on the Samsung Smart TV. So I came to the conclusion because of this that the ordering is ultimately determined by the client being used. This code is lifted from my dreambox plugin

    items = []

    ....

    ....

    items.append(DirectoryObject(key=Callback(Display_Bouquets),
                                   title=Locale.LocalString('Live'),
                                   thumb = R(LIVE),
                                   tagline=Locale.LocalString('LiveTag')))
     ...
     ...
     oc = ObjectContainer(objects=items, view_group='List', no_cache=True)

Thanks for your suggestion, I did see that alternate method but I am yet to test it out. I'll give it a whirl to see if that helps at all. :)

With regards to your comment about your Samsung TV, I'm glad you pointed it out as I am yet to test it on my Samsung in the other room. As I don't really play from my PC much, so far I have used Plex Web for the majority of my testing. I have however ran a few tests on a phone/tablet. Although really nice, fullscreen + keyboard nav is not my cup of tea.

In case you might remember, when you ran into this issue were you also trying to add both VideoClipObject & DirectoryObject to the same ObjectContainer? If so, was the reaction the same where the directory objects group together?

Imho, it seems too similar to how an OS would group files/folders separately so I get the feeling this might be an expected outcome and out of my control. The fact that the numbers next to the titles are assigned in correct order also suggests the for loop successfully added them in the correct order.

All items below object "1." are DirectoryObjects, and they also have their correct index number, as well as alpha order. I listed the first 10 below:

Top of List:

2. 9/11 Chronicles: Truth Rising
4. 9/11 False Flag
6. 9/11 Revisited, Were Explosives Used?
9. 9/11: 10 Years Later  (*this one looks odd but if "10" is auto-corrected to "Ten" while sorting, it works...*)
10. 9/11: THE SENSIBLE DOUBT

Bottom of List:

1. 102 Minutes That Changed America
3. 9/11 Eyewitness
5. 9/11 Mysteries
7. 9/11 The Explosive Reality
8. 9/11 The Firemens Story

Yes they were a mixture of both now I come to think of it.


Sent from my HTC One using Tapatalk

Yes they were a mixture of both now I come to think of it.

Sent from my HTC One using Tapatalk

Thanks for the verification that it's not just me :P

Could one of the Plex Dev's please verify if this is expected behavior, or if it should be reported as a bug?

  - If this is to be expected, is there any way to disable such re-ordering from within a Channel so we can retain the manually specified order?

TIA!

I don’t know off hand if this is expected behaviour or not. I’m also not sure if it’s the client app that is reordering things or PMS/plugin-framework. It would be helpful to look at the XML generated by the plugin to determine if things are properly ordered there.

I don't know off hand if this is expected behaviour or not. I'm also not sure if it's the client app that is reordering things or PMS/plugin-framework. It would be helpful to look at the XML generated by the plugin to determine if things are properly ordered there.

Thanks for the advice, but could you please tell me where said XMLs might be located? :P Are you referring to the files in Plug-in Support/Data?

*UPDATE*

Works perfectly fine on Android on both tablet & phone, and the order is also retained in PHT; although other display issues became apparent while testing with PHT where at least half of my titles are not showing up. I'm pretty sure the title issue is an encoding problem, I used encoding="utf-8", errors="ignore" for the moment so I think it's doing just that and ignoring them.

*UPDATE2*

Apparently I was wrong about Android. Although the order & titles are correct and displaying fine, the next page button does not show up all, like it does with Plex Web & Plex for Android?

Usually the simplest way to view the xml is to hit the plugin directly using a browser or cURL.

http://:32400/

You'll get something like this (taken form the YouTube channel):








The "key" value for each object is what clients use to "walk the tree" of the XML. You can do the same manually by appending the chosen key to the PMS url.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.