Skip to content

Commit

Permalink
Updates code according to Kodi Jarvis API
Browse files Browse the repository at this point in the history
  • Loading branch information
Roman Miroshnychenko (Work) committed Jan 21, 2016
1 parent 69f7c3d commit 12ebf28
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 16 deletions.
4 changes: 2 additions & 2 deletions addon.xml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<addon id="plugin.video.example"
version="1.2.0"
version="2.0.0"
name="Example Kodi Video Plugin"
provider-name="Roman_V_M">
<requires>
<import addon="xbmc.python" version="2.14.0"/>
<import addon="xbmc.python" version="2.24.0"/>
</requires>
<extension point="xbmc.python.pluginsource" library="main.py">
<provides>video</provides>
Expand Down
30 changes: 16 additions & 14 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ def get_categories():
Here you can insert some parsing code that retrieves
the list of video categories (e.g. 'Movies', 'TV-shows', 'Documentaries' etc.)
from some site or server.
:return: list
"""
return VIDEOS.keys()
Expand All @@ -75,6 +76,7 @@ def get_videos(category):
Get the list of videofiles/streams.
Here you can insert some parsing code that retrieves
the list of videostreams in a given category from some site or server.
:param category: str
:return: list
"""
Expand All @@ -84,7 +86,6 @@ def get_videos(category):
def list_categories():
"""
Create the list of video categories in the Kodi interface.
:return: None
"""
# Get video categories
categories = get_categories()
Expand All @@ -94,9 +95,12 @@ def list_categories():
for category in categories:
# Create a list item with a text label and a thumbnail image.
list_item = xbmcgui.ListItem(label=category, thumbnailImage=VIDEOS[category][0]['thumb'])
# 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', VIDEOS[category][0]['thumb'])
# Set graphics (thumbnail, fanart, banner, poster, landscape etc.) for the list item.
# Here we use the same image for all items for simplicity's sake.
# 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.
# Here we use a category name for both properties for for simplicity's sake.
# setInfo allows to set various information for an item.
Expand All @@ -123,8 +127,8 @@ def list_categories():
def list_videos(category):
"""
Create the list of playable videos in the Kodi interface.
:param category: str
:return: None
"""
# Get the list of videos in the category.
videos = get_videos(category)
Expand All @@ -133,15 +137,13 @@ def list_videos(category):
# Iterate through videos.
for video in videos:
# Create a list item with a text label and a thumbnail image.
list_item = xbmcgui.ListItem(label=video['name'], thumbnailImage=video['thumb'])
# 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'])
list_item = xbmcgui.ListItem(label=video['name'])
# Set additional info for the list item.
list_item.setInfo('video', {'title': video['name'], 'genre': video['genre']})
# Set additional graphics (banner, poster, landscape etc.) for the list item.
# Again, here we use the same image as the thumbnail for simplicity's sake.
list_item.setArt({'landscape': video['thumb']})
# Set graphics (thumbnail, fanart, banner, poster, landscape etc.) for the list item.
# Here we use the same image for all items for simplicity's sake.
# 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'.
# This is mandatory for playable items!
list_item.setProperty('IsPlayable', 'true')
Expand All @@ -166,8 +168,8 @@ def list_videos(category):
def play_video(path):
"""
Play a video by the provided path.
:param path: str
:return: None
"""
# Create a playable item with a path to play.
play_item = xbmcgui.ListItem(path=path)
Expand All @@ -179,8 +181,8 @@ def router(paramstring):
"""
Router function that calls other functions
depending on the provided paramstring
:param paramstring:
:return:
"""
# Parse a URL-encoded paramstring to the dictionary of
# {<parameter>: <value>} elements
Expand Down

0 comments on commit 12ebf28

Please sign in to comment.