-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontrol.py
executable file
·168 lines (133 loc) · 5.43 KB
/
control.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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
# -*- coding: utf-8 -*-
import xbmc
import xbmcaddon
import xbmcgui
import xbmcvfs
import uuid
debugAddon = True
addon = xbmcaddon.Addon()
user = addon.getSetting('toya_go_user');
password = addon.getSetting('toya_go_pass');
tv_sort = addon.getSetting('toya_go_tv_sort');
deviceid = addon.getSetting('toya_go_device')
token = addon.getSetting('toya_go_token')
firststart = addon.getSetting('toya_go_init')
addonname = addon.getAddonInfo('name')
server_enable = addon.getSetting('server_enable')
server_port = addon.getSetting('server_port')
epg = addon.getSetting('toya_go_epg')
m3u_dir = xbmcvfs.translatePath(addon.getSetting('m3u_dir'))
xmltv_dir = addon.getSetting('xmltv_dir')
toya_go_radio = addon.getSetting('toya_go_radio')
toya_go_camera = addon.getSetting('toya_go_camera')
toya_go_freevod = addon.getSetting('toya_go_freevod')
toya_go_karaoke = addon.getSetting('toya_go_karaoke')
toya_go_tv = addon.getSetting('toya_go_tv')
server_radio = addon.getSetting('server_radio')
developr_mode = addon.getSetting('developr_mode')
has_account = addon.getSetting('has_account')
main_screen_tv = addon.getSetting('toya_go_tv_main_screen')
# server_epg = addon.getSetting('server_epg')
pvr_epg_source = addon.getSetting('pvr_epg_source')
playlist_type = addon.getSetting('playlist_type')
toya_go_tv_num = addon.getSetting('toya_go_tv_num')
# epg_url = 'https://github.com/piotrekcrash/kodi/raw/master/epg/epg_toya.xml'
ekg_kwp_url = 'https://epg.ovh/pl.gz'
PHOTO_URL = 'https://data-go.toya.net.pl/photo/categories/'
profile = dataPath = xbmcvfs.translatePath(addon.getAddonInfo('profile'))
icon = addon.getAddonInfo('icon')
if deviceid == '':
randomdev = str(uuid.uuid4().hex.upper()[0:10])
addon.setSetting('toya_go_device', randomdev)
deviceid = randomdev
# if user == '' or password == '':
# addon.openSettings()
db = 'toyago'
monitor = xbmc.Monitor()
dialog = xbmcgui.Dialog()
def getSetting(name):
return addon.getSetting(name)
def setSetting(name, value):
addon.setSetting(name, value)
def openSettings():
addon.openSettings()
def openIPTVsettings(addonName):
xbmcaddon.Addon(id=addonName).openSettings()
def setIptvSettings(addonName):
iptvAddon = xbmcaddon.Addon(id=addonName)
if pvr_epg_source != '0':
epgurl = epgSourceUrl(pvr_epg_source)
if iptvAddon.getSetting('epgUrl') != epgurl:
iptvAddon.setSetting('epgUrl', epgurl)
if iptvAddon.getSetting('epgPathType') != '1':
iptvAddon.setSetting('epgPathType', '1')
location = profile
if m3u_dir not in '':
location = m3u_dir
m3uPath = location + 'toyago.m3u8'
if iptvAddon.getSetting('m3uPath') != m3uPath:
iptvAddon.setSetting('m3uPath', m3uPath)
if iptvAddon.getSetting('m3uPathType') != '0':
iptvAddon.setSetting('m3uPathType', '0')
def epgSourceUrl(epgtype):
# if epgtype == '1':
# return epg_url
# elif epgtype == '2':
# return ekg_kwp_url
# return ''
return ekg_kwp_url
def setIptvCustomSettings():
custom_pvraddon_name = addon.getSetting('custom_pvraddon_name')
if custom_pvraddon_name == '':
sendInfo('Nazwa dadatku nie została zdefiniowana')
else:
exist = xbmc.getCondVisibility('System.HasAddon(%s)' % custom_pvraddon_name)
if exist == 1:
sendInfo('Dodatek: ' + custom_pvraddon_name + ' jest zainstalowany')
else:
sendInfo('Brak dodatku: ' + custom_pvraddon_name)
def sendError(error):
xbmcgui.Dialog().notification(addonname, error, xbmcgui.NOTIFICATION_ERROR)
def sendInfo(info):
xbmcgui.Dialog().notification(addonname, info, icon=icon)
def logInfo(info):
xbmc.log(msg=addonname + ' - ' + info, level=xbmc.LOGINFO)
def logError(error):
xbmc.log(msg=addonname + ' - ' + error, level=xbmc.LOGERROR)
def runCreator():
run = dialog.yesno(addonname, 'Chcesz skonfigurować dodatek?')
if run == 1:
confCreator()
def reauthCreator():
again = dialog.yesno(addonname, 'Niepoprawy login lub hasło. Chcesz wprowadzić poprawne dane?')
sendInfo(str(again))
if again == 1:
confCreator()
def confCreator():
login = dialog.input('Podaj email ([email protected])', defaultt=user, type=xbmcgui.INPUT_ALPHANUM)
passw = dialog.input('Podaj hasło', type=xbmcgui.INPUT_ALPHANUM)
import toyago
API = toyago.GetInstance(deviceid, login, passw, '', False)
try:
API.authenticate(True)
setSetting('toya_go_user', login)
setSetting('toya_go_pass', passw)
import kodiservice
kodiservice.initdb(profile, db)
kodiservice.updatechannels(deviceid, user, password, token, profile, db)
except Exception as e:
reauthCreator()
confIptv = dialog.yesno(addonname, 'Chcesz skonfigurować automatycznie wtyczke IPTV? \nZostaniesz kilkakrotnie ' +
'poproszony o restart. \nPotwierdż klikając OK')
if confIptv == 1:
try:
# iptvsimple = xbmcaddon.Addon(id='pvr.iptvsimple')
setIptvSettings()
except RuntimeError as e:
dialog.ok(addonname, 'Wygląda na to, że nie masz zainstalowanego dodatku IPTV Simple. Zinstaluj z ' +
'Repozytorium (Klienty telewizji) i ponownie uruchom kreator w ustawieniach ToyaGO')
def setbusy(isBusy):
if isBusy is True:
xbmc.executebuiltin('ActivateWindow(busydialognocancel)')
else:
xbmc.executebuiltin('Dialog.Close(busydialognocancel)')