Listitem¶
The “listitem” control is used for the creating of item lists in Kodi.
-
class
codequick.listing.
Listitem
(content_type='video')[source]¶ The “listitem” control is used for the creating “folder” or “video” items within Kodi.
Parameters: content_type (str) – [opt] Type of content been listed. e.g. “video”, “music”, “pictures”. -
subtitles
= list()¶ List of paths to subtitle files.
-
art
= Art()¶ Dictionary like object for adding “listitem art”. See
listing.Art
for more details.
-
info
= Info()¶ Dictionary like object for adding “infoLabels”. See
listing.Info
for more details.
-
stream
= Stream()¶ Dictionary like object for adding “stream details”. See
listing.Stream
for more details.
-
context
= Context()¶ List object for “context menu” items. See
listing.Context
for more details.
-
property
= dict()¶ Dictionary like object that allows you to add “listitem properties”. e.g. “StartOffset”.
Some of these are processed internally by Kodi, such as the “StartOffset” property, which is the offset in seconds at which to start playback of an item. Others may be used in the skin to add extra information, such as “WatchedCount” for tvshow items.
Examples: >>> item = Listitem() >>> item.property['StartOffset'] = '256.4'
-
params
= dict()¶ Dictionary like object for parameters that will be passed to the “callback” function.
Example: >>> item = Listitem() >>> item.params['videoid'] = 'kqmdIV_gBfo'
-
listitem
= None¶ The underlining kodi listitem object, for advanced use.
-
label
¶ The listitem label property.
Example: >>> item = Listitem() >>> item.label = "Video Title"
-
set_path
(path, is_folder=False, is_playable=True)[source]¶ Set the listitem’s path.
- The path can be any of the following:
- Any kodi path, e.g. “plugin://” or “script://”
- Directly playable URL or filepath.
Note
When specifying a external ‘plugin’ or ‘script’ as the path, Kodi will treat it as a playable item. To override this behavior, you can set the
is_playable
andis_folder
parameters.Parameters: - path – A playable URL or plugin/script path.
- is_folder – Tells kodi if path is a folder (default ->
False
). - is_playable – Tells kodi if path is a playable item (default ->
True
).
-
set_callback
(callback, *args, **kwargs)[source]¶ Set the “callback” function for this listitem.
- The “callback” parameter can be any of the following:
codequick.Script
callback.codequick.Route
callback.codequick.Resolver
callback.- A callback reference object
Script.ref
.
Parameters: - callback – The “callback” function or reference object.
- args – “Positional” arguments that will be passed to the callback.
- kwargs – “Keyword” arguments that will be passed to the callback.
-
classmethod
from_dict
(callback, label, art=None, info=None, stream=None, context=None, properties=None, params=None, subtitles=None)[source]¶ Constructor to create a “listitem”.
This method will create and populate a listitem from a set of given values.
Parameters: - callback (Callback) – The “callback” function or playable URL.
- label (str) – The listitem’s label.
- art (dict) – Dictionary of listitem art.
- info (dict) – Dictionary of infoLabels.
- stream (dict) – Dictionary of stream details.
- context (list) – List of “context menu” item(s) containing “tuples” of (“label”, “command”) pairs.
- properties (dict) – Dictionary of listitem properties.
- params (dict) – Dictionary of parameters that will be passed to the “callback” function.
- subtitles (list) – List of paths to subtitle files.
Returns: A listitem object.
Return type: Example: >>> params = {"url": "http://example.com"} >>> item = {"label": "Video Title", "art": {"thumb": "http://example.com/image.jpg"}, "params": params} >>> listitem = Listitem.from_dict(**item)
-
classmethod
next_page
(*args, **kwargs)[source]¶ Constructor for adding link to “Next Page” of content.
By default the current running “callback” will be called with all of the parameters that are given here. You can specify which “callback” will be called by setting a keyword only argument called ‘callback’.
Parameters: - args – “Positional” arguments that will be passed to the callback.
- kwargs – “Keyword” arguments that will be passed to the callback.
Example: >>> item = Listitem() >>> item.next_page(url="http://example.com/videos?page2")
-
classmethod
recent
(callback, *args, **kwargs)[source]¶ Constructor for adding “Recent Videos” folder.
This is a convenience method that creates the listitem with “name”, “thumbnail” and “plot”, already preset.
Parameters: - callback (Callback) – The “callback” function.
- args – “Positional” arguments that will be passed to the callback.
- kwargs – “Keyword” arguments that will be passed to the callback.
-
classmethod
search
(callback, *args, **kwargs)[source]¶ Constructor to add “saved search” support to add-on.
This will first link to a “sub” folder that lists all saved “search terms”. From here, “search terms” can be created or removed. When a selection is made, the “callback” function that was given will be executed with all parameters forwarded on. Except with one extra parameter,
search_query
, which is the “search term” that was selected.Parameters: - callback (Callback) – Function that will be called when the “listitem” is activated.
- args – “Positional” arguments that will be passed to the callback.
- kwargs – “Keyword” arguments that will be passed to the callback.
-
classmethod
youtube
(content_id, label=None, enable_playlists=True)[source]¶ Constructor to add a “YouTube channel” to add-on.
This listitem will list all videos from a “YouTube”, channel or playlist. All videos will have a “Related Videos” option via the context menu. If
content_id
is a channel ID andenable_playlists
isTrue
, then a link to the “channel playlists” will also be added to the list of videos.Parameters: Example: >>> item = Listitem() >>> item.youtube("UC4QZ_LsYcvcq7qOsOhpAX4A")
-
-
class
codequick.listing.
Art
[source]¶ Dictionary like object, that allows you to add various images. e.g. “thumb”, “fanart”.
if “thumb”, “fanart” or “icon” is not set, then they will be set automaticly based on the add-on’s fanart and icon images if available.
Note
The automatic image values can be disabled by setting them to an empty string. e.g. item.art.thumb = “”.
- Expected art values are.
- thumb
- poster
- banner
- fanart
- clearart
- clearlogo
- landscape
- icon
Example: >>> item = Listitem() >>> item.art.icon = "http://www.example.ie/icon.png" >>> item.art["fanart"] = "http://www.example.ie/fanart.jpg" >>> item.art.local_thumb("thumbnail.png")
-
local_thumb
(image)[source]¶ Set the “thumbnail” image to a image file, located in the add-on “resources/media” directory.
Parameters: image (str) – Filename of the image.
-
global_thumb
(image)[source]¶ Set the “thumbnail” image to a image file, located in the codequick “resources/media” directory.
- The available global thumbnail images are.
- next.png - Arrow pointing to the right.
- videos.png - Circle with a play button in the middle.
- search.png - An image of a magnifying glass.
- search_new.png - A magnifying glass with plus symbol in the middle.
- playlist.png - Image of three bulleted lines.
- recent.png - Image of a clock.
Parameters: image (str) – Filename of the image.
-
class
codequick.listing.
Info
[source]¶ Dictionary like object, that allow’s you to add listitem “infoLabels”.
“InfoLabels” are like metadata for listitems. e.g. “duration”, “genre”, “size”, “rating” and or “plot”. They are also used for sorting purpose’s, sort methods will be automatically selected.
Some “infolabels” need to be of a given type e.g. “size” as “long”, “rating” as “float”. For the most part, this conversion will be done automatically.
- Example of what would happen is.
- “duration” would be converted to
int
and “xbmcplugin.SORT_METHOD_VIDEO_RUNTIME” sort method will be selected. - “size” would be converted to
long
and “xbmcplugin.SORT_METHOD_SIZE” sort method will be selected.
- “duration” would be converted to
See also
The full list of listitem “infoLabels” can be found at:
Note
Duration infolabel value can be either in “seconds” or as a “hh:mm:ss” string.
Examples: >>> item = Listitem() >>> item.info.genre = "Science Fiction" >>> item.info["size"] = 256816
-
class
codequick.listing.
Stream
[source]¶ Dictionary like object, that allows you to add “stream details”. e.g. “video_codec”, “audio_codec”.
- Expected stream values are.
- video_codec - str (h264)
- aspect - float (1.78)
- width - integer (1280)
- height - integer (720)
- channels - integer (2)
- audio_codec - str (AAC)
- audio_language - str (en)
- subtitle_language - str (en)
Type convertion will be done automatically, so manual convertion is not required.
Example: >>> item = Listitem() >>> item.stream.video_codec = "h264" >>> item.stream.audio_codec = "aac"
-
hd
(quality, aspect=None)[source]¶ Convenient method to set required stream info to show “SD/HD/4K” logos.
The values witch are set are “width”, “height” and “aspect”. If no aspect ratio is given, then a ratio of 1.78(16:9) is set when the quality is 720p or greater.
- Quality options are.
- 0 = 480p
- 1 = 720p
- 2 = 1080p
- 3 = 4K.
Parameters: Example: >>> item = Listitem() >>> item.stream.hd(2, aspect=1.78) # 1080p
-
class
codequick.listing.
Context
[source]¶ Adds item(s) to the context menu of the listitem.
This is a list containing “tuples” consisting of (“label”, “command”) pairs.
This class inherits all methods and attributes from the build-in data type
list
.See also
The full list of built-in functions can be found at:
Convenient method to add a “Related Videos” context menu item.
All this really does is to call “context.container” and sets “label” for you.
Parameters: - callback (Callback) – The function that will be called when menu item is activated.
- args – [opt] “Positional” arguments that will be passed to the callback.
- kwargs – [opt] “Keyword” arguments that will be passed to the callback.
-
container
(callback, label, *args, **kwargs)[source]¶ Convenient method to add a context menu item that links to a “container”.
Parameters: - callback (Callback) – The function that will be called when menu item is activated.
- label (str) – The label of the context menu item.
- args – [opt] “Positional” arguments that will be passed to the callback.
- kwargs – [opt] “Keyword” arguments that will be passed to the callback.
-
script
(callback, label, *args, **kwargs)[source]¶ Convenient method to add a context menu item that links to a “script”.
Parameters: - callback (Callback) – The function that will be called when menu item is activated.
- label (str or unicode) – The label of the context menu item.
- args – [opt] “Positional” arguments that will be passed to the callback.
- kwargs – [opt] “Keyword” arguments that will be passed to the callback.