forked from pelrol/xbmc-my-canal
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon.py
56 lines (41 loc) · 1.38 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
from xbmcswift2 import Plugin
from resources.lib import scraper
import pprint
plugin = Plugin()
@plugin.route('/')
def index():
emission_types = scraper.Emission.get_emission_types()
pprint.pprint(emission_types)
items = [{
'label': emission_type['name'],
'path': plugin.url_for('show_emission_for_type', type_index=emission_type['index']),
} for emission_type in emission_types]
return items
@plugin.route('/emission_type/<type_index>/')
def show_emission_for_type(type_index):
emissions = scraper.Emission.get_emissions_from_index(type_index)
items = [{
'label': emission['name'],
'path': plugin.url_for('show_emission', url=emission['url']),
'icon': emission['icon'],
} for emission in emissions]
return items
@plugin.route(('/emission/<url>/'))
def show_emission(url):
videos = scraper.Video.from_url(url)
#pprint.pprint(videos)
items = [{
'label': video['name'],
'path': plugin.url_for('play_video', url=video['url']),
'icon': video['icon'],
'is_playable': True,
} for video in videos]
return items
@plugin.route('/video/<url>/')
def play_video(url):
media = scraper.Media.from_url(url)
media_url = media['url']
plugin.log.info('Playing url: %s' % media_url)
return plugin.set_resolved_url(media_url)
if __name__ == '__main__':
plugin.run()