Updates code according to Kodi Jarvis API

This commit is contained in:
Roman Miroshnychenko (Work) 2016-01-21 15:43:21 +02:00
parent 69f7c3d2fc
commit 12ebf28f24
2 changed files with 18 additions and 16 deletions

View File

@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.example" <addon id="plugin.video.example"
version="1.2.0" version="2.0.0"
name="Example Kodi Video Plugin" name="Example Kodi Video Plugin"
provider-name="Roman_V_M"> provider-name="Roman_V_M">
<requires> <requires>
<import addon="xbmc.python" version="2.14.0"/> <import addon="xbmc.python" version="2.24.0"/>
</requires> </requires>
<extension point="xbmc.python.pluginsource" library="main.py"> <extension point="xbmc.python.pluginsource" library="main.py">
<provides>video</provides> <provides>video</provides>

30
main.py
View File

@ -65,6 +65,7 @@ def get_categories():
Here you can insert some parsing code that retrieves Here you can insert some parsing code that retrieves
the list of video categories (e.g. 'Movies', 'TV-shows', 'Documentaries' etc.) the list of video categories (e.g. 'Movies', 'TV-shows', 'Documentaries' etc.)
from some site or server. from some site or server.
:return: list :return: list
""" """
return VIDEOS.keys() return VIDEOS.keys()
@ -75,6 +76,7 @@ def get_videos(category):
Get the list of videofiles/streams. Get the list of videofiles/streams.
Here you can insert some parsing code that retrieves Here you can insert some parsing code that retrieves
the list of videostreams in a given category from some site or server. the list of videostreams in a given category from some site or server.
:param category: str :param category: str
:return: list :return: list
""" """
@ -84,7 +86,6 @@ def get_videos(category):
def list_categories(): def list_categories():
""" """
Create the list of video categories in the Kodi interface. Create the list of video categories in the Kodi interface.
:return: None
""" """
# Get video categories # Get video categories
categories = get_categories() categories = get_categories()
@ -94,9 +95,12 @@ def list_categories():
for category in categories: for category in categories:
# Create a list item with a text label and a thumbnail image. # Create a list item with a text label and a thumbnail image.
list_item = xbmcgui.ListItem(label=category, thumbnailImage=VIDEOS[category][0]['thumb']) list_item = xbmcgui.ListItem(label=category, thumbnailImage=VIDEOS[category][0]['thumb'])
# Set a fanart image for the list item. # Set graphics (thumbnail, fanart, banner, poster, landscape etc.) for the list item.
# Here we use the same image as the thumbnail for simplicity's sake. # Here we use the same image for all items for simplicity's sake.
list_item.setProperty('fanart_image', VIDEOS[category][0]['thumb']) # In a real-life plugin you need to set each image accordingly.
list_item.setArt({'thumb': VIDEOS[category][0]['thumb'],
'icon': VIDEOS[category][0]['thumb'],
'fanart': VIDEOS[category][0]['thumb']})
# Set additional info for the list item. # Set additional info for the list item.
# Here we use a category name for both properties for for simplicity's sake. # Here we use a category name for both properties for for simplicity's sake.
# setInfo allows to set various information for an item. # setInfo allows to set various information for an item.
@ -123,8 +127,8 @@ def list_categories():
def list_videos(category): def list_videos(category):
""" """
Create the list of playable videos in the Kodi interface. Create the list of playable videos in the Kodi interface.
:param category: str :param category: str
:return: None
""" """
# Get the list of videos in the category. # Get the list of videos in the category.
videos = get_videos(category) videos = get_videos(category)
@ -133,15 +137,13 @@ def list_videos(category):
# Iterate through videos. # Iterate through videos.
for video in videos: for video in videos:
# Create a list item with a text label and a thumbnail image. # Create a list item with a text label and a thumbnail image.
list_item = xbmcgui.ListItem(label=video['name'], thumbnailImage=video['thumb']) list_item = xbmcgui.ListItem(label=video['name'])
# Set a fanart image for the list item.
# Here we use the same image as the thumbnail for simplicity's sake.
list_item.setProperty('fanart_image', video['thumb'])
# Set additional info for the list item. # Set additional info for the list item.
list_item.setInfo('video', {'title': video['name'], 'genre': video['genre']}) list_item.setInfo('video', {'title': video['name'], 'genre': video['genre']})
# Set additional graphics (banner, poster, landscape etc.) for the list item. # Set graphics (thumbnail, fanart, banner, poster, landscape etc.) for the list item.
# Again, here we use the same image as the thumbnail for simplicity's sake. # Here we use the same image for all items for simplicity's sake.
list_item.setArt({'landscape': video['thumb']}) # In a real-life plugin you need to set each image accordingly.
list_item.setArt({'thumb': video['thumb'], 'icon': video['thumb'], 'fanart': video['thumb']})
# Set 'IsPlayable' property to 'true'. # Set 'IsPlayable' property to 'true'.
# This is mandatory for playable items! # This is mandatory for playable items!
list_item.setProperty('IsPlayable', 'true') list_item.setProperty('IsPlayable', 'true')
@ -166,8 +168,8 @@ def list_videos(category):
def play_video(path): def play_video(path):
""" """
Play a video by the provided path. Play a video by the provided path.
:param path: str :param path: str
:return: None
""" """
# Create a playable item with a path to play. # Create a playable item with a path to play.
play_item = xbmcgui.ListItem(path=path) play_item = xbmcgui.ListItem(path=path)
@ -179,8 +181,8 @@ def router(paramstring):
""" """
Router function that calls other functions Router function that calls other functions
depending on the provided paramstring depending on the provided paramstring
:param paramstring: :param paramstring:
:return:
""" """
# Parse a URL-encoded paramstring to the dictionary of # Parse a URL-encoded paramstring to the dictionary of
# {<parameter>: <value>} elements # {<parameter>: <value>} elements