This repository has been archived by the owner on Jul 8, 2020. It is now read-only.
forked from michilinmnnchn/plugin.video.dazn
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaddon.py
67 lines (60 loc) · 1.98 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
# -*- coding: utf-8 -*-
import sys
if (sys.version_info[0] == 2):
from urlparse import urlparse, parse_qs
else:
from urllib.parse import urlparse, parse_qs
from resources.lib.common import Common
from resources.lib.client import Client
from resources.lib.parser import Parser
handle_ = int(sys.argv[1])
url_ = sys.argv[0]
plugin = Common(
addon_handle=handle_,
addon_url=url_
)
client = Client(plugin)
parser = Parser(plugin)
def router(paramstring):
args = dict(parse_qs(paramstring))
mode = args.get('mode', ['rails'])[0]
title = args.get('title', [''])[0]
id_ = args.get('id', ['home'])[0]
params = args.get('params', [''])[0]
verify_age = True if args.get('verify_age', [''])[0] == 'True' else False
if mode == 'rails':
parser.rails_items(client.rails(id_, params), id_)
elif 'rail' in mode:
parser.rail_items(client.rail(id_, params), mode)
elif 'epg' in mode:
date = params
if id_ == 'date':
date = plugin.get_date()
parser.epg_items(client.epg(date), date, mode)
elif mode == 'play':
parser.playback(client.playback(id_, plugin.youth_protection_pin(verify_age)))
elif mode == 'play_context':
parser.playback(client.playback(id_, plugin.youth_protection_pin(verify_age)), title, True)
elif mode == 'logout':
if plugin.logout():
client.signOut()
sys.exit(0)
elif mode == 'is_settings':
plugin.open_is_settings()
else:
sys.exit(0)
if __name__ == '__main__':
if plugin.startup or not client.TOKEN:
playable = plugin.start_is_helper()
client.DEVICE_ID = plugin.uniq_id()
if client.DEVICE_ID and playable:
client.startUp()
if client.TOKEN:
plugin.set_setting('startup', 'false')
client.userProfile()
else:
client.TOKEN = ''
if client.TOKEN and client.DEVICE_ID:
router(sys.argv[2][1:])
else:
sys.exit(0)