Another user asked a similar question within one of my release threads. Decided to answer them and you here.
@EnglishMossop said:
I feel like it could be controlled by the view_group but can’t find what the valid values for viewMode, mediaType and type are when calling Plugin.addViewGroup. Any help?
@NotVinny said:
@Nosinden said:
There are some channels that have used the view_group param, and I’ve checked them out in the past to get an idea of how to use them. I’ll do some digging again and post a better response after fixing my code.
Would love to have an understanding of this, but don’t worry too much. I just thought maybe you had worked with them before. I won’t lose any sleep over it 
Current valid view modes dict:
view_modes = {
"List": 65586, "InfoList": 65592, "MediaPreview": 458803, "Showcase": 458810, "Coverflow": 65591,
"PanelStream": 131124, "WallStream": 131125, "Songs": 65593, "Seasons": 65593, "Albums": 131123,
"Episodes": 65590," ImageStream":458809," Pictures":131123
}
I know List is the same as it is within Plex Web Client, and InfoList is same as Details list within Plex Web Client. The rest I do not know, but assume they help dictate or mimic the TVShowObject & SeasonObject as well as other Objects that have specific arrangements of metadata.
Plugin.AddViewGroup() defaults:
Plugin.AddViewGroup(name, viewMode="List", mediaType="items", type=None, menu=None, cols=None, rows=None, thumb=None, summary=None)
Basic usage of the Plugin.AddViewGroup() can be found within the A Beginner’s Guide to v2.1 support page.
ViewTypes
# Initialize the plug-in
Plugin.AddViewGroup("Details", viewMode="InfoList", mediaType="items")
Plugin.AddViewGroup("List", viewMode="List", mediaType="items")
These lines are configuring the type of ViewTypes that the plug-in might want to use. I’m sure you’ve all noticed that within the OS X client of Plex it’s possible to change the type of view being displayed at any time. However, for the iOS client this is not configurable. Therefore, the developer needs to decide which view types make sense for each Container object returned by the Plug-in. This plug-in defines a single group, called “List” which actually maps to the Plex View Type of “List”. You should note that you can add multiple of these for different types.
For more examples, try the GitHub search Plugin.AddViewGroup.
Further digging within the constkit.py shows a view type and a summary type:
class ViewTypes(Framework.ConstantGroup):
_excluded_policies = [
Framework.policies.ModernPolicy,
]
Grid = 'grid'
List = 'list'
class SummaryTextTypes(Framework.ConstantGroup):
_excluded_policies = [
Framework.policies.ModernPolicy,
]
NoSummary = 0
Short = 1
Long = 2
The Plugin.AddViewGroup() has params for type and summary. My hunch is these constants are for those parameters. My guess would be:
Plugin.AddViewGroup("season_test", viewMode="Seasons", mediaType="episodes", type="list", summary=1)
# then to use within an ObjectContainer
oc = ObjectContainer(title2="Season Test View", view_mode="season_test")
# I assume this may mimic a behavior similar to the SeasonObject but not sure
As for the mediaType I’m unsure of valid input, but assume it can be either items (default), episodes, photos, songs, or videos. There may be more, but that’s all I’ve been able to find from other repos.
Notes:
Remember the ObjectContainer() has a cache time tied to the global HTTP.CacheTime that can also be declared within the Start() function. If no cache time is set, then the Framework will use the default per client. Optionally the no_cache param can be set to True overriding the global cache time for that ObjectContainer()
Example:
ObjectContainer(no_cache=True)
From the Framework documentation (applies to ObjectContainer):
no_history
A boolean specifying whether the container should be added to the client’s history stack. For example, if Container B in the sequence A => B => C had no_cache set to True, navigating back from C would take the user directly to A.
replace_parent
A boolean specifying whether the container should replace the previous container in the client’s history stack. For example, if Container C in the sequence A => B => C had replace_parent set to True, navigating back from C would take the user directly to A.
no_cache
A boolean indicating whether the container can be cached or not. Under normal circumstances, the client will cache a container for use when navigating back up the directory tree. If no_cache is set to True, the container will be requested again when navigating back.
Besides no_cache there are no_history and replace_parent. Depending on the application, these params can also be manipulated. Note the PopupDirectoryObjects() acts like it has the no_history=True, but is inherently set and cannot be overridden.
So, be careful of cache times when playing with the view_mode. If a long cache time is set, or no cache time is set, then the view_mode option may not apply right away. Also each client has a separate cache system and timing. Some are longer than others.
Finally, some clients flat-out ignore the view_mode parameters and present media by how the clients are codded. I don’t remember where I read this, but do know the info came from a Plex-Employee. In reality the view_mode will not force all clients to act the same.
@EnglishMossop said:
I output the same code for various different ObjectContainers but each time Plex seems to either present a list or a gallery of thumbs based on the number in the list or something. Is there a way to force it?
As-far-as forcing goes, if the above does not help, then here are some of my other findings.
If you always want a list to show up, lets say within the Android and iOS Clients, but want icons for all other clients then try keying the thumbs to the Client.Platform, example:
oc = ObjectContainer() # no_cache=True if client does not auto refresh when a directory changes
match = Client.Platform not in ['Android', 'iOS'] # match all patforms except Android and iOS
# pretend we have a list of dict items to create a list of directories
for d in items:
oc.add(DirectoryObject(
key=Callback(Test, data=d),
title=d['title'],
thumb=R(d['resources_icon']) if match else None,
#thumb=d['thumb'] if match else None # if using URLs and not icons
))
return oc
resources_icon represents an icon within your channel’s Resources directory, i.e. icon-example.png. Normally when Plex is presented a list of objects with the same icon (which can all be None too), then it will default to a list view.
For some clients, if a list of DirectoryObject only have titles and thumbs, but the titles are extremely long, then the client will default to the list view. If the summary is set for most of those objects, then most clients will display the objects as either a detailed list (showing the thumb, title and summary) or a photo grid (showing the thumb and title only).
Besides DirectoryObject there are also TVShowObject, and SeasonObject, which have a different set of rules as to how their media is presented per client. You may find that one of them suits your needs better than using the DirectoryObject. For example, both the Fox.bundle and Lifetime.bundle utilize the TVShowObject, and SeasonObject.