forked from Sorien/plugin.video.sl
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
58 lines (47 loc) · 1.83 KB
/
main.py
File metadata and controls
58 lines (47 loc) · 1.83 KB
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
import sys
import inputstreamhelper
import logger
import requests
import skylink
import account
import xbmc
import xbmcaddon
import xbmcgui
import urlparse
import xbmcplugin
import replay
import utils
_id = int(sys.argv[1])
_addon = xbmcaddon.Addon()
def play(account_id, channel_id, askpin):
sl = utils.get_provider(account_id)
if not sl:
return
logger.log.info('Play channel %s from %s' % (channel_id, sl.account.provider))
if askpin != 'False':
pin_ok = utils.ask_for_pin(sl)
if not pin_ok:
xbmcplugin.setResolvedUrl(_id, False, xbmcgui.ListItem())
return
info = {}
info = utils.call(sl, lambda: sl.channel_info(channel_id))
if info:
is_helper = inputstreamhelper.Helper(info['protocol'], drm=info['drm'])
if is_helper.check_inputstream():
playitem = xbmcgui.ListItem(path=info['path'])
playitem.setProperty('inputstreamaddon', is_helper.inputstream_addon)
playitem.setProperty('inputstream.adaptive.manifest_type', info['protocol'])
playitem.setProperty('inputstream.adaptive.license_type', info['drm'])
playitem.setProperty('inputstream.adaptive.license_key', info['key'])
xbmcplugin.setResolvedUrl(_id, True, playitem)
if __name__ == '__main__':
args = urlparse.parse_qs(sys.argv[2][1:])
if 'account' in args and 'channel' in args:
play(str(args['account'][0]), str(args['channel'][0]), str(args['askpin'][0]) if 'askpin' in args else 'False')
elif 'replay' in args:
replay.router(args)
else:
xbmcplugin.setPluginCategory(_id, '')
xbmcplugin.setContent(_id, 'videos')
xbmcplugin.addDirectoryItem(_id, replay.get_url(replay='channels'), xbmcgui.ListItem(label=_addon.getLocalizedString(30600)), True)
xbmcplugin.endOfDirectory(_id)