-
Notifications
You must be signed in to change notification settings - Fork 2
/
addon.py
84 lines (75 loc) · 3.36 KB
/
addon.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
from urllib.parse import parse_qsl
from video import VideoHandler
from audio import AudioHandler
import sys
import xbmcaddon
import xbmc
addon = xbmcaddon.Addon()
# Get the plugin url in plugin:// notation.
_url = sys.argv[0]
# Get the plugin handle as an integer number.
_handle = int(sys.argv[1])
vh = VideoHandler(_handle, _url)
ah = AudioHandler(_handle, _url)
def router(paramstring):
"""
Router function that calls other functions
depending on the provided paramstring
:param paramstring:
"""
# Parse a URL-encoded paramstring to the dictionary of
# {<parameter>: <value>} elements
params = dict(parse_qsl(paramstring))
# Check the parameters passed to the plugin
if params:
if "content_type" in params:
if params["content_type"] == "video":
vh.list_menu()
# vh.list_programs()
elif params["content_type"] == "audio":
ah.list_radios()
# ah.list_radio_programs()
else:
if "action" in params:
if params["action"] == "videomenu":
# Display the list of videos in a provided category.
if params["option"] == "all_tvshows":
vh.list_programs()
# elif params['option'] == 'last_tvshows':
# vh.list_last_broadcast()
elif params["option"] == "program-type-list":
vh.list_programs_types()
elif params["action"] == "videotypelisting":
# Display the list of videos in a provided category.
vh.list_programs_types_playlist(params["program"])
elif params["action"] == "videolisting":
# Display the list of videos in a provided category.
vh.list_playlists(params["program"])
# vh.list_episodes(params['program'])
elif params["action"] == "videoprogram":
# Display the list of videos in a provided program.
vh.list_episodes(params["program"])
elif params["action"] == "videoepisode":
# Display the list of videos in a provided category.
vh.list_videos(params["program"])
elif params["action"] == "videoplay":
# Play a video from a provided URL.
vh.play_video(params["video"])
elif params["action"] == "audioplay":
ah.play_audio(params["program"])
elif params["action"] == "radio":
ah.list_radio_programs(params["program"])
elif params["action"] == "audioprogram":
ah.list_seasons(params["program"])
elif params["action"] == "audioseason":
ah.list_program_season_chapters(params["program"])
elif params["action"] == "audiochapter":
ah.list_program_audios(params["program"])
else:
# If the plugin is called from Kodi UI without any parameters,
# display the list of video categories
vh.list_programs()
if __name__ == "__main__":
# Call the router function and pass the plugin call parameters to it.
# We use string slicing to trim the leading '?' from the plugin call paramstring
router(sys.argv[2][1:])