diff --git a/Readme.md b/Readme.md index 95101ac..4263369 100644 --- a/Readme.md +++ b/Readme.md @@ -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) diff --git a/plugin.video.example/default.py b/plugin.video.example/default.py index c2ceebc..ed4568b 100644 --- a/plugin.video.example/default.py +++ b/plugin.video.example/default.py @@ -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 - # {: []} elements - params = parse_qs(paramstring) + # {: } 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]) diff --git a/tests/tests.py b/tests/tests.py index ec7dc7d..bab2215 100644 --- a/tests/tests.py +++ b/tests/tests.py @@ -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.