/
plugin.py
4433 lines (4040 loc) · 185 KB
/
plugin.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/python
# -*- coding: utf-8 -*-
'''
****************************************
* coded by Lululla & PCD *
* skin by MMark *
* 03/04/2022 *
* Skin by MMark *
****************************************
#--------------------#
'''
from __future__ import print_function
from . import _
from Components.AVSwitch import AVSwitch
from Components.ActionMap import ActionMap, HelpableActionMap
from Components.config import ConfigSubsection, config, configfile, ConfigYesNo, ConfigEnableDisable, ConfigSelectionNumber, ConfigClock
from Components.config import ConfigSelection, getConfigListEntry, NoSave, ConfigText, ConfigDirectory, ConfigPassword
from Components.ConfigList import ConfigListScreen
from Components.Label import Label
from Components.MenuList import MenuList
from Components.MultiContent import MultiContentEntryText, MultiContentEntryPixmapAlphaTest
from Components.Pixmap import Pixmap
from Components.ProgressBar import ProgressBar
from Components.ServiceEventTracker import ServiceEventTracker, InfoBarBase
from Components.Sources.List import List
from Components.Sources.StaticText import StaticText
from Components.Task import Task, Condition, Job, job_manager as JobManager
from Plugins.Plugin import PluginDescriptor
from Screens.Console import Console
from Screens.InfoBar import MoviePlayer, InfoBar
from Screens.Standby import TryQuitMainloop, Standby
from Screens.InfoBarGenerics import InfoBarShowHide, InfoBarSubtitleSupport, InfoBarSummarySupport, \
InfoBarNumberZap, InfoBarMenu, InfoBarEPG, InfoBarSeek, InfoBarMoviePlayerSummarySupport, \
InfoBarAudioSelection, InfoBarNotifications, InfoBarServiceNotifications
from Screens.LocationBox import LocationBox
from Screens.MessageBox import MessageBox
from Screens.MovieSelection import MovieSelection
from Screens.Screen import Screen
from Screens.Standby import Standby
from Screens.TaskView import JobView
from Screens.VirtualKeyBoard import VirtualKeyBoard
# from Tools import ASCIItranslit
from Tools.Directories import SCOPE_PLUGINS
# from Tools.Directories import pathExists
from Tools.Directories import resolveFilename
from Tools.Downloader import downloadWithProgress
from enigma import RT_HALIGN_CENTER, RT_VALIGN_CENTER
from enigma import RT_HALIGN_LEFT, RT_HALIGN_RIGHT
from enigma import gPixmapPtr, eAVSwitch #eEnv
from enigma import eListbox, eTimer
from enigma import eListboxPythonMultiContent #, eConsoleAppContainer
# from enigma import eServiceCenter
from enigma import eServiceReference
from enigma import ePicLoad #eSize
from enigma import gFont
from enigma import iPlayableService
# from enigma import iServiceInformation
from enigma import loadPNG
# from enigma import quitMainloop
from os import listdir, path, X_OK, chmod, access
from os.path import splitext
from os.path import exists as file_exists
from sys import version_info
from twisted.web.client import downloadPage
# try:
# from StringIO import StringIO
# except ImportError:
# from io import StringIO
try:
from xml.etree.cElementTree import ElementTree, fromstring
except ImportError:
from xml.etree.ElementTree import ElementTree, fromstring
try:
from Plugins.Extensions.XCplugin.Utils import *
except:
from . import Utils
import base64
import glob
import hashlib
import json
import os
import re
import six
import socket
import sys
import time
global STREAMS, piclogo, pictmp, skin_path, Path_Picons, Path_Movies, Path_Movies2, Path_XML, enigma_path
global isStream, btnsearch, eserv, infoname, tport, re_search, pmovies, series, urlinfo, epgimport_path
_session = " "
version = "XC Forever V.2.2"
PY3 = False
plugin_path = os.path.dirname(sys.modules[__name__].__file__)
skin_path = plugin_path
iconpic = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/plugin.png".format('XCplugin'))
filterlist = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/cfg/filterlist.txt".format('XCplugin'))
piclogo = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/skin/fhd/iptvlogo.jpg".format('XCplugin'))
enigma_path = '/etc/enigma2/'
epgimport_path = '/etc/epgimport/'
pictmp = "/tmp/poster.jpg"
xc_list = "/tmp/xc.txt"
iptv_list_tmp = []
re_search = False
pmovies = False
series = False
isStream = False
btnsearch = 0
next_request = 0
stream_url = ""
urlinfo = ""
WGET = ''
pythonVer = sys.version_info.major
print("pythonVer = ", pythonVer)
if pythonVer == 3:
PY3 = True
else:
PY3 = False
if PY3:
from urllib.request import urlopen, Request
from urllib.parse import urlparse
else:
from urllib2 import urlopen, Request
from urlparse import urlparse
try:
from Plugins.Extensions.SubsSupport import SubsSupport, SubsSupportStatus
except ImportError:
class SubsSupport(object):
def __init__(self, *args, **kwargs):
pass
class SubsSupportStatus(object):
def __init__(self, *args, **kwargs):
pass
try:
from OpenSSL import SSL
from twisted.internet import ssl
from twisted.internet._sslverify import ClientTLSOptions
sslverify = True
except:
sslverify = False
if sslverify:
class SNIFactory(ssl.ClientContextFactory):
def __init__(self, hostname=None):
self.hostname = hostname
def getContext(self):
ctx = self._contextFactory(self.method)
if self.hostname:
ClientTLSOptions(self.hostname, ctx)
return ctx
modelive = [("1", "Dvb(1)"), ("4097", "IPTV(4097)")]
if os.path.exists("/usr/bin/gstplayer"):
modelive.append(("5001", "Gstreamer(5001)"))
if os.path.exists("/usr/bin/exteplayer3"):
modelive.append(("5002", "Exteplayer3(5002)"))
if DreamOS():
modelive.append(("8193", "eServiceUri(8193)"))
modemovie = [("4097", "IPTV(4097)")]
if os.path.exists("/usr/bin/gstplayer"):
modemovie.append(("5001", "Gstreamer(5001)"))
if os.path.exists("/usr/bin/exteplayer3"):
modemovie.append(("5002", "Exteplayer3(5002)"))
if DreamOS():
modemovie.append(("8193", "eServiceUri(8193)"))
if DreamOS():
WGET = '/usr/bin/wget --no-check-certificate'
else:
WGET = '/usr/bin/wget'
config.plugins.XCplugin = ConfigSubsection()
config.plugins.XCplugin.data = ConfigYesNo(default=False)
# config.plugins.XCplugin.panel = ConfigSelection(default = "player_api", choices = [("player_api", _("player_api")), ("panel_api", _("panel_api"))])
config.plugins.XCplugin.hostaddress = ConfigText(default="exampleserver.com")
config.plugins.XCplugin.port = ConfigText(default="80")
config.plugins.XCplugin.user = ConfigText(default="Enter_Username", visible_width=50, fixed_size=False)
config.plugins.XCplugin.passw = ConfigPassword(default="******", fixed_size=False, censor="*")
config.plugins.XCplugin.infoexp = ConfigYesNo(default=False)
config.plugins.XCplugin.infoname = NoSave(ConfigText(default="myBouquet"))
# config.plugins.XCplugin.showlive = ConfigEnableDisable(default=True)
config.plugins.XCplugin.LivePlayer = ConfigEnableDisable(default=False)
config.plugins.XCplugin.live = ConfigSelection(default='1', choices=modelive)
config.plugins.XCplugin.services = ConfigSelection(default='4097', choices=modemovie)
config.plugins.XCplugin.typelist = ConfigSelection(default="Multi Live & VOD", choices=["Multi Live & VOD", "Multi Live/Single VOD", "Combined Live/VOD"])
config.plugins.XCplugin.timeout = ConfigText(default="10")
config.plugins.XCplugin.bouquettop = ConfigSelection(default="Bottom", choices=["Bottom", "Top"])
config.plugins.XCplugin.badcar = ConfigEnableDisable(default=False)
config.plugins.XCplugin.picons = ConfigEnableDisable(default=False)
config.plugins.XCplugin.pthpicon = ConfigDirectory(default="/media/hdd/picon")
config.plugins.XCplugin.pthmovie = ConfigDirectory(default="/media/hdd/movie")
try:
from Components.UsageConfig import defaultMoviePath
downloadpath = defaultMoviePath()
config.plugins.XCplugin.pthmovie = ConfigDirectory(default=downloadpath)
except:
if os.path.exists("/usr/bin/apt-get"):
config.plugins.XCplugin.pthmovie = ConfigDirectory(default='/media/hdd/movie')
config.plugins.XCplugin.pdownmovie = ConfigSelection(default="Direct", choices=["JobManager", "Direct", "Requests"])
config.plugins.XCplugin.pthxmlfile = ConfigDirectory(default="/etc/enigma2/xc")
config.plugins.XCplugin.typem3utv = ConfigSelection(default="MPEGTS to TV", choices=["M3U to TV", "MPEGTS to TV"])
config.plugins.XCplugin.strtmain = ConfigEnableDisable(default=True)
config.plugins.XCplugin.autobouquetupdate = ConfigEnableDisable(default=False)
config.plugins.XCplugin.updateinterval = ConfigSelectionNumber(default=24, min=1, max=48, stepwidth=1)
config.plugins.XCplugin.last_update = ConfigText(default="none")
config.plugins.XCplugin.timetype = ConfigSelection(default="interval", choices=[("interval", _("interval")), ("fixed time", _("fixed time"))])
config.plugins.XCplugin.fixedtime = ConfigClock(default=0)
if isHD():
CHANNEL_NUMBER = [3, 0, 50, 40, 0]
CHANNEL_NAME = [75, 0, 900, 40, 1]
FONT_0 = ("Regular", 24)
FONT_1 = ("Regular", 24)
BLOCK_H = 40
piclogo = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/skin/hd/iptvlogo.jpg".format('XCplugin'))
skin_path = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/skin/hd".format('XCplugin'))
elif isFHD():
CHANNEL_NUMBER = [3, 0, 100, 50, 0]
CHANNEL_NAME = [110, 0, 1200, 50, 1]
FONT_0 = ("Regular", 32)
FONT_1 = ("Regular", 32)
BLOCK_H = 50
skin_path = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/skin/fhd".format('XCplugin'))
piclogo = resolveFilename(SCOPE_PLUGINS, "Extensions/{}/skin/fhd/iptvlogo.jpg".format('XCplugin'))
if DreamOS():
skin_path = skin_path + '/dreamOs'
def copy_poster():
os.system("cd / && cp -f " + piclogo + " " + pictmp)
copy_poster()
ntimeout = int(config.plugins.XCplugin.timeout.value)
socket.setdefaulttimeout(ntimeout)
eserv = int(config.plugins.XCplugin.services.value)
infoname = str(config.plugins.XCplugin.infoname.value)
Path_Picons = str(config.plugins.XCplugin.pthpicon.value) + "/"
Path_Movies = str(config.plugins.XCplugin.pthmovie.value) + "/"
Path_Movies2 = Path_Movies
Path_XML = str(config.plugins.XCplugin.pthxmlfile.value) + "/"
def check_port(tport):
url = tport
line = url.strip()
protocol = 'http://'
domain = ''
port = ''
if str(config.plugins.XCplugin.port.value) != '80':
port = str(config.plugins.XCplugin.port.value)
else:
port = '80'
host = ''
urlsplit1 = line.split("/")
protocol = urlsplit1[0] + "//"
if len(urlsplit1) > 2:
domain = urlsplit1[2].split(':')[0]
if len(urlsplit1[2].split(':')) > 1:
port = urlsplit1[2].split(':')[1]
host = "%s%s:%s" % (protocol, domain, port)
if not url.startswith(host):
url = str(url.replace(protocol + domain, host))
return url
class xc_home(Screen):
def __init__(self, session):
Screen.__init__(self, session)
self.session = session
skin = skin_path + "/xc_home.xml"
with open(skin, 'r') as f:
self.skin = f.read()
self.setup_title = ('MAIN MENU')
self.list = []
self["Text"] = Label("")
self["version"] = Label(version)
self['text'] = xcM3UList([])
self["key_red"] = Label(_("Exit"))
self["key_green"] = Label(_("Select"))
self["key_yellow"] = Label(_("Movie"))
self["key_blue"] = Label(_("Loader M3U"))
self["actions"] = HelpableActionMap(self, "XCpluginActions", {
"cancel": self.exitY,
"back": self.exitY,
"home": self.exitY,
"showMediaPlayer": self.showMovies,
"pvr": self.showMovies,
"2": self.showMovies,
"menu": self.config,
"help": self.help,
"green": self.Team,
"yellow": self.taskManager,
"movielist": self.taskManager,
"blue": self.xcPlay,
"ok": self.button_ok,
"info": self.help}, -1)
self.onFirstExecBegin.append(self.check_dependencies)
self.onLayoutFinish.append(self.updateMenuList)
def check_dependencies(self):
dependencies = True
try:
import requests
# from PIL import Image
pythonFull = float(str(sys.version_info.major) + "." + str(sys.version_info.minor))
print("***** python version *** %s" % pythonFull)
if pythonFull < 3.9:
print("*** checking multiprocessing ***")
from multiprocessing.pool import ThreadPool
except Exception as e:
print("**** missing dependencies ***")
print(e)
dependencies = False
if dependencies is False:
os.chmod("/usr/lib/enigma2/python/Plugins/Extensions/XCplugin/dependencies.sh", 0o0755)
cmd1 = ". /usr/lib/enigma2/python/Plugins/Extensions/XCplugin/dependencies.sh"
self.session.openWithCallback(self.start, Console, title="Checking Dependencies", cmdlist=[cmd1], closeOnSuccess=True)
else:
self.start()
def start(self):
OnclearMem()
def config(self):
self.session.open(xc_config)
def button_ok(self):
self.keyNumberGlobalCB(self['text'].getSelectedIndex())
def exitY(self):
ReloadBouquets()
self.close()
def Team(self):
self.session.open(OpenServer)
def help(self):
self.session.open(xc_help)
def taskManager(self):
self.session.open(xc_StreamTasks)
def xcPlay(self):
self.session.open(xc_Play)
def showMovies(self):
try:
self.session.open(MovieSelection)
except:
pass
def OpenList(self):
global STREAMS
STREAMS = iptv_streamse()
STREAMS.read_config()
if "exampleserver.com" not in STREAMS.xtream_e2portal_url:
STREAMS.get_list(STREAMS.xtream_e2portal_url)
self.session.openWithCallback(check_configuring, xc_Main)
else:
message = (_("First Select the list or enter it in Config"))
web_info(message)
def updateMenuList(self):
global infoname
self.menu_list = []
for x in self.menu_list:
del self.menu_list[0]
list = []
# idx = 0
for x in Panel_list:
list.append(xcm3ulistEntry(x))
self.menu_list.append(x)
# idx += 1
self['text'].setList(list)
if config.plugins.XCplugin.infoexp.getValue():
infoname = str(config.plugins.XCplugin.infoname.value)
self["Text"].setText(infoname)
def keyNumberGlobalCB(self, idx):
sel = self.menu_list[idx]
if sel == ('HOME'):
self.OpenList()
elif sel == ('PLAYLIST'):
self.session.open(OpenServer)
elif sel == ('MAKER BOUQUET'):
self.session.open(xc_maker)
elif sel == ('MOVIE'):
self.taskManager()
elif sel == ('PLAYER UTILITY '):
self.session.open(xc_Play)
elif sel == ('CONFIG'):
self.session.open(xc_config)
elif sel == ('ABOUT HELP'):
self.session.open(xc_help)
class xc_config(Screen, ConfigListScreen):
def __init__(self, session):
Screen.__init__(self, session)
self.session = session
skin = skin_path + "/xc_config.xml"
with open(skin, 'r') as f:
self.skin = f.read()
self.setup_title = ('XCplugin Forever')
self.list = []
self.onChangedEntry = []
self.downloading = False
self["playlist"] = Label()
self["playlist"].setText("Xstream Code Setup")
self["version"] = Label(version)
self['statusbar'] = Label()
self["description"] = Label("")
self["key_red"] = Label(_("Back"))
self["key_green"] = Label(_("Save"))
self["key_blue"] = Label(_("Import") + " txt")
self["key_yellow"] = Label(_("Import") + " sh")
self["actions"] = HelpableActionMap(self, "XCpluginActions", {
"home": self.extnok,
"cancel": self.extnok,
"left": self.keyLeft,
"right": self.keyRight,
"help": self.help,
"yellow": self.iptv_sh,
"green": self.cfgok,
"blue": self.ImportInfosServer,
"showVirtualKeyboard": self.KeyText,
"ok": self.ok
}, -1)
self.update_status()
ConfigListScreen.__init__(self, self.list, session=self.session, on_change=self.changedEntry)
self.createSetup()
self.showhide()
self.onLayoutFinish.append(self.layoutFinished)
def iptv_sh(self):
self.session.openWithCallback(self.importIptv_sh, MessageBox, _("Import Server from /ect/enigma2/iptv.sh?"), type=MessageBox.TYPE_YESNO, timeout=10, default=False)
def importIptv_sh(self, result):
if result:
iptvsh = "/etc/enigma2/iptv.sh"
if file_exists(iptvsh) and os.stat(iptvsh).st_size > 0:
with open(iptvsh, 'r') as f:
fpage = f.read()
regexcat = 'USERNAME="(.*?)".*?PASSWORD="(.*?)".*?url="http://(.*?):(.*?)/get.php.*?'
match = re.compile(regexcat, re.DOTALL).findall(fpage)
for usernamesh, passwordsh, urlsh, ports in match:
urlsh = urlsh.replace('"', '')
usernamesh = usernamesh.replace('"', '')
passwordsh = passwordsh.replace('"', '')
config.plugins.XCplugin.hostaddress.setValue(urlsh)
config.plugins.XCplugin.port.setValue(ports)
config.plugins.XCplugin.user.setValue(usernamesh)
config.plugins.XCplugin.passw.setValue(passwordsh)
filesave = "xc_sh_" + str(config.plugins.XCplugin.user.value) + ".xml"
filesave = filesave.replace(":", "_").lower()
with open(Path_XML + filesave, "w") as t:
t.write(str('<?xml version="1.0" encoding="UTF-8" ?>\n' + '<items>\n' + '<plugin_version>' + version + '</plugin_version>\n' + '<xtream_e2portal_url><![CDATA[http://' + urlsh + ']]></xtream_e2portal_url>\n' + '<port>' + ports + '</port>\n' + '<username>' + usernamesh + '</username>\n' + '<password>' + passwordsh + '</password>\n' + '</items>'))
t.close()
self.ConfigText()
else:
self.mbox = self.session.open(MessageBox, (_("Missing %s !") % iptvsh), MessageBox.TYPE_INFO, timeout=4)
def ImportInfosServer(self):
self.session.openWithCallback(self.importIptv_txt, MessageBox, _("Import Server from /tmp/xc.tx?"), type=MessageBox.TYPE_YESNO, timeout=10, default=False)
def importIptv_txt(self, result):
if result:
if os.path.isfile(xc_list) and os.stat(xc_list).st_size > 0:
with open(xc_list, 'r') as f:
chaine = f.readlines()
url = chaine[0].replace("\n", "").replace("\t", "").replace("\r", "")
port = chaine[1].replace("\n", "").replace("\t", "").replace("\r", "").replace(":", "_")
user = chaine[2].replace("\n", "").replace("\t", "").replace("\r", "").replace(":", "_")
pswrd = chaine[3].replace("\n", "").replace("\t", "").replace("\r", "")
filesave = "xc_txt_" + user + ".xml"
filesave = filesave.replace(":", "_")
filesave = filesave.lower()
with open(Path_XML + filesave, "w") as t:
t.write(str('<?xml version="1.0" encoding="UTF-8" ?>\n' + '<items>\n' + '<plugin_version>' + version + '</plugin_version>\n' + '<xtream_e2portal_url><![CDATA[http://' + url + ']]></xtream_e2portal_url>\n' + '<port>' + str(port) + '</port>\n' + '<username>' + user + '</username>\n' + '<password>' + pswrd + '</password>\n' + '</items>'))
t.close()
self.mbox = self.session.open(MessageBox, _("File saved to %s !" % filesave), MessageBox.TYPE_INFO, timeout=5)
config.plugins.XCplugin.hostaddress.setValue(url)
config.plugins.XCplugin.port.setValue(port)
config.plugins.XCplugin.user.setValue(user)
config.plugins.XCplugin.passw.setValue(pswrd)
self.createSetup()
else:
self.mbox = self.session.open(MessageBox, _("File not found %s" % xc_list), MessageBox.TYPE_INFO, timeout=5)
def update_status(self):
if config.plugins.XCplugin.autobouquetupdate:
self['statusbar'].setText(_("Last channel update: %s") % config.plugins.XCplugin.last_update.value)
def layoutFinished(self):
self.setTitle(self.setup_title)
def help(self):
self.session.open(xc_help)
def createSetup(self):
self.editListEntry = None
self.list = []
indent = "- "
self.list.append(getConfigListEntry(_("Data Server Configuration:"), config.plugins.XCplugin.data, (_("Your Server Login and data input"))))
if config.plugins.XCplugin.data.getValue():
# self.list.append(getConfigListEntry(_("Old/New panel"), config.plugins.XCplugin.panel, (_("Select Panel used"))))
self.list.append(getConfigListEntry(_("Server URL"), config.plugins.XCplugin.hostaddress, (_("Enter Server Url without 'http://' your_domine"))))
self.list.append(getConfigListEntry(_("Server PORT"), config.plugins.XCplugin.port, (_("Enter Server Port '8080'"))))
self.list.append(getConfigListEntry(_("Server Username"), config.plugins.XCplugin.user, (_("Enter Username"))))
self.list.append(getConfigListEntry(_("Server Password"), config.plugins.XCplugin.passw, (_("Enter Password"))))
self.list.append(getConfigListEntry(_("Server Timeout"), config.plugins.XCplugin.timeout, (_("Timeout Server (sec)"))))
self.list.append(getConfigListEntry(_("Folder user file .xml"), config.plugins.XCplugin.pthxmlfile, (_("Configure folder containing .xml files\nPress 'OK' to change location."))))
self.list.append(getConfigListEntry(_("Media Folder "), config.plugins.XCplugin.pthmovie, (_("Configure folder containing movie/media files\nPress 'OK' to change location."))))
# self.list.append(getConfigListEntry(_("Show/Hide Live Channel "), config.plugins.XCplugin.showlive, (_("Show/Hide Live Channel"))))
# if config.plugins.XCplugin.showlive.value is True:
self.list.append(getConfigListEntry(_("LivePlayer Active "), config.plugins.XCplugin.LivePlayer, (_("Live Player for Stream .ts: set No for Record Live"))))
if config.plugins.XCplugin.LivePlayer.value is True:
self.list.append(getConfigListEntry(_("Live Services Type"), config.plugins.XCplugin.live, (_("Configure service Reference Dvb-Iptv-Gstreamer-Exteplayer3"))))
self.list.append(getConfigListEntry(_("Download Type "), config.plugins.XCplugin.pdownmovie, (_("Configure type of download movie: JobManager/Direct."))))
self.list.append(getConfigListEntry(_("Filter Bad Tag"), config.plugins.XCplugin.badcar, (_("Filter Bad Tag"))))
self.list.append(getConfigListEntry(_("Bouquet style "), config.plugins.XCplugin.typelist, (_("Configure the type of conversion in the favorite list"))))
if config.plugins.XCplugin.typelist.value == "Combined Live/VOD":
self.list.append(getConfigListEntry(_("Conversion type Output "), config.plugins.XCplugin.typem3utv, (_("Configure type of stream to be downloaded by conversion"))))
self.list.append(getConfigListEntry(_("Vod Services Type"), config.plugins.XCplugin.services, (_("Configure service Reference Iptv-Gstreamer-Exteplayer3"))))
self.list.append(getConfigListEntry(_("Name Server Bouquet Configuration:"), config.plugins.XCplugin.infoexp, (_("Set Name for MakerBouquet"))))
if config.plugins.XCplugin.infoexp.getValue():
self.list.append(getConfigListEntry(_("Name Bouquet Export"), config.plugins.XCplugin.infoname, (_("Configure name of bouqet exported. Default is myBouquet"))))
self.list.append(getConfigListEntry(_("Place IPTV bouquets at "), config.plugins.XCplugin.bouquettop, (_("Configure to place the bouquets of the converted lists"))))
self.list.append(getConfigListEntry(_("Automatic bouquet update (schedule):"), config.plugins.XCplugin.autobouquetupdate, (_("Active Automatic Bouquet Update"))))
if config.plugins.XCplugin.autobouquetupdate.getValue():
self.list.append(getConfigListEntry(indent + (_("Schedule type:")), config.plugins.XCplugin.timetype, (_("At an interval of hours or at a fixed time"))))
if config.plugins.XCplugin.timetype.value == "interval":
self.list.append(getConfigListEntry(2 * indent + (_("Update interval (hours):")), config.plugins.XCplugin.updateinterval, (_("Configure every interval of hours from now"))))
if config.plugins.XCplugin.timetype.value == "fixed time":
self.list.append(getConfigListEntry(2 * indent + (_("Time to start update:")), config.plugins.XCplugin.fixedtime, (_("Configure at a fixed time"))))
self.list.append(getConfigListEntry(_("Picons IPTV "), config.plugins.XCplugin.picons, (_("Download Picons ?"))))
if config.plugins.XCplugin.picons.value:
self.list.append(getConfigListEntry(_("Picons IPTV bouquets to "), config.plugins.XCplugin.pthpicon, (_("Configure folder containing picons files\nPress 'OK' to change location."))))
self.list.append(getConfigListEntry(_("Link in Main Menu "), config.plugins.XCplugin.strtmain, (_("Display XCplugin in Main Menu"))))
self["config"].list = self.list
self["config"].setList(self.list)
def changedEntry(self):
for x in self.onChangedEntry:
x()
def getCurrentEntry(self):
return self["config"].getCurrent()[0]
def showhide(self):
pass
def getCurrentValue(self):
return str(self["config"].getCurrent()[1].getText())
def createSummary(self):
from Screens.Setup import SetupSummary
return SetupSummary
def keyLeft(self):
ConfigListScreen.keyLeft(self)
self.createSetup()
self.showhide()
def keyRight(self):
ConfigListScreen.keyRight(self)
self.createSetup()
self.showhide()
def ok(self):
ConfigListScreen.keyOK(self)
sel = self["config"].getCurrent()[1]
if sel and sel == config.plugins.XCplugin.pthmovie:
self.setting = "pthmovie"
self.openDirectoryBrowser(config.plugins.XCplugin.pthmovie.value)
if sel and sel == config.plugins.XCplugin.pthxmlfile:
self.setting = "pthxmlfile"
self.openDirectoryBrowser(config.plugins.XCplugin.pthxmlfile.value)
if sel and sel == config.plugins.XCplugin.pthpicon:
self.setting = "pthpicon"
self.openDirectoryBrowser(config.plugins.XCplugin.pthpicon.value)
else:
pass
def openDirectoryBrowser(self, path):
try:
self.session.openWithCallback(
self.openDirectoryBrowserCB,
LocationBox,
windowTitle=_("Choose Directory:"),
text=_("Choose directory"),
currDir=str(path),
bookmarks=config.movielist.videodirs,
autoAdd=False,
editDir=True,
inhibitDirs=["/bin", "/boot", "/dev", "/home", "/lib", "/proc", "/run", "/sbin", "/sys", "/var"],
minFree=15)
except Exception as ex:
print("openDirectoryBrowser get failed: ", str(ex))
def openDirectoryBrowserCB(self, path):
if path != None:
if self.setting == "pthmovie":
config.plugins.XCplugin.pthmovie.setValue(path)
if self.setting == "pthxmlfile":
config.plugins.XCplugin.pthxmlfile.setValue(path)
if self.setting == "pthpicon":
config.plugins.XCplugin.pthpicon.setValue(path)
configfile.save()
return
def cfgok(self):
if config.plugins.XCplugin.picons.value and config.plugins.XCplugin.pthpicon.value == "/usr/share/enigma2/picon/":
if not os.path.exists("/usr/share/enigma2/picon"):
os.system("mkdir /usr/share/enigma2/picon")
if config.plugins.XCplugin.pthxmlfile.value == "/media/hdd/xc":
if not os.path.exists("/media/hdd"):
self.mbox = self.session.open(MessageBox, _("/media/hdd NOT DETECTED!"), MessageBox.TYPE_INFO, timeout=4)
return
if config.plugins.XCplugin.pthxmlfile.value == "/media/usb/xc":
if not os.path.exists("/media/usb"):
self.mbox = self.session.open(MessageBox, _("/media/usb NOT DETECTED!"), MessageBox.TYPE_INFO, timeout=4)
return
self.save()
def xml_plugin(self):
filesave = "xc_" + str(config.plugins.XCplugin.user.value) + ".xml"
if 'Enter' in filesave:
self.mbox = self.session.open(MessageBox, _("No Valid data Username Default !"), MessageBox.TYPE_INFO, timeout=5)
else:
filesave = filesave.replace(":", "_")
filesave = filesave.lower()
port = str(config.plugins.XCplugin.port.value)
with open(Path_XML + filesave, "w") as f:
f.write(str('<?xml version="1.0" encoding="UTF-8" ?>\n' + '<items>\n' + '<plugin_version>' + version + '</plugin_version>\n' + '<xtream_e2portal_url><![CDATA[http://' + str(config.plugins.XCplugin.hostaddress.value) + ']]></xtream_e2portal_url>\n' + '<port>' + port + '</port>\n' + '<username>' + str(config.plugins.XCplugin.user.value) + '</username>\n' + '<password>' + str(config.plugins.XCplugin.passw.value) + '</password>\n' + '</items>'))
f.close()
def save(self):
if self["config"].isChanged():
for x in self["config"].list:
x[1].save()
config.plugins.XCplugin.typem3utv.save()
config.plugins.XCplugin.pthmovie.save()
configfile.save()
self.xml_plugin()
self.mbox = self.session.open(MessageBox, _("Settings saved successfully !"), MessageBox.TYPE_INFO, timeout=5)
self.close()
def KeyText(self):
sel = self["config"].getCurrent()
if sel:
self.session.openWithCallback(self.VirtualKeyBoardCallback, VirtualKeyBoard, title=self["config"].getCurrent()[0], text=self["config"].getCurrent()[1].value)
def VirtualKeyBoardCallback(self, callback=None):
if callback != None and len(callback):
self["config"].getCurrent()[1].value = callback
self["config"].invalidate(self["config"].getCurrent())
return
def cancelConfirm(self, result):
if not result:
return
for x in self["config"].list:
x[1].cancel()
self.close()
def extnok(self):
if self["config"].isChanged():
self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"))
else:
self.close()
def ConfigText(self):
STREAMS.read_config()
STREAMS.get_list(STREAMS.xtream_e2portal_url)
class iptv_streamse():
def __init__(self):
global MODUL, iptv_list_tmp, tport
self.iptv_list = []
self.iptv_list_tmp = []
self.iptv_list_history = []
self.plugin_version = ""
# self.xml_error = ""
self.playlistname = ""
self.playlistname_tmp = ""
self.next_page_url = ""
self.next_page_text = ""
self.prev_page_url = ""
self.prev_page_text = ""
# self.clear_url = ""
self.trial = ""
self.banned_text = ""
self.systems = ""
self.playhack = ""
self.url_tmp = ""
self.next_page_url_tmp = ""
self.next_page_text_tmp = ""
self.prev_page_url_tmp = ""
self.prev_page_text_tmp = ""
self.esr_id = 4097
self.list_index_tmp = 0
self.list_index = 0
self.ar_id_start = 0
self.ar_id_end = 0
self.ar_id_player = 0
self.play_vod = False
self.play_iptv = False
self.video_status = False
self.server_oki = True
self.ar_start = True
self.img_loader = False
self.cont_play = False
self.disable_audioselector = False
self.port = str(config.plugins.XCplugin.port.value)
self.hostaddress = config.plugins.XCplugin.hostaddress.value
self.hosts = "http://" + str(config.plugins.XCplugin.hostaddress.value)
self.xtream_e2portal_url = self.hosts + ':' + self.port
self.username = str(config.plugins.XCplugin.user.value)
self.password = str(config.plugins.XCplugin.passw.value)
def MoviesFolde(self):
return Path_Movies
def getValue(self, definitions, default):
Len = len(definitions)
return Len > 0 and definitions[Len - 1].text or default
def read_config(self):
try:
print("-----------CONFIG NEW START----------")
# self.hosts = "http://" + str(config.plugins.XCplugin.hostaddress.value)
# self.port = str(config.plugins.XCplugin.port.value)
# self.xtream_e2portal_url = self.hosts + ':' + self.port
username = self.username
if username and username != "" and 'Enter' not in username:
self.username = username
print('ok user #ok pass')
password = str(config.plugins.XCplugin.passw.value)
if password and password != "" and 'Enter' not in password:
self.password = password
print('ok password #ok pass')
plugin_version = version
print('xtream_e2portal_url = ', self.xtream_e2portal_url)
print('port = ', self.port)
print('username = ', self.username)
print('password = ', self.password)
print('plugin_version = ', plugin_version)
# print('stream_live = ', stream_live)
print('stream_url = ', stream_url)
print('iptv_list_tmp = ', iptv_list_tmp)
print('btnsearch = ', btnsearch)
print('next_request = ', next_request )
print('isStream = ', isStream )
print("-----------CONFIG NEW END----------")
except Exception as ex:
print("++++++++++ERROR READ CONFIG+++++++++++++ ")
print(str(ex))
def get_list(self, url=None):
global stream_live, iptv_list_tmp, stream_url, btnsearch, isStream, next_request, infoname
stream_live = False
stream_url = ""
# self.xml_error = ""
self.url = check_port(url)
# self.url = url
# self.clear_url = self.url
self.list_index = 0
iptv_list_tmp = []
xml = None
btnsearch = 0
next_request = 0
isStream = False
try:
print("!!!!!!!!-------------------- URL %s" % self.url)
if '&type' in self.url:
next_request = 1
# elif "_get" in self.url:
# next_request = 2
elif "get_" in self.url: #at start
next_request = 2
xml = self._request(self.url)
print('res xml: ', str(xml))
# if xml or xml != None:
if xml:
self.next_page_url = ""
self.next_page_text = ""
self.prev_page_url = ""
self.prev_page_text = ""
self.playlistname = ""
playlistname_exists = xml.findtext('playlist_name')
if playlistname_exists:
self.playlistname = xml.findtext('playlist_name')#.encode('utf-8')
infoname = self.playlistname
if config.plugins.XCplugin.infoexp.getValue():
infoname = str(config.plugins.XCplugin.infoname.value)
self.next_page_url = xml.findtext("next_page_url")
next_page_text_element = xml.findall("next_page_url")
if next_page_text_element:
self.next_page_text = next_page_text_element[0].attrib.get("text")#.encode("utf-8")
# print('next_page_text encode')
self.prev_page_url = xml.findtext("prev_page_url")
prev_page_text_element = xml.findall("prev_page_url")
if prev_page_text_element:
self.prev_page_text = prev_page_text_element[0].attrib.get("text")#.encode("utf-8")
# print('prev_page_text encode')
chan_counter = 0
for channel in xml.findall("channel"):
chan_counter = chan_counter + 1
title64 = ''
name = ''
description64 = ''
description = ''
category_id = ''
playlist_url = ''
desc_image = ''
# stream_url = ''
piconname = ''
ts_stream = ''
nameepg = ''
description4playlist_html = ''
title64 = channel.findtext('title')
name = base64.b64decode(title64).decode('utf-8')
####test bad char from kiddac plugin
if config.plugins.XCplugin.badcar.value == True:
name = badcar(name)
####
description64 = channel.findtext('description')
description = base64.b64decode(description64).decode('utf-8')
try:
name = ''.join(chr(ord(c)) for c in name).decode('utf8')
except:
pass
try:
description = ''.join(chr(ord(c)) for c in description).decode('utf8')
except:
pass
stream_url = checkStr(channel.findtext('stream_url'))
piconname = checkStr(channel.findtext("logo"))
category_id = checkStr(channel.findtext('category_id'))
ts_stream = checkStr(channel.findtext("ts_stream"))
playlist_url = checkStr(channel.findtext('playlist_url'))
desc_image = checkStr(channel.findtext('desc_image'))
if desc_image and desc_image != "n/A" and desc_image != "":
# if desc_image.startswith("https"):
desc_image = str(desc_image)
# if PY3:
# desc_image = desc_image.encode()
# if isStream and "/live/"or "/series/" in stream_url : #and category_id =='0' or category_id == '2':
if stream_url and stream_url != "n/A" and stream_url != "": #stream_url = None ????
isStream = True
# if isStream and ("/live/" or "/series/") in stream_url:
# if isStream and "/live/" or "/series/" in stream_url :
if isStream and "/live/" in stream_url:
print("****** is live stream **** ")
stream_live = True
epgnowtime = ''
epgnowdescription = ''
epgnexttitle = ''
epgnexttime = ''
epgnextdescription = ''
if len(name.split("[")) > 1:
name = name.split("[")[0].strip()
# if description != '':
# timematch = re.findall(r'\[(\d\d:\d\d)\]', description)
# titlematch = re.findall(r'\[\d\d:\d\d\](.*)', description)
# descriptionmatch = re.findall(r'\n(?s)\((.*?)\)', description)
# if timematch:
# if len(timematch) > 0:
# epgnowtime = timematch[0].strip()
# if len(timematch) > 1:
# epgnexttime = timematch[1].strip()
# if titlematch:
# if len(titlematch) > 0:
# name = titlematch[0].strip()
# if len(titlematch) > 1:
# epgnexttitle = titlematch[1].strip()
# if descriptionmatch:
# if len(descriptionmatch) > 0:
# epgnowdescription = descriptionmatch[0].strip()
# if len(descriptionmatch) > 1:
# epgnextdescription = descriptionmatch[1].strip()
# description = epgnowtime + ' ' + name + '\n' + epgnowdescription
# description4playlist_html = epgnexttime + ' ' + epgnexttitle + '\n' + epgnextdescription
if description != '':
timematch = re.findall(r'\[(\d\d:\d\d)\]', description)
titlematch = re.findall(r'\[\d\d:\d\d\](.*)', description)
print('=============titlematch: ', titlematch)
descriptionmatch = re.findall(r'\n(?s)\((.*?)\)', description)
if timematch:
if len(timematch) > 0:
epgnowtime = timematch[0].strip()
if len(timematch) > 1:
epgnexttime = timematch[1].strip()
if titlematch:
# if len(titlematch) > 0:
# name = titlematch[0].strip()
if len(titlematch) > 0:
nameepg = titlematch[0].strip()
if len(titlematch) > 1:
epgnexttitle = titlematch[1].strip()
if descriptionmatch:
if len(descriptionmatch) > 0:
epgnowdescription = descriptionmatch[0].strip()
if len(descriptionmatch) > 1:
epgnextdescription = descriptionmatch[1].strip()
description = epgnowtime + ' ' + name + '\n' + epgnowdescription
description4playlist_html = epgnexttime + ' ' + epgnexttitle + '\n' + epgnextdescription
# if "/movie/" in stream_url :
# if isStream and "/movie/" in stream_url:
if isStream and ("/movie/" or "/series/") in stream_url:
stream_live = False
vodTitle = ''
vodDescription = ''
vodDuration = ''
vodGenre = ''
# vodVideoType = ''
# vodRating = ''
# vodCountry = ''
# vodReleaseDate = ''
# vodDirector = ''
# vodCast = ''
vodLines = description.splitlines()
vodItems = {}
for line in vodLines:
vodItems[checkStr(line.partition(": ")[0])] = checkStr(line.partition(": ")[-1])
if "NAME" in vodItems:
vodTitle = str(vodItems["NAME"]).strip()
elif "O_NAME" in vodItems:
vodTitle = str(vodItems["O_NAME"]).strip()
else:
vodTitle = str(name)
if "COVER_BIG" in vodItems and vodItems["COVER_BIG"] and vodItems["COVER_BIG"] != "null" :
piconname = str(vodItems["COVER_BIG"]).strip()
if "DESCRIPTION" in vodItems:
vodDescription = str(vodItems["DESCRIPTION"]).strip()
elif "PLOT" in vodItems:
vodDescription = str(vodItems["PLOT"]).strip()
else:
vodDescription = str('TRAMA')
if "DURATION" in vodItems:
vodDuration = str(vodItems["DURATION"]).strip()
else:
vodDuration = str('DURATION: -- --')
if "GENRE" in vodItems:
vodGenre = str(vodItems["GENRE"]).strip()
else:
vodGenre = str('GENRE: -- --')
name = str(vodTitle)
description = str(vodTitle) + '\n' + str(vodGenre) + '\nDuration: ' + str(vodDuration) + '\n' + str(vodDescription)
chan_tulpe = (
chan_counter,
str(name),
str(description),
piconname,
stream_url,
playlist_url,
str(category_id),
desc_image,
str(description4playlist_html),
# ts_stream,
nameepg)
iptv_list_tmp.append(chan_tulpe)
btnsearch = next_request
except Exception as e:
print('checkRedirect get failed: ', str(e))
# self.xml_error = 'error'
if len(iptv_list_tmp):