forked from jamieu/plugin.video.mubi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
addon.py
33 lines (25 loc) · 864 Bytes
/
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
from xbmcswift2 import xbmc, xbmcgui, Plugin
from resources.lib.mubi import Mubi
PLUGIN_NAME = 'MUBI'
PLUGIN_ID = 'plugin.video.mubi'
plugin = Plugin(PLUGIN_NAME, PLUGIN_ID, __file__)
if not plugin.get_setting("username"):
plugin.open_settings()
mubi = Mubi()
mubi.login(plugin.get_setting("username", unicode), plugin.get_setting("password", unicode))
@plugin.route('/')
def index():
films = mubi.now_showing()
items = [{
'label': film.title,
'is_playable': True,
'path': plugin.url_for('play_film', identifier=film.mubi_id),
'thumbnail': film.artwork,
'info': film.metadata._asdict()
} for film in films]
return items
@plugin.route('/play/<identifier>')
def play_film(identifier):
return plugin.set_resolved_url(mubi.get_play_url(identifier))
if __name__ == '__main__':
plugin.run()