-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathdefault.py
3064 lines (2984 loc) · 179 KB
/
default.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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/bin/env python
################################################################################
# This file is part of LibreELEC - https://libreelec.tv
# Copyright (C) 2016-2017 Team LibreELEC
# Copyright (C) 2017 Tnds82 ([email protected])
#
# LibreELEC is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 2 of the License, or
# (at your option) any later version.
#
# LibreELEC is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with LibreELEC. If not, see <http://www.gnu.org/licenses/>.
################################################################################
import xbmc,xbmcaddon,xbmcvfs,xbmcgui,xbmcplugin
import subprocess
from subprocess import Popen
from xbmcswift2 import Plugin
import io
import os
import re
import requests
import sys
import json
import urllib.request, urllib.error, urllib.parse
import time
import ast
import zipfile
import datetime
import urllib.request, urllib.parse, urllib.error
import picons
plugin = Plugin()
dialog = xbmcgui.Dialog()
try:
tvh_url_get = xbmcaddon.Addon('pvr.hts').getSetting("host")
if tvh_url_get:
tvh_url_set = xbmcaddon.Addon().setSetting(id='tvhurl', value=tvh_url_get)
else:
try:
tvh_url = xbmcaddon.Addon().getSetting('tvhurl')
except:
tvh_url_set = xbmcaddon.Addon().setSetting(id='tvhurl', value="127.0.0.1")
tvh_port_get = xbmcaddon.Addon('pvr.hts').getSetting("http_port")
if tvh_port_get:
tvh_port_set = xbmcaddon.Addon().setSetting(id='tvhport', value=tvh_port_get)
else:
try:
tvh_port = xbmcaddon.Addon().getSetting('tvhport')
except:
tvh_port_set = xbmcaddon.Addon().setSetting(id='tvhport', value="9981")
except:
pass
tvh_port = xbmcaddon.Addon().getSetting('tvhport')
tvh_usern = xbmcaddon.Addon().getSetting('usern')
tvh_passw = xbmcaddon.Addon().getSetting('passw')
if tvh_usern != "" and tvh_passw != "":
tvh_url = tvh_usern + ":" + tvh_passw + "@" + xbmcaddon.Addon().getSetting('tvhurl')
else:
tvh_url = xbmcaddon.Addon().getSetting('tvhurl')
try:
check_url = 'http://' + tvh_url + ':' + tvh_port + '/api/status/connections'
check_load = requests.get(check_url)
check_status = check_load.raise_for_status()
except requests.exceptions.HTTPError as err:
dialog.ok("Tvheadend Access Error!", str(err), "", "Please check your username/password in settings.")
except requests.exceptions.RequestException as e:
dialog.ok("Tvheadend Access Error!", "Could not connect to Tvheadend server.", "Please check your Tvheadend server is running or check the IP and port configuration in the settings.")
truefalse = ['true', 'false']
enabledisable = ['Enabled', 'Disabled']
def get_icon_path(icon_name):
addon_path = xbmcaddon.Addon().getAddonInfo("path")
return os.path.join(addon_path, 'resources', 'img', icon_name+".png")
def find_param(d, param_id):
for param in d['entries'][0]['params']:
if param['id'] == param_id:
try:
value = param['value']
except:
value = ""
break
else:
value = "NO PARAMATER FOUND"
return value
def find_param_item(d, param_id, item):
for param in d['entries'][0]['params']:
if param['id'] == param_id:
try:
value = param[item]
except:
value = ""
break
else:
value = "NO PARAMATER FOUND"
return value
def find_param_dict(d, param_id, param_id2):
param_value = find_param(d, param_id)
for param in d['entries'][0]['params']:
if param['id'] == param_id:
param_dict = param[param_id2]
break
else:
param_dict = "NO PARAMATER FOUND"
param_key = []
param_val = []
for param_k in param_dict:
param_key.append(param_k['key'])
for param_v in param_dict:
param_val.append(param_v['val'])
try:
param_index = param_key.index(param_value)
return (param_val[param_index], param_key, param_val)
except:
return (param_value, param_key, param_val)
def find_param_enum(d, param_id, param_id2):
param_value = find_param(d, param_id)
for param in d['entries'][0]['params']:
if param['id'] == param_id:
param_dict = param['enum']
break
else:
param_dict = "NO PARAMATER FOUND"
param_key = []
param_val = []
for param_k in param_dict:
param_key.append(param_k['key'])
for param_v in param_dict:
param_val.append(param_v['val'])
try:
param_index = param_key.index(param_value)
return (param_val[param_index], param_key, param_val)
except:
return (param_value, param_key, param_val)
def find_param_list(d, param_id, param_id2):
param_value = find_param(d, param_id)
for param in d['entries'][0]['params']:
if param['id'] == param_id:
param_list = param[param_id2]
break
else:
param_list = "NO PARAMATER FOUND"
return (param_value, param_list)
def find_list(d, param_id, param_id2):
for param in d['entries'][0]['params']:
if param['id'] == param_id:
param_list = param[param_id2]
break
else:
param_list = []
return param_list
def find_prop(d, param_id):
for param in d['props']:
if param['id'] == param_id:
try:
value = param['default']
except:
value = ""
break
else:
value = "NO PARAMATER FOUND"
return value
def find_props_dict(d, param_id, param_id2):
for param in d['props']:
if param['id'] == param_id:
param_dict = param[param_id2]
break
else:
param_dict = "NO PARAMATER FOUND"
param_key = []
param_val = []
for param_k in param_dict:
param_key.append(param_k['key'])
for param_v in param_dict:
param_val.append(param_v['val'])
return (param_key, param_val)
def dis_or_enable_addon(addon_id, enable="true"):
addon = '"%s"' % addon_id
if xbmc.getCondVisibility("System.HasAddon(%s)" % addon_id) and enable == "true":
return xbmc.log("### Skipped %s, reason = allready enabled" % addon_id)
elif not xbmc.getCondVisibility("System.HasAddon(%s)" % addon_id) and enable == "false":
return xbmc.log("### Skipped %s, reason = not installed" % addon_id)
else:
do_json = '{"jsonrpc":"2.0","id":1,"method":"Addons.SetAddonEnabled","params":{"addonid":%s,"enabled":%s}}' % (addon, enable)
query = xbmc.executeJSONRPC(do_json)
response = json.loads(query)
if enable == "true":
xbmc.log("### Enabled %s, response = %s" % (addon_id, response))
else:
xbmc.log("### Disabled %s, response = %s" % (addon_id, response))
return xbmc.executebuiltin('Container.Update(%s)' % xbmc.getInfoLabel('Container.FolderPath'))
def ZipDir(inputDir, outputZip):
zipOut = zipfile.ZipFile(outputZip, 'w', compression=zipfile.ZIP_DEFLATED)
rootLen = len(os.path.dirname(inputDir))
def _ArchiveDirectory(parentDirectory):
contents = os.listdir(parentDirectory)
if not contents:
archiveRoot = parentDirectory[rootLen:].replace('\\', '/').lstrip('/')
zipInfo = zipfile.ZipInfo(archiveRoot+'/')
zipOut.writestr(zipInfo, '')
for item in contents:
fullPath = os.path.join(parentDirectory, item)
if os.path.isdir(fullPath) and not os.path.islink(fullPath):
_ArchiveDirectory(fullPath)
else:
archiveRoot = fullPath[rootLen:].replace('\\', '/').lstrip('/')
if os.path.islink(fullPath):
zipInfo = zipfile.ZipInfo(archiveRoot)
zipInfo.create_system = 3
zipInfo.external_attr = 2716663808
zipOut.writestr(zipInfo, os.readlink(fullPath))
else:
zipOut.write(fullPath, archiveRoot, zipfile.ZIP_DEFLATED)
_ArchiveDirectory(inputDir)
zipOut.close()
def picons_param_load():
url_latest = 'http://cvh.libreelec.tv/picons/latest2.json'
ljson = requests.get(url_latest).json()
picons_source_list = ['Custom URL']
picons_source_files = ['Custom URL']
for p in ljson['Picons']['latest']:
picons_source_list.append(p['desc'])
for n in ljson['Picons']['latest']:
picons_source_files.append(n['name'])
picons_source_value = xbmcaddon.Addon().getSetting('psource')
picons_source = picons_source_list[int(picons_source_value)]
picons_file = picons_source_files[int(picons_source_value)]
picons_dest = xbmcaddon.Addon().getSetting('pdest')
picons_url = xbmcaddon.Addon().getSetting('purl')
picons_list = ["Picons Source: " + str(picons_source), "Picons Destination: " + str(picons_dest), "DOWNLOAD PICONS"]
sel_param = dialog.select('Picons Download - Select parameter', list=picons_list)
if sel_param < 0:
return
if sel_param >= 0:
if sel_param == 0:
sel_psource = dialog.select('Select Picons Source', list=picons_source_list)
if sel_psource < 0:
picons_param_load()
else:
picons_source_set = xbmcaddon.Addon().setSetting(id='psource', value=str(sel_psource))
picons_param_load()
if sel_param == 1:
picons_dest_update = dialog.browse(3, "Select Picons Destination", "files", defaultt=picons_dest)
picons_dest_set = xbmcaddon.Addon().setSetting(id='pdest', value=picons_dest_update)
picons_param_load()
if sel_param == 2:
if picons_source_value == "0":
sel_purl = dialog.input('Enter the Picons URL to Download', defaultt=picons_url,type=xbmcgui.INPUT_ALPHANUM)
if sel_purl != "":
picons_url_set = xbmcaddon.Addon().setSetting(id='purl', value=str(sel_purl))
picons.url_external(sel_purl)
if picons_source_value > "0":
picons.compare_release(url_latest, picons_file, picons_source_value)
def dvr_param_load(dvr_uuid_sel):
dvr_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + dvr_uuid_sel
dvr_load = requests.get(dvr_url).json()
dvr_name = dvr_load['entries'][0]['text']
dvr_enabled = find_param(dvr_load, 'enabled')
dvr_keep, dvr_keep_key, dvr_keep_val = find_param_dict(dvr_load, 'removal-days', 'enum')
dvr_profile_value = find_param(dvr_load, 'profile')
dvr_profile_dict_url = 'http://' + tvh_url + ':' + tvh_port + '/api/profile/list'
dvr_profile_dict_load = requests.get(dvr_profile_dict_url).json()
dvr_profile_dict = dvr_profile_dict_load['entries']
dvr_profile_key = []
dvr_profile_val = []
for dvr_k in dvr_profile_dict:
dvr_profile_key.append(dvr_k['key'])
for dvr_v in dvr_profile_dict:
dvr_profile_val.append(dvr_v['val'])
dvr_profile_index = dvr_profile_key.index(dvr_profile_value)
dvr_profile = dvr_profile_val[dvr_profile_index]
dvr_clone = find_param(dvr_load, 'clone')
dvr_storage = find_param(dvr_load, 'storage')
xbmcaddon.Addon().setSetting(id='dvrstorage', value=dvr_storage)
dvr_info_list = ["Name: " + str(dvr_name), "Enabled: " + str(dvr_enabled), "Storage: " + str(dvr_storage), "Days to Keep Recordings: " + str(dvr_keep), "Duplicate Recording Timer If Error Occurs: " + str(dvr_clone), "Stream Profile: " + str(dvr_profile), "Recording File and Folder options", "Timeshift Options"]
dvr_param_edit(dvr_uuid_sel, dvr_info_list, dvr_keep_key, dvr_keep_val, dvr_name, dvr_enabled, dvr_storage, dvr_keep, dvr_clone, dvr_profile_key, dvr_profile_val, dvr_profile)
def dvr_param_edit(dvr_uuid_sel, dvr_info_list, dvr_keep_key, dvr_keep_val, dvr_name, dvr_enabled, dvr_storage, dvr_keep, dvr_clone, dvr_profile_key, dvr_profile_val, dvr_profile):
sel_param = dialog.select('DVR Configuration - Select parameter to edit', list=dvr_info_list)
if sel_param < 0:
dvr()
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_dvr_name = dialog.input('Edit the DVR profile name', defaultt=dvr_name,type=xbmcgui.INPUT_ALPHANUM)
if sel_dvr_name == "":
dvr_param_load(dvr_uuid_sel)
else:
param_update = '"name":"' + sel_dvr_name + '"'
if sel_param == 1:
sel_enabled = dialog.select('Enable or disable the DVR profile', list=enabledisable)
if sel_enabled >= 0:
dvr_enabled = truefalse[sel_enabled]
param_update = '"enabled":' + dvr_enabled
if sel_param == 2:
if tvh_url == "127.0.0.1":
plugin.open_settings()
dvr_storage_update_tvh = xbmcaddon.Addon().getSetting('dvrstorage')
param_update = '"storage":"' + str(dvr_storage_update_tvh) + '"'
else:
dialog.ok('Tvheadend backend on network location', 'Your Tvheadend backend is located on a network. Currently Kodi cannot browse network folders.', 'Please enter the DVR recording location manually.')
dvr_storage_update_tvh = dialog.input('Edit the DVR recording location', defaultt=dvr_storage,type=xbmcgui.INPUT_ALPHANUM)
xbmcaddon.Addon().setSetting(id='dvrstorage', value=dvr_storage_update_tvh)
param_update = '"storage":"' + str(dvr_storage_update_tvh) + '"'
if sel_param == 3:
sel_enabled = dialog.select('Select the number of days to keep DVR recordings', list=dvr_keep_val)
if sel_enabled >= 0:
dvr_keep = dvr_keep_key[sel_enabled]
param_update = '"removal-days":' + str(dvr_keep)
if sel_param == 4:
sel_enabled = dialog.select('Enable or disable the re-recording of a timer if an error occurs', list=enabledisable)
if sel_enabled >= 0:
dvr_clone = truefalse[sel_enabled]
param_update = '"clone":' + dvr_clone
if sel_param == 5:
sel_enabled = dialog.select('Select the stream profile for DVR playback', list=dvr_profile_val)
if sel_enabled >= 0:
dvr_keep = dvr_profile_key[sel_enabled]
param_update = '"profile":' + str(dvr_profile)
if sel_param == 6:
dvr_file_param_load(dvr_uuid_sel)
if sel_param == 7:
time_param_load(dvr_uuid_sel)
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + dvr_uuid_sel + '"}'
param_save = requests.get(param_url)
dvr_param_load(dvr_uuid_sel)
def dvr_file_param_load(dvr_uuid_sel):
dvr_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + dvr_uuid_sel
dvr_load = requests.get(dvr_url).json()
dvr_day_dir = find_param(dvr_load, 'day-dir')
dvr_channel_dir = find_param(dvr_load, 'channel-dir')
dvr_title_dir = find_param(dvr_load, 'title-dir')
dvr_channel_title = find_param(dvr_load, 'channel-in-title')
dvr_date_title = find_param(dvr_load, 'date-in-title')
dvr_time_title = find_param(dvr_load, 'time-in-title')
dvr_episode_title = find_param(dvr_load, 'episode-in-title')
dvr_subtitle_title = find_param(dvr_load, 'subtitle-in-title')
dvr_omit_title = find_param(dvr_load, 'omit-title')
dvr_clean_title = find_param(dvr_load, 'clean-title')
dvr_whitespace_title = find_param(dvr_load, 'whitespace-in-title')
dvr_windows_title = find_param(dvr_load, 'windows-compatible-filenames')
dvr_file_info_list = ["Make subdirectories per day: " + str(dvr_day_dir), "Make subdirectories per channel: " + str(dvr_channel_dir), "Make subdirectories per title: " + str(dvr_title_dir), "Include channel name in filename: " + str(dvr_channel_title), "Include date in filename: " + str(dvr_date_title), "Include time in filename: " + str(dvr_time_title), "Include episode in filename: " + str(dvr_episode_title), "Include subtitle in filename: " + str(dvr_subtitle_title), "Don't include title in filename: " + str(dvr_omit_title), "Remove all unsafe characters from filename: " + str(dvr_clean_title), "Replace whitespace in title with '-': " + str(dvr_whitespace_title), "Use Windows-compatible filenames: " + str(dvr_windows_title)]
dvr_file_param_edit(dvr_uuid_sel, dvr_file_info_list, dvr_day_dir, dvr_channel_dir, dvr_title_dir, dvr_channel_title, dvr_date_title, dvr_time_title, dvr_episode_title, dvr_subtitle_title, dvr_omit_title, dvr_clean_title, dvr_whitespace_title, dvr_windows_title)
def dvr_file_param_edit(dvr_uuid_sel, dvr_file_info_list, dvr_day_dir, dvr_channel_dir, dvr_title_dir, dvr_channel_title, dvr_date_title, dvr_time_title, dvr_episode_title, dvr_subtitle_title, dvr_omit_title, dvr_clean_title, dvr_whitespace_title, dvr_windows_title):
sel_param = dialog.select('DVR File and Folder Options - Select parameter to edit', list=dvr_file_info_list)
if sel_param < 0:
return
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_enabled = dialog.select('Make subdirectories per day', list=enabledisable)
if sel_enabled >= 0:
dvr_day_dir = truefalse[sel_enabled]
param_update = '"day-dir":' + dvr_day_dir
if sel_param == 1:
sel_enabled = dialog.select('Make subdirectories per channel', list=enabledisable)
if sel_enabled >= 0:
dvr_channel_dir = truefalse[sel_enabled]
param_update = '"channel-dir":' + dvr_channel_dir
if sel_param == 2:
sel_enabled = dialog.select('Make subdirectories per title', list=enabledisable)
if sel_enabled >= 0:
dvr_title_dir = truefalse[sel_enabled]
param_update = '"title-dir":' + dvr_title_dir
if sel_param == 3:
sel_enabled = dialog.select('Include channel name in filename', list=enabledisable)
if sel_enabled >= 0:
dvr_channel_title = truefalse[sel_enabled]
param_update = '"channel-in-title":' + dvr_channel_title
if sel_param == 4:
sel_enabled = dialog.select('Include date in filename', list=enabledisable)
if sel_enabled >= 0:
dvr_date_title = truefalse[sel_enabled]
param_update = '"date-in-title":' + dvr_date_title
if sel_param == 5:
sel_enabled = dialog.select('Include time in filename', list=enabledisable)
if sel_enabled >= 0:
dvr_time_title = truefalse[sel_enabled]
param_update = '"time-in-title":' + dvr_time_title
if sel_param == 6:
sel_enabled = dialog.select('Include episode in filename', list=enabledisable)
if sel_enabled >= 0:
dvr_episode_title = truefalse[sel_enabled]
param_update = '"episode-in-title":' + dvr_episode_title
if sel_param == 7:
sel_enabled = dialog.select('Include subtitle in filename', list=enabledisable)
if sel_enabled >= 0:
dvr_subtitle_title = truefalse[sel_enabled]
param_update = '"subtitle-in-title":' + dvr_subtitle_title
if sel_param == 8:
sel_enabled = dialog.select("Don't include title in filename", list=enabledisable)
if sel_enabled >= 0:
dvr_omit_title = truefalse[sel_enabled]
param_update = '"omit-title":' + dvr_omit_title
if sel_param == 9:
sel_enabled = dialog.select('Remove all unsafe characters from filename', list=enabledisable)
if sel_enabled >= 0:
dvr_clean_title = truefalse[sel_enabled]
param_update = '"clean-title":' + dvr_clean_title
if sel_param == 10:
sel_enabled = dialog.select("Replace whitespace in title with '-'", list=enabledisable)
if sel_enabled >= 0:
dvr_whitespace_title = truefalse[sel_enabled]
param_update = '"whitespace-in-title":' + dvr_whitespace_title
if sel_param == 11:
sel_enabled = dialog.select('Use Windows-compatible filenames', list=enabledisable)
if sel_enabled >= 0:
dvr_windows_title = truefalse[sel_enabled]
param_update = '"windows-compatible-filenames":' + dvr_windows_title
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + dvr_uuid_sel + '"}'
param_save = requests.get(param_url)
dvr_file_param_load(dvr_uuid_sel)
def time_param_load(dvr_uuid_sel):
time_url = 'http://' + tvh_url + ':' + tvh_port + '/api/timeshift/config/load'
time_load = requests.get(time_url).json()
time_enabled = find_param(time_load, 'enabled')
time_ondemand = find_param(time_load, 'ondemand')
time_path = find_param(time_load, 'path')
time_max_period = find_param(time_load, 'max_period')
time_unlimited_period = find_param(time_load, 'unlimited_period')
time_max_size = find_param(time_load, 'max_size')
time_ram_size = find_param(time_load, 'ram_size')
time_unlimited_size = find_param(time_load, 'unlimited_size')
time_ram_only = find_param(time_load, 'ram_only')
time_ram_fit = find_param(time_load, 'ram_fit')
time_teletext = find_param(time_load, 'teletext')
time_info_list = ["Timeshift Enabled: " + str(time_enabled), "Maximum Time (mins): " + str(time_max_period), "Storage Path: " + str(time_path), "Maximum Size (MB): " + str(time_max_size), "Maximum RAM Size (MB): " + str(time_ram_size), "RAM Only: " + str(time_ram_only), "On-demand (no first rewind): " + str(time_ondemand), "Unlimited Time: " + str(time_unlimited_period), "Unlimited Size: " + str(time_unlimited_size), "Fit to RAM (cut rewind): " + str(time_ram_fit), "Include Teletext: " + str(time_teletext)]
time_param_edit(dvr_uuid_sel, time_info_list, time_enabled, time_max_period, time_path, time_max_size, time_ram_size, time_ram_only, time_ondemand, time_unlimited_period, time_unlimited_size, time_ram_fit, time_teletext)
def time_param_edit(dvr_uuid_sel, time_info_list, time_enabled, time_max_period, time_path, time_max_size, time_ram_size, time_ram_only, time_ondemand, time_unlimited_period, time_unlimited_size, time_ram_fit, time_teletext):
sel_param = dialog.select('Timeshift Options - Select parameter to edit', list=time_info_list)
if sel_param < 0:
return
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_enabled = dialog.select('Enable/Disable the timeshift function', list=enabledisable)
if sel_enabled >= 0:
time_enabled = truefalse[sel_enabled]
param_update = '"enabled":' + time_enabled
if sel_param == 1:
sel_num = dialog.input('Set maximum time for buffering (minutes)', defaultt=str(time_max_period),type=xbmcgui.INPUT_NUMERIC)
if sel_num >= 0:
time_max_period = sel_num
param_update = '"max_period":' + str(time_max_period)
if sel_param == 2:
if tvh_url == "127.0.0.1":
plugin.open_settings()
time_storage_update_tvh = xbmcaddon.Addon().getSetting('timestorage')
param_update = '"path":"' + str(time_storage_update_tvh) + '"'
else:
dialog.ok('Tvheadend backend on network location', 'Your Tvheadend backend is located on a network. Currently Kodi cannot browse network folders.', 'Please enter the DVR recording location manually.')
time_storage_update_tvh = dialog.input('Edit the timeshift buffer path', defaultt=time_path,type=xbmcgui.INPUT_ALPHANUM)
xbmcaddon.Addon().setSetting(id='timestorage', value=time_storage_update_tvh)
param_update = '"path":"' + str(time_storage_update_tvh) + '"'
if sel_param == 3:
sel_num = dialog.input('Set maximum storage size for buffering (MB)', defaultt=str(time_max_size),type=xbmcgui.INPUT_NUMERIC)
if sel_num >= 0:
time_max_size = sel_num
param_update = '"max_size":' + str(time_max_size)
if sel_param == 4:
sel_num = dialog.input('Set maximum RAM size for buffering (MB)', defaultt=str(time_ram_size),type=xbmcgui.INPUT_NUMERIC)
if sel_num >= 0:
time_ram_size = sel_num
param_update = '"ram_size":' + str(time_ram_size)
if sel_param == 5:
sel_enabled = dialog.select('Enable/Disable to use RAM only', list=enabledisable)
if sel_enabled >= 0:
time_ram_only = truefalse[sel_enabled]
param_update = '"ram_only":' + time_ram_only
if sel_param == 6:
sel_enabled = dialog.select('Enable/Disable timeshift on-demand (no first rewind)', list=enabledisable)
if sel_enabled >= 0:
time_ondemand = truefalse[sel_enabled]
param_update = '"ondemand":' + time_ondemand
if sel_param == 7:
sel_enabled = dialog.select('Enable/Disable unlimited time (may cause slowdown)', list=enabledisable)
if sel_enabled >= 0:
time_unlimited_period = truefalse[sel_enabled]
param_update = '"unlimited_period":' + time_unlimited_period
if sel_param == 8:
sel_enabled = dialog.select('Enable/Disable unlimited size (uses all storage)', list=enabledisable)
if sel_enabled >= 0:
time_unlimited_size = truefalse[sel_enabled]
param_update = '"unlimited_size":' + time_unlimited_size
if sel_param == 9:
sel_enabled = dialog.select('Enable/Disable fit to RAM (clears oldest buffer)', list=enabledisable)
if sel_enabled >= 0:
time_ram_fit = truefalse[sel_enabled]
param_update = '"ram_fit":' + time_ram_fit
if sel_param == 5:
sel_enabled = dialog.select('Enable/Disable to include teletext data', list=enabledisable)
if sel_enabled >= 0:
time_teletext = truefalse[sel_enabled]
param_update = '"teletext":' + time_teletext
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/timeshift/config/save?node={' + param_update + '}'
param_save = requests.get(param_url)
time_param_load(dvr_uuid_sel)
def muxes_load(net_uuid_sel):
net_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + str(net_uuid_sel)
net_load = requests.get(net_url).json()
net_class = net_load['entries'][0]['class']
muxes_url = 'http://' + tvh_url + ':' + tvh_port + '/api/mpegts/mux/grid?limit=999999999&filter=[{"type":"string","value":"' + net_uuid_sel + '","field":"network_uuid"}]'
muxes = requests.get(muxes_url).json()
muxes_name = []
muxes_uuid = []
muxes_enabled = []
muxes_network = []
muxes_frequency = []
muxes_total = muxes['total']
if muxes_total > 0:
for mux_n in muxes['entries']:
muxes_name.append(mux_n['name'])
for mux_u in muxes['entries']:
muxes_uuid.append(mux_u['uuid'])
for mux_w in muxes['entries']:
muxes_network.append(" in " + mux_w['network'])
try:
for mux_f in muxes['entries']:
muxes_frequency.append(mux_f['frequency'])
except:
for mux_f in muxes['entries']:
muxes_frequency.append(mux_f['channel_number'])
muxes_full = list(zip(muxes_name, muxes_network,))
muxes_list = ["%s %s" % x for x in muxes_full]
muxes_frequency, muxes_list, muxes_uuid = list(zip(*sorted(zip(muxes_frequency, muxes_list, muxes_uuid))))
create_mux = "CREATE NEW MUX"
muxes_list = list(muxes_list)
muxes_list.insert(0,create_mux)
muxes_list = tuple(muxes_list)
muxes_frequency = list(muxes_frequency)
muxes_frequency.insert(0,create_mux)
muxes_frequency = tuple(muxes_frequency)
muxes_uuid = list(muxes_uuid)
muxes_uuid.insert(0,create_mux)
muxes_uuid = tuple(muxes_uuid)
else:
muxes_list = ['CREATE NEW MUX']
sel_mux = dialog.select('Select a mux to configure', list=muxes_list)
if sel_mux == 0:
if net_class == "iptv_network" or net_class == "iptv_auto_network":
mux_new_iptv(net_uuid_sel)
else:
mux_new()
if sel_mux >= 0:
mux_uuid_sel = muxes_uuid[sel_mux]
sel_mux_class_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + mux_uuid_sel
sel_mux_class_load = requests.get(sel_mux_class_url).json()
sel_mux_class = sel_mux_class_load['entries'][0]['class']
if sel_mux_class == "dvb_mux_atsc_t":
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
if sel_mux_class == "dvb_mux_atsc_c":
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
if sel_mux_class == "dvb_mux_dvbc":
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
if sel_mux_class == "dvb_mux_dvbt":
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_class == "dvb_mux_dvbs":
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_class == "iptv_mux":
mux_param_load_iptv(mux_uuid_sel, net_uuid_sel)
def mux_param_load_atsct(mux_uuid_sel, net_uuid_sel):
mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + mux_uuid_sel
mux_load = requests.get(mux_url).json()
mux_name = mux_load['entries'][0]['text']
mux_enabled, mux_enabled_key, mux_enabled_val = find_param_dict(mux_load, 'enabled', 'enum')
mux_modulation, mux_modulation_key, mux_modulation_val = find_param_dict(mux_load, 'modulation', 'enum')
mux_delsys, mux_delsys_list = find_param_list(mux_load, 'delsys', 'enum')
mux_scanstate, mux_scanstate_key, mux_scanstate_val = find_param_dict(mux_load, 'scan_state', 'enum')
mux_frequency = find_param(mux_load, 'frequency')
mux_services = find_param(mux_load, 'num_svc')
mux_channels = find_param(mux_load, 'num_chn')
mux_info_list = ["Enabled: " + str(mux_enabled), "Delivery System: " + str(mux_delsys), "Frequency: " + str(mux_frequency), "Modulation: " + str(mux_modulation), "Scan Status: " + str(mux_scanstate), "Number of Services: " + str(mux_services), "Number of Channels: " + str(mux_channels), "DELETE THE MUX"]
mux_param_edit_atsct(mux_uuid_sel, mux_info_list, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel)
def mux_param_edit_atsct(mux_uuid_sel, mux_info_list, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel):
if mux_scanstate == "ACTIVE":
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list, autoclose=4000)
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list)
if sel_param < 0:
muxes()
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_enabled = dialog.select('Enable or disable the mux', list=mux_enabled_val)
if sel_enabled <0:
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_enabled = mux_enabled_key[sel_enabled]
param_update = '"enabled":' + str(mux_enabled)
if sel_param == 1:
sel_enabled = dialog.select('Select the mux delivery system', list=mux_delsys_list)
if sel_enabled <0:
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_delsys = mux_delsys_list[sel_enabled]
param_update = '"delsys":"' + str(mux_delsys + '"')
if sel_param == 2:
sel_mux_frequency = dialog.input('Edit the mux frequency', defaultt=str(mux_frequency),type=xbmcgui.INPUT_NUMERIC)
param_update = '"frequency":' + sel_mux_frequency
if sel_param == 3:
sel_mux_modulation = dialog.select('Select the modulation of the mux', list=mux_modulation_val)
if sel_mux_modulation <0:
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
if sel_mux_modulation >= 0:
mux_modulation = mux_modulation_key[sel_mux_modulation]
param_update = '"modulation":"' + str(mux_modulation) + '"'
if sel_param == 4:
sel_mux_scanstate = dialog.select('Set the scan state of the mux', list=mux_scanstate_val)
if sel_mux_scanstate <0:
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
if sel_mux_scanstate >= 0:
mux_scanstate = mux_scanstate_key[sel_mux_scanstate]
param_update = '"scan_state":' + str(mux_scanstate)
if sel_param == 7:
confirm_del = dialog.yesno('Confirm mux delete', 'Are you sure want to delete the ' + mux_name + ' mux?')
if not confirm_del:
return
delete_mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/delete?uuid=["' + mux_uuid_sel +'"]'
delete_mux = requests.get(delete_mux_url)
muxes_load(net_uuid_sel)
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + mux_uuid_sel + '"}'
param_save = requests.get(param_url)
mux_param_load_atsct(mux_uuid_sel, net_uuid_sel)
def mux_param_load_atscc(mux_uuid_sel, net_uuid_sel):
mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + mux_uuid_sel
mux_load = requests.get(mux_url).json()
mux_name = mux_load['entries'][0]['text']
mux_enabled, mux_enabled_key, mux_enabled_val = find_param_dict(mux_load, 'enabled', 'enum')
mux_modulation, mux_modulation_key, mux_modulation_val = find_param_dict(mux_load, 'constellation', 'enum')
mux_delsys, mux_delsys_list = find_param_list(mux_load, 'delsys', 'enum')
mux_scanstate, mux_scanstate_key, mux_scanstate_val = find_param_dict(mux_load, 'scan_state', 'enum')
mux_frequency = find_param(mux_load, 'frequency')
mux_symbolrate = find_param(mux_load, 'symbolrate')
mux_services = find_param(mux_load, 'num_svc')
mux_channels = find_param(mux_load, 'num_chn')
mux_info_list = ["Enabled: " + str(mux_enabled), "Delivery System: " + str(mux_delsys), "Frequency: " + str(mux_frequency), "Symbol Rate: " + str(mux_symbolrate), "Modulation: " + str(mux_modulation), "Scan Status: " + str(mux_scanstate), "Number of Services: " + str(mux_services), "Number of Channels: " + str(mux_channels), "DELETE THE MUX"]
mux_param_edit_atscc(mux_uuid_sel, mux_info_list, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_symbolrate, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel)
def mux_param_edit_atscc(mux_uuid_sel, mux_info_list, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_symbolrate, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel):
if mux_scanstate == "ACTIVE":
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list, autoclose=4000)
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list)
if sel_param < 0:
muxes()
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_enabled = dialog.select('Enable or disable the mux', list=mux_enabled_val)
if sel_enabled <0:
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_enabled = mux_enabled_key[sel_enabled]
param_update = '"enabled":' + str(mux_enabled)
if sel_param == 1:
sel_enabled = dialog.select('Select the mux delivery system', list=mux_delsys_list)
if sel_enabled <0:
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_delsys = mux_delsys_list[sel_enabled]
param_update = '"delsys":"' + str(mux_delsys + '"')
if sel_param == 2:
sel_mux_frequency = dialog.input('Edit the mux frequency', defaultt=str(mux_frequency),type=xbmcgui.INPUT_NUMERIC)
param_update = '"frequency":' + sel_mux_frequency
if sel_param == 3:
sel_mux_frequency = dialog.input('Edit the mux symbol rate', defaultt=str(mux_symbolrate),type=xbmcgui.INPUT_NUMERIC)
param_update = '"symbolrate":' + sel_mux_symbolrate
if sel_param == 4:
sel_mux_modulation = dialog.select('Select the modulation of the mux', list=mux_modulation_val)
if sel_mux_modulation <0:
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
if sel_mux_modulation >= 0:
mux_modulation = mux_modulation_key[sel_mux_modulation]
param_update = '"constellation":"' + str(mux_modulation) + '"'
if sel_param == 5:
sel_mux_scanstate = dialog.select('Set the scan state of the mux', list=mux_scanstate_val)
if sel_mux_scanstate <0:
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
if sel_mux_scanstate >= 0:
mux_scanstate = mux_scanstate_key[sel_mux_scanstate]
param_update = '"scan_state":' + str(mux_scanstate)
if sel_param == 8:
confirm_del = dialog.yesno('Confirm mux delete', 'Are you sure want to delete the ' + mux_name + ' mux?')
if not confirm_del:
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
delete_mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/delete?uuid=["' + mux_uuid_sel +'"]'
delete_mux = requests.get(delete_mux_url)
muxes_load(net_uuid_sel)
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + mux_uuid_sel + '"}'
param_save = requests.get(param_url)
mux_param_load_atscc(mux_uuid_sel, net_uuid_sel)
def mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel):
mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + mux_uuid_sel
mux_load = requests.get(mux_url).json()
mux_name = mux_load['entries'][0]['text']
mux_enabled, mux_enabled_key, mux_enabled_val = find_param_dict(mux_load, 'enabled', 'enum')
mux_modulation, mux_modulation_key, mux_modulation_val = find_param_dict(mux_load, 'constellation', 'enum')
mux_delsys, mux_delsys_list = find_param_list(mux_load, 'delsys', 'enum')
mux_scanstate, mux_scanstate_key, mux_scanstate_val = find_param_dict(mux_load, 'scan_state', 'enum')
mux_frequency = find_param(mux_load, 'frequency')
mux_bandwidth, mux_bandwidth_key, mux_bandwidth_val = find_param_dict(mux_load, 'bandwidth', 'enum')
mux_transmission, mux_transmission_key, mux_transmission_val = find_param_dict(mux_load, 'transmission_mode', 'enum')
mux_guard, mux_guard_key, mux_guard_val = find_param_dict(mux_load, 'guard_interval', 'enum')
mux_hierarchy, mux_hierarchy_key, mux_hierarchy_val = find_param_dict(mux_load, 'hierarchy', 'enum')
mux_fec_hi, mux_fec_hi_key, mux_fec_hi_val = find_param_dict(mux_load, 'fec_hi', 'enum')
mux_fec_lo, mux_fec_lo_key, mux_fec_lo_val = find_param_dict(mux_load, 'fec_lo', 'enum')
mux_plp_id = find_param(mux_load, 'plp_id')
mux_services = find_param(mux_load, 'num_svc')
mux_channels = find_param(mux_load, 'num_chn')
mux_info_list = ["Enabled: " + str(mux_enabled), "Delivery System: " + str(mux_delsys), "Frequency: " + str(mux_frequency), "Bandwidth: " + str(mux_bandwidth), "COFDM Modulation: " + str(mux_modulation), "Transmission Mode: " + str(mux_transmission), "Guard Interval: " + str(mux_guard), "Hierarchy: " + str(mux_hierarchy), "FEC High: " + str(mux_fec_hi), "FEC Low: " + str(mux_fec_lo), "PLP ID: " + str(mux_plp_id), "Scan Status: " + str(mux_scanstate), "Number of Services: " + str(mux_services), "Number of Channels: " + str(mux_channels), "DELETE THE MUX"]
mux_param_edit_dvbt(mux_uuid_sel, mux_info_list, mux_plp_id, mux_fec_lo, mux_fec_lo_key, mux_fec_lo_val, mux_fec_hi, mux_fec_hi_key, mux_fec_hi_val, mux_hierarchy, mux_hierarchy_key, mux_hierarchy_val, mux_guard, mux_guard_key, mux_guard_val, mux_transmission, mux_transmission_key, mux_transmission_val, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_bandwidth, mux_bandwidth_key, mux_bandwidth_val, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel)
def mux_param_edit_dvbt(mux_uuid_sel, mux_info_list, mux_plp_id, mux_fec_lo, mux_fec_lo_key, mux_fec_lo_val, mux_fec_hi, mux_fec_hi_key, mux_fec_hi_val, mux_hierarchy, mux_hierarchy_key, mux_hierarchy_val, mux_guard, mux_guard_key, mux_guard_val, mux_transmission, mux_transmission_key, mux_transmission_val, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_bandwidth, mux_bandwidth_key, mux_bandwidth_val, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel):
if mux_scanstate == "ACTIVE":
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list, autoclose=4000)
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list)
if sel_param < 0:
muxes()
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_enabled = dialog.select('Enable or disable the mux', list=mux_enabled_val)
if sel_enabled <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_enabled = mux_enabled_key[sel_enabled]
param_update = '"enabled":' + str(mux_enabled)
if sel_param == 1:
sel_enabled = dialog.select('Select the mux delivery system', list=mux_delsys_list)
if sel_enabled <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_delsys = mux_delsys_list[sel_enabled]
param_update = '"delsys":"' + str(mux_delsys + '"')
if sel_param == 2:
sel_mux_frequency = dialog.input('Edit the mux frequency', defaultt=str(mux_frequency),type=xbmcgui.INPUT_NUMERIC)
param_update = '"frequency":' + sel_mux_frequency
if sel_param == 3:
sel_mux_bandwidth = dialog.select('Select the mux bandwidth', list=mux_bandwidth_val)
if sel_mux_bandwidth <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_bandwidth >= 0:
mux_bandwidth = mux_bandwidth_key[sel_mux_bandwidth]
param_update = '"bandwidth":"' + str(mux_bandwidth) + '"'
if sel_param == 4:
sel_mux_modulation = dialog.select('Select the COFDM modulation of the mux', list=mux_modulation_val)
if sel_mux_modulation <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_modulation >= 0:
mux_modulation = mux_modulation_key[sel_mux_modulation]
param_update = '"modulation":"' + str(mux_modulation) + '"'
if sel_param == 5:
sel_mux_transmission = dialog.select('Select the mux transmission mode', list=mux_transmission_val)
if sel_mux_transmission <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_transmission >= 0:
mux_transmission = mux_transmission_key[sel_mux_transmission]
param_update = '"transmission_mode":"' + str(mux_transmission) + '"'
if sel_param == 6:
sel_mux_guard = dialog.select('Select the mux guard interval', list=mux_guard_val)
if sel_mux_guard <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_guard >= 0:
mux_guard = mux_guard_key[sel_mux_guard]
param_update = '"guard_interval":"' + str(mux_guard) + '"'
if sel_param == 7:
sel_mux_hierarchy = dialog.select('Select the mux hierarchy', list=mux_hierarchy_val)
if sel_mux_hierarchy <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_hierarchy >= 0:
mux_hierarchy = mux_hierarchy_key[sel_mux_hierarchy]
param_update = '"hierarchy":"' + str(mux_hierarchy) + '"'
if sel_param == 8:
sel_mux_fec_hi = dialog.select('Select the mux forward error correction high', list=mux_fec_hi_val)
if sel_mux_fec_hi <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_fec_hi >= 0:
mux_fec_hi = mux_fec_hi_key[sel_mux_fec_hi]
param_update = '"fec_hi":"' + str(mux_fec_hi) + '"'
if sel_param == 9:
sel_mux_fec_lo = dialog.select('Select the mux forward error correction low', list=mux_fec_lo_val)
if sel_mux_fec_lo <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_fec_lo >= 0:
mux_fec_lo = mux_fec_lo_key[sel_mux_fec_lo]
param_update = '"fec_lo":"' + str(mux_fec_lo) + '"'
if sel_param == 10:
sel_mux_plp_id = dialog.input('Edit the mux PLP ID', defaultt=str(mux_plp_id),type=xbmcgui.INPUT_ALPHANUM)
if sel_mux_plp_id == "":
return
else:
param_update = '"plp_id":' + sel_mux_plp_id
if sel_param == 11:
sel_mux_scanstate = dialog.select('Set the scan state of the mux', list=mux_scanstate_val)
if sel_mux_scanstate <0:
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
if sel_mux_scanstate >= 0:
mux_scanstate = mux_scanstate_key[sel_mux_scanstate]
param_update = '"scan_state":' + str(mux_scanstate)
if sel_param == 14:
confirm_del = dialog.yesno('Confirm mux delete', 'Are you sure want to delete the ' + mux_name + ' mux?')
if not confirm_del:
return
delete_mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/delete?uuid=["' + mux_uuid_sel +'"]'
delete_mux = requests.get(delete_mux_url)
muxes_load(net_uuid_sel)
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + mux_uuid_sel + '"}'
param_save = requests.get(param_url)
mux_param_load_dvbt(mux_uuid_sel, net_uuid_sel)
def mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel):
mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + mux_uuid_sel
mux_load = requests.get(mux_url).json()
mux_name = mux_load['entries'][0]['text']
mux_enabled, mux_enabled_key, mux_enabled_val = find_param_dict(mux_load, 'enabled', 'enum')
mux_delsys, mux_delsys_list = find_param_list(mux_load, 'delsys', 'enum')
mux_frequency = find_param(mux_load, 'frequency')
mux_symbolrate = find_param(mux_load, 'symbolrate')
mux_polarization, mux_polarization_key, mux_polarization_val = find_param_dict(mux_load, 'polarisation', 'enum')
mux_modulation, mux_modulation_key, mux_modulation_val = find_param_dict(mux_load, 'modulation', 'enum')
mux_fec, mux_fec_key, mux_fec_val = find_param_dict(mux_load, 'fec', 'enum')
mux_scanstate, mux_scanstate_key, mux_scanstate_val = find_param_dict(mux_load, 'scan_state', 'enum')
mux_rolloff, mux_rolloff_key, mux_rolloff_val = find_param_dict(mux_load, 'rolloff', 'enum')
mux_pilot, mux_pilot_key, mux_pilot_val = find_param_dict(mux_load, 'pilot', 'enum')
mux_sidfilter = find_param(mux_load, 'sid_filter')
mux_streamid = find_param(mux_load, 'stream_id')
mux_plsmode, mux_plsmode_key, mux_plsmode_val = find_param_dict(mux_load, 'pls_mode', 'enum')
mux_plscode = find_param(mux_load, 'pls_code')
mux_services = find_param(mux_load, 'num_svc')
mux_channels = find_param(mux_load, 'num_chn')
mux_info_list = ["Enabled: " + str(mux_enabled), "Delivery System: " + str(mux_delsys), "Frequency: " + str(mux_frequency), "Symbol Rate: " + str(mux_symbolrate), "Polarization: " + str(mux_polarization), "Modulation: " + str(mux_modulation), "FEC: " + str(mux_fec), "Rolloff: " + str(mux_rolloff), "Pilot: " + str(mux_pilot), "Service ID: " + str(mux_sidfilter), "ISI Stream ID: " + str(mux_streamid), "PLS Mode: " + str(mux_plsmode), "PLS Code: " + str(mux_plscode), "Scan Status: " + str(mux_scanstate), "Number of Services: " + str(mux_services), "Number of Channels: " + str(mux_channels), "DELETE THE MUX"]
mux_param_edit_dvbs(mux_uuid_sel, mux_info_list, mux_sidfilter, mux_streamid, mux_polarization, mux_polarization_key, mux_polarization_val, mux_symbolrate, mux_plscode, mux_fec, mux_fec_key, mux_fec_val, mux_plsmode, mux_plsmode_key, mux_plsmode_val, mux_pilot, mux_pilot_key, mux_pilot_val, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_rolloff, mux_rolloff_key, mux_rolloff_val, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel)
def mux_param_edit_dvbs(mux_uuid_sel, mux_info_list, mux_sidfilter, mux_streamid, mux_polarization, mux_polarization_key, mux_polarization_val, mux_symbolrate, mux_plscode, mux_fec, mux_fec_key, mux_fec_val, mux_plsmode, mux_plsmode_key, mux_plsmode_val, mux_pilot, mux_pilot_key, mux_pilot_val, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_frequency, mux_rolloff, mux_rolloff_key, mux_rolloff_val, mux_modulation, mux_modulation_key, mux_modulation_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_delsys, mux_delsys_list, mux_name, mux_services, mux_channels, net_uuid_sel):
if mux_scanstate == "ACTIVE":
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list, autoclose=4000)
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list)
if sel_param < 0:
muxes()
if sel_param >= 0:
param_update = ""
if sel_param == 0:
sel_enabled = dialog.select('Enable or disable the mux', list=mux_enabled_val)
if sel_enabled <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_enabled = mux_enabled_key[sel_enabled]
param_update = '"enabled":' + str(mux_enabled)
if sel_param == 1:
sel_enabled = dialog.select('Select the mux delivery system', list=mux_delsys_list)
if sel_enabled <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_enabled >= 0:
mux_delsys = mux_delsys_list[sel_enabled]
param_update = '"delsys":"' + str(mux_delsys + '"')
if sel_param == 2:
sel_mux_frequency = dialog.input('Edit the mux frequency', defaultt=str(mux_frequency),type=xbmcgui.INPUT_NUMERIC)
param_update = '"frequency":' + sel_mux_frequency
if sel_param == 3:
sel_mux_frequency = dialog.input('Edit the mux symbol rate', defaultt=str(mux_symbolrate),type=xbmcgui.INPUT_NUMERIC)
param_update = '"symbolrate":' + sel_mux_symbolrate
if sel_param == 4:
sel_mux_polarization = dialog.select('Select the polarization of the mux', list=mux_polarization_val)
if sel_mux_polarization <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_polarization >= 0:
mux_polarization = mux_polarization_key[sel_mux_polarization]
param_update = '"polarisation":"' + str(mux_polarization) + '"'
if sel_param == 5:
sel_mux_modulation = dialog.select('Select the modulation of the mux', list=mux_modulation_val)
if sel_mux_modulation <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_modulation >= 0:
mux_modulation = mux_modulation_key[sel_mux_modulation]
param_update = '"modulation":"' + str(mux_modulation) + '"'
if sel_param == 6:
sel_mux_fec = dialog.select('Select the mux forward error correction', list=mux_fec_val)
if sel_mux_fec <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_fec >= 0:
mux_fec = mux_fec_key[sel_mux_fec]
param_update = '"fec":"' + str(mux_fec) + '"'
if sel_param == 7:
sel_mux_rolloff = dialog.select('Select the mux rolloff', list=mux_rolloff_val)
if sel_mux_rolloff <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_rolloff >= 0:
mux_rolloff = mux_rolloff_key[sel_mux_rolloff]
param_update = '"rolloff":"' + str(mux_rolloff) + '"'
if sel_param == 8:
sel_mux_pilot = dialog.select('Select the mux pilot', list=mux_pilot_val)
if sel_mux_pilot <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_pilot >= 0:
mux_pilot = mux_pilot_key[sel_mux_pilot]
param_update = '"pilot":"' + str(mux_pilot) + '"'
if sel_param == 9:
sel_mux_sidfilter = dialog.input('Edit the mux Service ID - filter out others', defaultt=str(mux_sidfilter),type=xbmcgui.INPUT_ALPHANUM)
if sel_mux_sidfilter == "":
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
else:
param_update = '"sid_filter":' + sel_mux_sidfilter
if sel_param == 10:
sel_mux_streamid = dialog.input('Edit the mux Stream ID', defaultt=str(mux_streamid),type=xbmcgui.INPUT_ALPHANUM)
if sel_mux_streamid == "":
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
else:
param_update = '"stream_id":' + sel_mux_streamid
if sel_param == 11:
sel_mux_plsmode = dialog.select('Select the mux bandwidth', list=mux_plsmode_val)
if sel_mux_plsmode <0:
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
if sel_mux_plsmode >= 0:
mux_plsmode = mux_plsmode_key[sel_mux_plsmode]
param_update = '"pls_mode":"' + str(mux_plsmode) + '"'
if sel_param == 12:
sel_mux_plscode = dialog.input('Edit the mux PLS Code', defaultt=str(mux_plscode),type=xbmcgui.INPUT_ALPHANUM)
if sel_mux_plscode == "":
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
else:
param_update = '"pls_code":' + sel_mux_plscode
if sel_param == 13:
sel_mux_scanstate = dialog.select('Set the scan state of the mux', list=mux_scanstate_val)
if sel_mux_scanstate <0:
mux_param_load_(mux_uuid_sel, net_uuid_sel)
if sel_mux_scanstate >= 0:
mux_scanstate = mux_scanstate_key[sel_mux_scanstate]
param_update = '"scan_state":' + str(mux_scanstate)
if sel_param == 16:
confirm_del = dialog.yesno('Confirm mux delete', 'Are you sure want to delete the ' + mux_name + ' mux?')
if not confirm_del:
return
delete_mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/delete?uuid=["' + mux_uuid_sel +'"]'
delete_mux = requests.get(delete_mux_url)
muxes_load(net_uuid_sel)
if param_update != "":
param_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/save?node={' + param_update + ',"uuid":"' + mux_uuid_sel + '"}'
param_save = requests.get(param_url)
mux_param_load_dvbs(mux_uuid_sel, net_uuid_sel)
def mux_param_load_iptv(mux_uuid_sel, net_uuid_sel):
mux_url = 'http://' + tvh_url + ':' + tvh_port + '/api/idnode/load?uuid=' + mux_uuid_sel
mux_load = requests.get(mux_url).json()
mux_name = mux_load['entries'][0]['text']
mux_enabled, mux_enabled_key, mux_enabled_val = find_param_dict(mux_load, 'enabled', 'enum')
mux_iptv_muxname = find_param(mux_load, 'iptv_muxname')
mux_url = find_param(mux_load, 'iptv_url')
mux_atsc = find_param(mux_load, 'iptv_atsc')
mux_chnum = find_param(mux_load, 'channel_number')
mux_channels = find_param(mux_load, 'num_chn')
mux_sname= find_param(mux_load, 'iptv_sname')
mux_services = find_param(mux_load, 'num_svc')
mux_scanstate, mux_scanstate_key, mux_scanstate_val = find_param_dict(mux_load, 'scan_state', 'enum')
mux_info_list = ["Enabled: " + str(mux_enabled), "URL: " + str(mux_url), "ATSC: " + str(mux_atsc), "Name: " + (mux_iptv_muxname), "Channel Number: " + str(mux_chnum), "Service Name: " + str(mux_sname), "Scan Status: " + str(mux_scanstate), "Number of Services: " + str(mux_services), "Number of Channels: " + str(mux_channels), "DELETE THE MUX"]
mux_param_edit_iptv(mux_uuid_sel, mux_info_list, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_name, mux_services, mux_channels, mux_url, mux_atsc, mux_iptv_muxname, mux_chnum, mux_sname, net_uuid_sel)
def mux_param_edit_iptv(mux_uuid_sel, mux_info_list, mux_scanstate, mux_scanstate_key, mux_scanstate_val, mux_enabled, mux_enabled_key, mux_enabled_val, mux_name, mux_services, mux_channels, mux_url, mux_atsc, mux_iptv_muxname, mux_chnum, mux_sname, net_uuid_sel):
if mux_scanstate == "ACTIVE":
sel_param = dialog.select(str(mux_name) + ' - Select parameter to edit', list=mux_info_list, autoclose=4000)
mux_param_load_iptv(mux_uuid_sel, net_uuid_sel)