forked from Opvolger/plugin.video.uzg
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon.py
71 lines (59 loc) · 1.95 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
'''
Uitzendinggemist(NPO)
~~~~~~~
An XBMC addon for watching uzg
:license: GPLv3, see LICENSE.txt for more details.
based on: https://github.com/jbeluch/plugin.video.documentary.net
Uitzendinggemist(NPO) / uzg = Made by Bas Magre (Opvolger)
'''
from xbmcswift2 import Plugin, SortMethod
import resources.lib.uzg
import time
import xbmcplugin
PLUGIN_NAME = 'uzg'
PLUGIN_ID = 'plugin.video.uzg'
plugin = Plugin(PLUGIN_NAME, PLUGIN_ID, __file__)
uzg = resources.lib.uzg.Uzg()
subtitle = plugin.get_setting( "subtitle", bool )
@plugin.route('/')
def index():
##main, alle shows
items = [{
'path': plugin.url_for('show_afleveringen', nebo_id=item['nebo_id']),
'label': item['label'],
'thumbnail': item['thumbnail'],
} for item in uzg.get_overzicht()]
return items
@plugin.route('/afleveringen/<nebo_id>/')
def show_afleveringen(nebo_id):
return show_items(uzg.get_items(nebo_id))
@plugin.route('/lectures/<whatson_id>/')
def play_lecture(whatson_id):
plugin.set_resolved_url(uzg.get_play_url(whatson_id))
if (subtitle):
add_subtitlesstream(uzg.get_ondertitel(whatson_id))
def add_subtitlesstream(subtitles):
player = xbmc.Player()
for _ in xrange(30):
if player.isPlaying():
break
time.sleep(1)
else:
raise Exception('No video playing. Aborted after 30 seconds.')
player.setSubtitles(subtitles)
player.setSubtitleStream(1)
def show_items(opgehaaldeitemsclass):
'''Lists playable videos for a given category url.'''
items = [{
'path': plugin.url_for('play_lecture', whatson_id=item['whatson_id']),
##'whatson_id': item['whatson_id'],
'label': item['label'],
'thumbnail': item['thumbnail'],
'is_playable': True,
'info': {
'date': item['date']
},
} for item in opgehaaldeitemsclass]
return plugin.finish(items,sort_methods=[SortMethod.DATE,SortMethod.LABEL])
if __name__ == '__main__':
plugin.run()