summaryrefslogtreecommitdiff
path: root/plugin.video.dazn/resources/lib/context.py
blob: a4df55d4a0f5f8666d2ba691fa5f1c717b7b41f3 (plain)
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
# -*- coding: utf-8 -*-

class Context:

    def __init__(self, plugin):
        self.cm = []
        self.plugin = plugin

    def epg_date(self):
        d = {
            'mode': 'epg',
            'id': 'date'
        }
        self.cm.append((self.plugin.get_string(30230), 'ActivateWindow(Videos, {0})'.format(self.plugin.build_url(d))))
        return self.cm

    def highlights(self, item, mode):
        d = {
            'mode': mode,
            'title': self.plugin.utfenc(item['title']),
            'id': item.get('id', ''),
            'params': item.get('params','')
        }
        self.cm.append((self.plugin.get_string(30231), 'ActivateWindow(Videos, {0})'.format(self.plugin.build_url(d))))
        return self.cm

    def related(self, cm_items):
        for i in cm_items:
            type_ = i['type']
            if type_ == 'Highlights':
                type_ = self.plugin.get_string(30213)
            elif type_ == 'Condensed':
                type_ = self.plugin.get_string(30216)
            d = {
                'mode': 'play_context',
                'title': self.plugin.utfenc(i['title']),
                'id': i.get('id', ''),
                'params': i.get('params','')
            }
            self.cm.append((type_, 'XBMC.RunPlugin({0})'.format(self.plugin.build_url(d))))
        return self.cm

    def goto(self, item):
        if item.get('sport', None):
            i = item['sport']
            d = {
                'mode': 'rails',
                'title': self.plugin.utfenc(i['Title']),
                'id': 'sport',
                'params': i['Id']
            }
            self.cm.append((self.plugin.get_string(30214), 'ActivateWindow(Videos, {0})'.format(self.plugin.build_url(d))))

        if item.get('competition', None):
            i = item['competition']
            d = {
                'mode': 'rails',
                'title': self.plugin.utfenc(i['Title']),
                'id': 'competition',
                'params': i['Id']
            }
            self.cm.append((self.plugin.get_string(30215), 'ActivateWindow(Videos, {0})'.format(self.plugin.build_url(d))))

        return self.cm