Heads-up: How to deal with content types / media types

  Thread Rating:
  • 1 Vote(s) - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
phil65 Offline
Team-Kodi Developer
Posts: 6,687
Joined: Mar 2009
Reputation: 147
Location: Cologne, Germany
Post: #1
We missed some proper documentation about how to deal with content types properly, so here is a quick write-up how skinners should deal with adjusting the views for all the different types of content Kodi is supporting.

Kodi (core as well as plugins) assigns content types to both the complete containers and also to each individual listitem so that skinners can show appropriate views and metadata for each occasion. Often these two basically go hand-in-hand (like "movies" for container content and "movie" for listitem dbtype), but there are also exceptions to the rule. (examples: playlists with mixed content, or movies which are linked to tvshows) It is important to know about this and when to choose what for visible conditions for example.


For a start, here is a list of all available content types including some remarks and where you need to deal with them (in brackets)

Quote:"" (empty) - used for "categories" / "nodes", like our library root. (all mediawindows)
tags (videos and music)
years (videos and music)
genres (videos and music)
countries (videos and music)
studios (videos and music)
playlists (videos and music)
movies (videos) - general guideline: this one is used for everything which can be found on sites like themoviedb.com.
sets (videos)
tvshows (videos) - general guideline: this one is used for everything which can be found on sites like thetvdb.com
seasons (videos)
artists (videos and music) - used for both albums and musicvideos
albums (videos and music) - same
songs (music)
musicvideos (videos and music)
addons (addonbrowser, videos, music, pictures, programs)
actors (videos)
directors (videos)
files (videos, music) - used for library nodes with no content set
mixed (videos, music) - for mixed song/musicvideo playlists
images (pictures)
games (games) - since v18
unknown (videos) - set by uPnP sources
events (eventlog)
videos (videos) - this one here is for all videos which do not apply to the more specific mentioned ones like "movies", "episodes" etc. A good example are youtube videos. This one wasnt well-communicated up to now so please add this to viewtypes which are appropriate.


And here is a list with all available dbtypes for listitems:

Quote:artist
album
song
video
set
musicvideo
movie
tvshow
season
episode
music (not really used (yet), so can be ignored for now I think.)

Where should I use what?
Container.Content(xx) should be used for the selection of available viewtypes in general. So main use case is to use this for the visible condition of all your viewtype containers as well as for the item/focusedlayouts of these containers. For "furniture" (=stuff outside of the containers, like InfoPanels with metadata), it is better to use String.IsEqual(ListItem.DBType,xx) in most cases.
In your InfoDialog xmls you shouldnt use Container.Content(xx) at all, please use String.IsEqual(ListItem.Dbtype,xxx) there exclusively. InfoDialog layout should only be dependent on the listitem type, not on anything container-related.

In general it might be a good idea to start a skin with some very basic list which is allowed for every content type (=no visible conditions). When having that done, add specialised viewtypes for specific content types as you deem necessary.

It would be cool if skins from v16 on could deal with content types / dbtypes as described, so some backporting would be nice.

If you have further questions concerning this topic, feel free to ask. I hope this clears up some confusion because we are not the best when it comes to documentation in this area. Ideas / pointing out errors are also welcome, this is really just written down from out of my head.

Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
(This post was last modified: 2016-12-30 02:53 by phil65.)
find quote
braz Offline
Skilled Skinner
Posts: 3,255
Joined: Aug 2012
Reputation: 100
Post: #2
Thanks Phil, great guide. I mostly follow this in Mimic, but having one issue with the video info dialog. I have a button that I want to display for all listitem types except seasons. So I tried !String.IsEqual(ListItem.DBTYPE,season) as the visibility condition but this doesn't work, the button still shows on seasons. If I change it to !Container.Content(seasons), then I get the visibility I'm looking for.

Is there something weird going on with how the video info dialog interprets the season dbtype? It seems like I've run into a few other cases like this, going to look for them now...

Thanks!
find quote
phil65 Offline
Team-Kodi Developer
Posts: 6,687
Joined: Mar 2009
Reputation: 147
Location: Cologne, Germany
Post: #3
the thing is: there is no infodialog for seasons. Wink
At the moment core just makes it open the infodialog of the corresponding tvshow, so listitem.dbtype probably returns "tvshow", and that´s why it doesnt work. I can understand why skinners want to make the infodialog for seasons look different, but atm core just doesnt allow that in a sane way, so if you want to workaround these core limitations you have to use hacks.

Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
(This post was last modified: 2016-12-07 02:08 by phil65.)
find quote
marcelveldt Offline
Skilled Skinner
Posts: 8,176
Joined: Jul 2014
Reputation: 333
Location: The Netherlands
Post: #4
Thanks for the guide Phil!
Question: How are PVR channels and recordings handled internally ?

For my PVR widgets generated by skinhelper I tried to set the DBTYPE to "channels" or "recordings" for python but always get a unsupported contenttype error in the logs.

Also, it seems that you can't set the DBID as infolabel on music items, only videoitems work.
find quote
ronie Offline
Team-Kodi Member
Posts: 13,179
Joined: Jan 2009
Reputation: 392
Post: #5
(2016-12-19 09:56)marcelveldt Wrote:  Also, it seems that you can't set the DBID as infolabel on music items, only videoitems work.

https://github.com/xbmc/xbmc/pull/10858

Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ and Search the forum before posting.
For troubleshooting and bug reporting please make sure you read this first.
find quote
marcelveldt Offline
Skilled Skinner
Posts: 8,176
Joined: Jul 2014
Reputation: 333
Location: The Netherlands
Post: #6
(2016-12-19 12:52)ronie Wrote:  
(2016-12-19 09:56)marcelveldt Wrote:  Also, it seems that you can't set the DBID as infolabel on music items, only videoitems work.

https://github.com/xbmc/xbmc/pull/10858

Thanks! So, this will be added in v18 ?
find quote
ronie Offline
Team-Kodi Member
Posts: 13,179
Joined: Jan 2009
Reputation: 392
Post: #7
yup.

Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ and Search the forum before posting.
For troubleshooting and bug reporting please make sure you read this first.
find quote
phil65 Offline
Team-Kodi Developer
Posts: 6,687
Joined: Mar 2009
Reputation: 147
Location: Cologne, Germany
Post: #8
I missed one (rather strange) content type: "unknown". That one gets set by uPnP sources sometimes, sadly cannot remember exactly for what.

Donate: https://kodi.tv/contribute/donate (foundation), 146Gr48FqHM7TPB9q33HHv6uWpgQqdz1yk (BTC personal)
Estuary: Kodis new default skin - ExtendedInfo Script - KodiDevKit
find quote
ronie Offline
Team-Kodi Member
Posts: 13,179
Joined: Jan 2009
Reputation: 392
Post: #9
for completeness sake, there's content type 'events' as well.
only used in the eventlog window ofc.

Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ and Search the forum before posting.
For troubleshooting and bug reporting please make sure you read this first.
find quote
marcelveldt Offline
Skilled Skinner
Posts: 8,176
Joined: Jul 2014
Reputation: 333
Location: The Netherlands
Post: #10
And what about tvchannels and recordings ?
How to set them from python as content type ?

I tried DBTYPE channels and tvchannels, both giving me a warning in the logs.

This reminds me that I have to get myself familiar with the kodi source code ;-)
find quote
ronie Offline
Team-Kodi Member
Posts: 13,179
Joined: Jan 2009
Reputation: 392
Post: #11
currently, there's little to no support for anything pvr related in python.

also, there's no content type / DBTYPE defined in kodi for channels, programmes & recodings afaik.

Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ and Search the forum before posting.
For troubleshooting and bug reporting please make sure you read this first.
find quote
marcelveldt Offline
Skilled Skinner
Posts: 8,176
Joined: Jul 2014
Reputation: 333
Location: The Netherlands
Post: #12
Ah, ok, thanks for the info.
For now, I'll just not set the dbtype for pvr content, in that case Kodi will auto fallback to "unknown" (I think).
Once I get my head around the Kodi code I'll try to add the support myself.
find quote
marcelveldt Offline
Skilled Skinner
Posts: 8,176
Joined: Jul 2014
Reputation: 333
Location: The Netherlands
Post: #13
Sorry to be a pain, found a little issue regarding this topic. The Kodi json api is currently outputting some strange results for the type field.
Instead of type "album" it's outputting "Compilation" or "Album" etc. while it should be just "album" imo.
Because I use the type from the json api and set that as content type in the listitems it's resulting in errors like: Invalid media type "Compilation"

Is this behaviour intended and should I work around it in my addon by converting the values to "album" ?

PHP Code:
{u'rating'0u'year'1972u'musicbrainzalbumid'u'be960473-e5bd-46ea-aeae-86190ca7356a'u'style': [], u'mood': [], u'title'u'The Ultimate Fan Extras Collection'u'fanart'u'image://smb%3A%2F%2Fhomeserver%2FData%2FMuziek%2FCollectie%2FM%2FMichael%20Jackson%2Ffan​art.jpg/'u'artistid': [2256], u'label'u'The Ultimate Fan Extras Collection'u'albumid'4542u'theme': [], u'type'u'Compilation'u'thumbnail'u'image://smb%3A%2F%2Fhomeserver%2FData%2FMuziek%2FCollectie%2FM%2FMichael%20Jackson%2FThe​%20Ultimate%20Fan%20Extras%20Collection%2Ffolder.jpg/'u'description'u''u'genre': [u'Pop;70s;80s;Soul;Dance;Disco;Easy Listening;R&B;Soundtrack'], u'genreid': [552055315532553355345535], u'dateadded'u'2016-07-24 01:01:20'u'artist': [u'Michael Jackson'], u'albumlabel'u''u'musicbrainzalbumartistid': [u'f27ec8db-af05-4f36-916e-3d57f91ecf5e'], u'displayartist'u'Michael Jackson'u'playcount'0

Note that all other json endpoints (e.g. for movies etc) report the type field lowercase and only with the types that are globally excepted as in the first post of this topic.
find quote
ronie Offline
Team-Kodi Member
Posts: 13,179
Joined: Jan 2009
Reputation: 392
Post: #14
that's the album type as far as i can tell.
it's not related to media type.

Do not PM or e-mail Team-Kodi members directly asking for support.
Always read the Forum rules, Kodi online-manual, FAQ and Search the forum before posting.
For troubleshooting and bug reporting please make sure you read this first.
find quote
marcelveldt Offline
Skilled Skinner
Posts: 8,176
Joined: Jul 2014
Reputation: 333
Location: The Netherlands
Post: #15
(2017-01-05 00:14)ronie Wrote:  that's the album type as far as i can tell.
it's not related to media type.

Hmmm, but why do all other json endpoints return the mediatype as the type property except for the album one ?
It doesn't seem very consistent to me but maybe I'm missing something very obvious :-)
find quote
Post Reply