Fixed links in the Readme; changed parsing method

This commit is contained in:
Roman Miroshnychenko (Work) 2015-05-19 14:48:41 +03:00
parent f0bb82a9e5
commit 71d0717167
3 changed files with 15 additions and 14 deletions

View File

@ -1,9 +1,11 @@
Simple example plugin for Kodi mediacenter
===
This is a simple yet fully functional example of a video plugin for [Kodi](www.kodi.tv) mediacenter.
This is a simple yet fully functional example of a video plugin for [Kodi](http://kodi.tv) mediacenter.
Please read the comments in the plugin code for more details.
**tests/** folder includes a simple example for partial unit testing of the plugin code.
The plugin uses free sample videos are provided by [www.vidsplay.com](www.vidsplay.com).
The plugin uses free sample videos are provided by [www.vidsplay.com](http://www.vidsplay.com/).
License: [GPL v.3](http://www.gnu.org/copyleft/gpl.html)

View File

@ -5,7 +5,7 @@
# License: GPL v.3 https://www.gnu.org/copyleft/gpl.html
import sys
from urlparse import parse_qs
from urlparse import parse_qsl
import xbmcgui
import xbmcplugin
@ -146,16 +146,16 @@ def router(paramstring):
:return:
"""
# Parse a URL-encoded paramstring to the dictionary of
# {<parameter>: [<list of values>]} elements
params = parse_qs(paramstring)
# {<parameter>: <value>} elements
params = dict(parse_qsl(paramstring[1:]))
# Check the parameters passed to the plugin
if params:
if params['action'][0] == 'listing':
if params['action'] == 'listing':
# Display the list of videos in a provided category.
list_videos(params['category'][0])
elif params['action'][0] == 'play':
list_videos(params['category'])
elif params['action'] == 'play':
# Play a video from a provided URL.
play_video(params['video'][0])
play_video(params['video'])
else:
# If the plugin is called from Kodi UI without any parameters,
# display the list of video categories
@ -164,5 +164,4 @@ def router(paramstring):
if __name__ == '__main__':
# Call the router function and pass the plugin call parameters to it.
# We use string slicing to remove starting "?" from the paramstring
router(sys.argv[2][1:])
router(sys.argv[2])

View File

@ -40,7 +40,7 @@ class RouterTestCase(unittest.TestCase):
"""
Test router for open a category request
"""
default.router('action=listing&category=Animals')
default.router('?action=listing&category=Animals')
mock_list_videos.assert_called_with('Animals')
@mock.patch('default.play_video')
@ -48,8 +48,8 @@ class RouterTestCase(unittest.TestCase):
"""
Test router for a play video request
"""
default.router('action=play&video=http://test')
mock_play_video.assert_called_with('http://test')
default.router('?action=play&video=http://test.mkv')
mock_play_video.assert_called_with('http://test.mkv')
# list_categories(), list_videos() and play_video() functions include
# mostly calls to Kody Python API with little or no custom logic.