-
Notifications
You must be signed in to change notification settings - Fork 58
Expand file tree
/
Copy pathinstaller.py
More file actions
1131 lines (1013 loc) · 47.8 KB
/
Copy pathinstaller.py
File metadata and controls
1131 lines (1013 loc) · 47.8 KB
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
# TVADDONS.CO / TVADDONS.CO - Addon Installer - Module By: Blazetamer (2013-2016)
import base64
import downloader
import extract
import os
import re
import ssl
import string
import sys
import time
import traceback
import urllib
import urllib2
import xbmc
import xbmcaddon
import xbmcgui
import xbmcplugin
from itertools import izip_longest
from libs import addon_able
from libs import aiapi
from libs import kodi
from libs import viewsetter
if kodi.get_kversion() > 16.5:
ssl._create_default_https_context = ssl._create_unverified_context
else:
pass
siteTitle = "TVADDONS.CO"
AddonTitle = kodi.AddonTitle
addon_id = kodi.addon_id
addon = (addon_id, sys.argv)
settings = xbmcaddon.Addon(id=addon_id)
ADDON = xbmcaddon.Addon(id=addon_id)
artPath = xbmc.translatePath(os.path.join('special://home', 'addons', addon_id, 'resources', 'art2/'))
artwork = xbmc.translatePath(os.path.join('special://home', 'addons', addon_id, 'art2/'))
mainPath = xbmc.translatePath(os.path.join('special://home', 'addons', addon_id))
fanart = xbmc.translatePath(os.path.join(mainPath, 'fanart.jpg'))
iconart = xbmc.translatePath(os.path.join(mainPath, 'icon.png'))
dp = xbmcgui.DialogProgress()
dialog = xbmcgui.Dialog()
# <<<<<<<<<Common Variables>>>>>>>>>>>>>>>
Keymaps_URL = base64.b64decode("aHR0cDovL2luZGlnby50dmFkZG9ucy4va2V5bWFwcy9jdXN0b21rZXlzLnR4dA==")
Keymaps_URL = 'http://indigo.tvaddons.co/keymaps/customkeys.txt'
KEYBOARD_FILE = xbmc.translatePath(os.path.join('special://home/userdata/keymaps/', 'keyboard.xml'))
openSub = "https://github.com/stsrfbim/facial-recog/raw/master/development/service.subtitles.opensubtitles_by_opensubtitles/service.subtitles.opensubtitles_by_opensubtitles-5.1.14.zip"
burst_url = "http://burst.surge.sh/release/script.quasar.burst-0.5.8.zip"
# tvpath = "https://oldgit.com/tvaresolvers/tva-common-repository/raw/master/zips/"
tvpath = "https://github.com/zqfaen/tva-common/raw/master/zips/"
krypton_url = "http://mirrors.kodi.tv/addons/krypton/"
api = aiapi
CMi = []
# ****************************************************************
def get_params():
param = [];
paramstring = sys.argv[2]
if len(paramstring) >= 2:
params = sys.argv[2];
cleanedparams = params.replace('?', '')
if (params[len(params) - 1] == '/'): params = params[0:len(params) - 2]
pairsofparams = cleanedparams.split('&');
param = {}
for i in range(len(pairsofparams)):
splitparams = {};
splitparams = pairsofparams[i].split('=')
if (len(splitparams)) == 2: param[splitparams[0]] = splitparams[1]
return param
params = get_params()
url = None
name = None
mode = None
year = None
imdb_id = None
# ****************************************************************
def MAININDEX():
kodi.addDir('GitHub Browser', '', 'github_main', artwork + 'github_browser.png',
description='Search for repositories hosted on GitHub.')
kodi.addDir('Search by: Addon/Author', '', 'searchaddon', artwork + 'search.png',
description="Search for addons by Name or Author")
if settings.getSetting('featured') == 'true':
kodi.addDir('Featured Addons', 'featured', 'addonlist', artwork + 'featured.png',
description="The most popular Kodi addons!")
# if settings.getSetting('livetv') == 'true':
# kodi.addDir('Live TV Addons', 'live', 'addonlist', artwork + 'livetv.png',
# description="The most popular live TV addons!")
# if settings.getSetting('sports') == 'true':
# kodi.addDir('Sports Addons', 'sports', 'addonlist', artwork + 'sports.png',
# description="The most popular sports addons!")
if settings.getSetting('video') == 'true':
kodi.addDir('Video Addons', 'video', 'addonlist', artwork + 'video.png',
description="Every video addon in existence!")
if settings.getSetting('audio') == 'true':
kodi.addDir('Audio Addons', 'audio', 'addonlist', artwork + 'audio.png',
description="Find addons to listen to music!")
if settings.getSetting('program') == 'true':
kodi.addDir('Program Addons', 'executable', 'addonlist', artwork + 'program.png',
description="Every program addon you can imagine!")
# if settings.getSetting('playlist') == 'true':
# kodi.addDir('Playlist Addons', 'playlists', 'addonlist', artwork + 'playlists.png',
# description="The most popular playlist addons!")
if settings.getSetting('services') == 'true':
kodi.addDir('Service Addons', 'service', 'addonlist', artwork + 'service.png')
if settings.getSetting('skincat') == 'true':
kodi.addDir('Kodi Skins', 'skins', 'addonlist', artwork + 'kodi_skins.png',
description="Change up your look!")
if settings.getSetting('world') == 'true':
kodi.addDir('International Addons', 'international', 'interlist', artwork + 'world.png',
description="Foreign language addons and repos from across the globe!")
if settings.getSetting('adult') == 'true':
kodi.addDir('Adult Addons', 'xxx', 'adultlist', artwork + 'adult.png',
description="Must be 18 years or older! This menu can be disabled from within Add-on Settings.")
# if settings.getSetting('repositories') == 'true':
# kodi.addDir('Repositories','repositories', 'addonlist', artwork + 'repositories.png',
# description="Browse addons by repository!")
# kodi.addItem('Enable Live Streaming', 'None', 'EnableRTMP', artwork + 'enablertmp.png',
# description="Enable RTMP InputStream and InputStream Adaptive modules for Live Streaming.")
kodi.addItem('Official OpenSubtitles Addon', openSub, 'addopensub', artwork + 'opensubicon.png',
description="Install Official OpenSubtitles Addon!")
kodi.addDir('Install ZIP from Online Link', '', 'urlzip', artwork + 'onlinesource.png',
description='Manually download and install addons or repositories from the web.')
viewsetter.set_view("sets")
# ****************************************************************
def _get_keyboard(default="", heading="", hidden=False): # Start Ketboard Function
keyboard = xbmc.Keyboard(default, heading, hidden)
keyboard.doModal()
if (keyboard.isConfirmed()):
return unicode(keyboard.getText(), "utf-8")
return default
def SEARCHADDON(url): # Start Search Function
vq = _get_keyboard(heading="Search add-ons")
if (not vq):
return False, 0
title = urllib.quote_plus(vq)
Get_search_results(title)
def Get_search_results(title):
link = api.search_addons(title)
my_list = sorted(link, key=lambda k: k['name'].upper())
for e in link:
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
if e['extension_point'] != 'xbmc.addon.repository':
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
viewsetter.set_view("sets")
def github_main(url):
github_instructions()
kodi.addDir('Search by GitHub Username', 'username', 'github_search', artwork + 'search_by_username.png',
description="Search for addons by Username. Ex. tvaddonsco")
kodi.addDir('Search by GitHub Repository Title', 'repo', 'github_search', artwork + 'search_by_repository_title.png',
description="Search for addons by Repository Name")
kodi.addDir('Search GitHub by Addon ID', 'addon_id', 'github_search', artwork + 'searchaddonid.png',
description="Search for addons by AddonID. Ex. plugin.video.youtube (Advanced)")
#kodi.addItem('Update Addons', '', 'github_update', artwork + 'update_github.png',
# description="Update GitHub Addons")
viewsetter.set_view("sets")
def github_search(url):
q = _get_keyboard("", "Search GitHub")
if not q: return
import json
from libs.github_installer import github_api
if url == 'username':
rtype = 'api'
response = github_api.find_zips(q)
if response is None: return
for r in github_api.sort_results(response['items']):
if not r['path'].endswith(".zip"): continue
url = github_api.content_url % (r['repository']['full_name'], r['path'])
kodi.addItem(r['name'], json.dumps({"url": url, "user": q, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])}), 'github_install', '', description="")
#viewsetter.set_view("list")
return
elif url == 'repo':
rtype = 'api'
results = github_api.search(q, 'title')
if results is None: return
for i in results['items']:
user = i['owner']['login']
response = github_api.find_zips(user)
if response is None: continue
for r in github_api.sort_results(response['items']):
if not r['path'].endswith(".zip"): continue
url = github_api.content_url % (r['repository']['full_name'], r['path'])
kodi.addItem(r['name'], json.dumps({"url": url, "user": q, "file": r['name'], "full_name": "%s/%s" % (q, r['repository']['name'])}), 'github_install', '', description="")
#viewsetter.set_view("list")
return
elif url == 'addon_id':
rtype = 'web'
results = github_api.web_search(q)
else:
rtype = 'api'
results = github_api.search(q)
if results is None: return
for r in results['items']:
if rtype == 'api':
kodi.addDir(r['name'], json.dumps({"user": r['owner']['login'], "repo": r['name'], "rtype": rtype}), 'github_results', '', description="")
else:
kodi.addItem("%s/%s" % (r['owner']['login'], r['name']), json.dumps({"user": r['owner']['login'], "repo": r['name'], "rtype": rtype}), 'github_results', '', description="")
#viewsetter.set_view("list")
def github_results(url):
import json
from libs import github_installer
from libs.github_installer import github_api
from libs.github_installer import kodi as _kodi
args = json.loads(url)
#viewsetter.set_view("list")
if args['rtype'] == 'web':
from libs.github_installer import kodi as _kodi
full_name = "%s/%s" % (args['user'], args['repo'])
c = _kodi.dialog_confirm("Confirm Install", full_name, yes="Install", no="Cancel")
if not c: return
url = "https://github.com/%s/%s/archive/master.zip" % (args['user'], args['repo'])
Ins = github_installer.GitHub_Installer(args['repo'], url, full_name, _kodi.vfs.join("special://home", "addons"), True)
return
results = github_api.find_zips(args['user'], args['repo'])
if results is None: return
for r in results['items']:
if r['repository']['name'] != args['repo']: continue
url = github_api.content_url % (r['repository']['full_name'], r['path'])
kodi.addItem(r['name'], json.dumps({'file': r['name'], "url": url, "full_name": r['repository']['full_name']}), 'github_install', '', description="")
#viewsetter.set_view("list")
def github_install(url):
import re
import json
from libs.github_installer import kodi as _kodi
from libs import github_installer
from libs.github_installer import github_api
args = json.loads(url)
if 'file' in args:
#viewsetter.set_view("list")
c = _kodi.dialog_confirm("Confirm Install", args['file'])
if not c: return
addon_id = re.sub("-[\d\.]+zip$", "", args['file'])
github_installer.GitHub_Installer(addon_id, args['url'], args['full_name'], _kodi.vfs.join("special://home", "addons"))
if not dialog.yesno(siteTitle, ' Click Continue to install more addons or',
' Restart button to finalize addon installation',
" Brought To You By %s " % siteTitle,
nolabel='Restart', yeslabel='Continue'):
xbmc.executebuiltin('ShutDown')
#viewsetter.set_view("list")
else:
pass
def github_instructions():
from libs.github_installer import kodi as _kodi
try:
KODI_LANGUAGE = xbmc.getLanguage()
except:
KODI_LANGUAGE = 'English'
path = _kodi.vfs.join(_kodi.get_path(), 'resources/language/%s/github_help.txt', KODI_LANGUAGE)
if not _kodi.vfs.exists(path):
path = _kodi.vfs.join(_kodi.get_path(), 'resources/language/English/github_help.txt')
text = _kodi.vfs.read_file(path)
_kodi.dialog_textbox('GitHub Browser Instructions', text)
def github_update():
from libs import github_installer
from libs.github_installer import kodi as _kodi
c = _kodi.dialog_confirm("Confirm Update", "Search for updates?")
if c : github_installer.update_addons()
# ********************************************************************
def INTERNATIONAL():
kodi.addDir('International Repos', '', 'interrepos',
'https://www.tvaddons.co/kodi-addons/images/categories/international.png',
description="Foreign language repos from across the globe!")
kodi.addDir('International Addonss', '', 'interaddons',
'https://www.tvaddons.co/kodi-addons/images/categories/international.png',
description="Foreign language addons from across the globe!")
def INTERNATIONAL_REPOS():
link = api.get_all_addons()
for e in link:
if e['repository_type'] == 'international' and e['extension_point'] == 'xbmc.addon.repository':
# if e['extension_Point'] == 'xbmc.addon.repository':
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
def INTERNATIONAL_ADDONS():
imurl = 'https://www.tvaddons.co/kodi-addons/images/categories/international/'
link = api.get_langs()
if link:
# for e in link:
# name=e['languages']
# kodi.log(name)
l_vert = {"af": "African",
"ar": "Arabic",
# "cn": "Chinese",
"zh": "Chinese",
"cs": "Czech",
"da": "Danish",
"nl": "Dutch",
"ph": "Filipino",
"fi": "Finnish",
"fr": "French",
"de": "German",
"el": "Greek",
# "iw": "Hebrew",
"he": "Hebrew",
"hu": "Hungarian",
"is": "Icelandic",
"hi": "Indian",
"ga": "Irish",
"it": "Italian",
"ja": "Japanese",
"ko": "Korean",
"mn": "Mongolian",
"ne": "Nepali",
"no": "Norwegian",
"ur": "Pakistani",
"pl": "Polish",
"pt": "Portuguese",
"ro": "Romanian",
"ru": "Russian",
"ms": "Singapore",
"es": "Spanish",
"sv": "Swedish",
"ta": "Tamil",
"th": "Thai",
"tr": "Turkish",
"vi": "Vietnamese"}
# for key in l_vert:
# if e['languages'] == key:
# full_name = l_vert[key]
# name = e['languages']
# try:
# kodi.addDir(full_name, name, 'interaddonslist', imurl + full_name.lower() + '.png',
# description="Foreign language addons from across the globe!")
# except:
# pass
# viewsetter.set_view("sets")
for key in sorted(l_vert.items(), key=lambda key: key[1]):
try:
kodi.addDir(key[1], key[0], 'interaddonslist', imurl + key[1].lower() + '.png',
description="Foreign language addons from across the globe!")
except:
pass
viewsetter.set_view("sets")
def INTERNATIONAL_ADDONS_LIST(url):
link = api.get_all_addons()
my_list = sorted(link, key=lambda k: k['name'])
for e in my_list:
if url in e['languages']:
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
def List_Addons(url):
specials = ('featured', 'live', 'sports', 'playlists')
regulars = ('video', 'executable')
easyreg = ('audio', 'image', 'service', 'skins')
if url in specials:
query = url
link = api.get_all_addons()
feat = api.special_addons(query)
my_list = sorted(link, key=lambda k: k['name'])
for e in my_list:
if e['id'] in feat:
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
if url in easyreg:
link = api.get_types(url)
my_list = sorted(link, key=lambda k: k['name'])
for e in my_list:
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
# Split into ABC Menus
if url in regulars:
d = dict.fromkeys(string.ascii_uppercase, 0)
my_list = sorted(d)
for e in my_list:
kodi.addDir(e, url, 'splitlist', artwork + e + '.png', description="Starts with letter " + e)
kodi.addDir('Others', url, 'splitlist', artwork + 'symbols.png', description="Starts with another character")
if url == 'repositories':
link = api.get_repos()
for e in link:
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', 'None', '', '', CMi,
contextreplace=False)
except:
pass
if url == 'skins':
link = api.get_all_addons()
my_list = sorted(link, key=lambda k: k['name'])
for e in my_list:
if e['extension_point'] == 'xbmc.gui.skin':
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', 'None', '', '', CMi,
contextreplace=False)
except:
pass
viewsetter.set_view("sets")
def Split_List(name, url):
regulars = ('video', 'audio', 'image', 'service', 'executable', 'skins')
letter = name
if url in regulars:
link = api.get_types(url)
my_list = sorted(link, key=lambda k: k['name'])
for e in my_list:
name = e['name']
repourl = e['repodlpath']
path = e['addon_zip_path']
description = e['description']
icon = path.rsplit('/', 1)[0] + '/icon.png'
fanart = path.rsplit('/', 1)[0] + '/fanart.jpg'
if letter == "Others":
ALPHA = string.ascii_letters
if name.startswith(tuple(ALPHA)) == False:
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
else:
if name.lower().startswith(letter) or name.upper().startswith(letter):
try:
addHELPDir(name, path, 'addoninstall', icon, fanart, description, 'addon', repourl, '', '', CMi,
contextreplace=False)
except:
pass
###<<<<<<<<<<<<<<ADULT SECTIONS>>>>>>>>>>>>>>>>>>>>>
def List_Adult(url):
if settings.getSetting('adult') == 'true':
confirm = xbmcgui.Dialog().yesno("Please Confirm",
" Please confirm that you are at least 18 years of age.",
" ", " ", "NO (EXIT)",
"YES (ENTER)")
if confirm:
url = 'https://indigo.tvaddons.co/installer/sources/xxx.php'
link = OPEN_URL(url).replace('\r', '').replace('\n', '').replace('\t', '');
match = re.compile(
"'name' => '(.+?)'.+?dataUrl' => '(.+?)'.+?xmlUrl' => '(.+?)'.+?downloadUrl' => '(.+?)'").findall(link)
for name, dataurl, url, repourl in match:
lang = 'Adults Only'
add2HELPDir(name + ' (' + lang + ')', url, 'getaddoninfo', '', fanart, dataurl, repourl)
if len(match) == 0:
return
else:
kodi.set_setting('adult', 'false')
return
viewsetter.set_view("sets")
def getaddoninfo(url, dataurl, repourl):
lang = 'Adults Only'
link = OPEN_URL(url).replace('\r', '').replace('\n', '').replace('\t', '')
match = re.compile('<addon id="(.+?)".+?ame="(.+?)".+?ersion="(.+?)"').findall(link)
for adid, name, version in match:
dload = dataurl + adid + "/" + adid + "-" + version + ".zip"
addHELPDir(name + ' (' + lang + ')', dload, 'addoninstall', '', fanart, '', 'addon', repourl, '', '')
viewsetter.set_view("sets")
# ****************************************************************
def OPEN_URL(url):
req = urllib2.Request(url)
req.add_header('User-Agent',
'Mozilla/5.0 (Linux; U; Android 4.2.2; en-us; AFTB Build/JDQ39) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30')
response = urllib2.urlopen(req)
link = response.read()
response.close()
return link
def EnableRTMP():
try:
addon_able.set_enabled("inputstream.adaptive")
except:
pass
time.sleep(0.5)
try:
addon_able.set_enabled("inputstream.rtmp")
except:
pass
time.sleep(0.5)
xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
dialog.ok("Operation Complete!", "Live Streaming has been Enabled!",
" Brought To You By %s " % siteTitle)
# ****************************************************************
def HUBINSTALL(name, url, script):
aList = []
script_url = url
link = OPEN_URL(script_url)
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
aList.sort(cmp=ver_cmp, reverse=True)
newest_v = script + '-' + aList[0]
newest_v_url = script_url + script + '-' + aList[0] + '.zip'
kodi.log("Looking for : " + newest_v_url)
path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))
dp = xbmcgui.DialogProgress()
dp.create("Starting up", "Initializing ", '', 'Please Stand By....')
# lib = os.path.join(path, name + '.zip')
lib = os.path.join(path, newest_v + '.zip')
addonfolder = xbmc.translatePath(os.path.join('special://', 'home', 'addons'))
if os.path.exists(lib):
os.remove(lib)
downloader.download(newest_v_url, lib, dp, timeout=120)
try:
# xbmc.executebuiltin("InstallAddon(%s)" % newest_v)
extract.all(lib, addonfolder, '')
time.sleep(2)
except IOError, (errno, strerror):
kodi.message("Failed to open required files", "Error code is:", strerror)
return False
# ****************************************************************
def OPENSUBINSTALL(url):
path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))
dp = xbmcgui.DialogProgress();
dp.create("Please Wait", " ", '', 'Installing Official OpenSubtitles Addon')
lib = os.path.join(path, 'opensubtitlesOfficial.zip')
try:
os.remove(lib)
except:
pass
downloader.download(url, lib, dp, timeout=120)
addonfolder = xbmc.translatePath(os.path.join('special://', 'home', 'addons'))
time.sleep(2)
try:
extract.all(lib, addonfolder, '')
except IOError, (errno, strerror):
kodi.message("Failed to open required files", "Error code is:", strerror)
return False
xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
addon_able.set_enabled("service.subtitles.opensubtitles_by_opensubtitles")
dialog.ok("Installation Complete!", " We hope you enjoy your Kodi addon experience!",
" Brought To You By %s " % siteTitle)
# #################################################################
# #****************************************************************
def set_content(content):
xbmcplugin.setContent(int(sys.argv[1]), content)
# HELPDIR**************************************************************
def addDir(name, url, mode, thumb):
u = sys.argv[0] + "?url=" + urllib.quote_plus(url) + "&mode=" + str(mode) + "&name=" + urllib.quote_plus(name);
ok = True;
liz = xbmcgui.ListItem(name, iconImage=iconart, thumbnailImage=thumb);
# liz.setInfo(type="Video",infoLabels={"title":name,"Plot":description})
try:
liz.setProperty("fanart_image", fanart)
except:
pass
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True);
return ok
def addHELPDir(name, url, mode, iconimage, fanart, description, filetype, repourl, version, author, contextmenuitems=[],
contextreplace=False):
u = sys.argv[0] + "?url=" + urllib.quote_plus(url) + "&mode=" + str(mode) + "&name=" + urllib.quote_plus(
name) + "&iconimage=" + urllib.quote_plus(iconimage) + "&fanart=" + urllib.quote_plus(
fanart) + "&description=" + urllib.quote_plus(description) + "&filetype=" + urllib.quote_plus(
filetype) + "&repourl=" + urllib.quote_plus(repourl) + "&author=" + urllib.quote_plus(
author) + "&version=" + urllib.quote_plus(version)
ok = True
liz = xbmcgui.ListItem(name, iconImage=iconart, thumbnailImage=iconimage) # "DefaultFolder.png"
# if len(contextmenuitems) > 0:
liz.addContextMenuItems(contextmenuitems, replaceItems=contextreplace)
liz.setInfo(type="Video", infoLabels={"title": name, "plot": description})
liz.setProperty("fanart_image", fanart)
liz.setProperty("Addon.Description", description)
liz.setProperty("Addon.Creator", author)
liz.setProperty("Addon.Version", version)
# properties={'Addon.Description':meta["plot"]}
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=False)
return ok
def add2HELPDir(name, url, mode, iconimage, fanart, description, filetype, contextmenuitems=[], contextreplace=False):
u = sys.argv[0] + "?url=" + urllib.quote_plus(url) + "&mode=" + str(mode) + "&name=" + urllib.quote_plus(
name) + "&iconimage=" + urllib.quote_plus(iconimage) + "&fanart=" + urllib.quote_plus(
fanart) + "&description=" + urllib.quote_plus(description) + "&filetype=" + urllib.quote_plus(filetype)
ok = True;
liz = xbmcgui.ListItem(name, iconImage=iconart, thumbnailImage=iconimage)
# if len(contextmenuitems) > 0:
liz.addContextMenuItems(contextmenuitems, replaceItems=contextreplace)
liz.setInfo(type="Video", infoLabels={"title": name, "Plot": description})
liz.setProperty("fanart_image", fanart)
ok = xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]), url=u, listitem=liz, isFolder=True)
return ok
###################### KEYMAP INSTALLER ####################
def keymaps():
try:
link = OPEN_URL(Keymaps_URL).replace('\n', '').replace('\r', '')
except:
kodi.addDir("No Keymaps Available", '', '', artwork + 'unkeymap.png')
kodi.log('Could not open keymaps URL')
return
match = re.compile('name="(.+?)".+?rl="(.+?)".+?mg="(.+?)".+?anart="(.+?)".+?ersion="(.+?)".+?ash="(.+?)"').findall(
link)
if os.path.isfile(KEYBOARD_FILE):
kodi.addDir("Remove Current Keymap Configuration", '', 'uninstall_keymap', artwork + 'unkeymap.png')
for name, url, iconimage, fanart, version, description in match:
kodi.addDir(name, url, 'install_keymap', artwork + 'keymapadd.png')
name = "[COLOR white][B]" + name + "[/B][/COLOR]"
viewsetter.set_view("files")
def install_keymap(name, url):
if os.path.isfile(KEYBOARD_FILE):
try:
os.remove(KEYBOARD_FILE)
except:
pass
# Check is the packages folder exists, if not create it.
path = xbmc.translatePath(os.path.join('special://home/addons', 'packages'))
if not os.path.exists(path):
os.makedirs(path)
path_key = xbmc.translatePath(os.path.join('special://home/userdata', 'keymaps'))
if not os.path.exists(path_key):
os.makedirs(path_key)
buildname = name
dp = xbmcgui.DialogProgress()
dp.create("Keymap Installer", "", "", "[B]Keymap: [/B]" + buildname)
buildname = "customkeymap"
lib = os.path.join(path, buildname + '.zip')
try:
os.remove(lib)
except:
pass
downloader.download(url, lib, dp, timeout=120)
addonfolder = xbmc.translatePath(os.path.join('special://', 'home'))
time.sleep(2)
dp.update(0, "", "Installing Please wait..", "")
try:
extract.all(lib, addonfolder, dp)
except IOError, (errno, strerror):
kodi.message("Failed to open required files", "Error code is:", strerror)
return False
time.sleep(1)
try:
os.remove(lib)
except:
pass
xbmc.executebuiltin("Container.Refresh")
dialog.ok("Custom Keymap Installed!", " We hope you enjoy your Kodi addon experience!",
" Brought To You By %s " % siteTitle)
def uninstall_keymap():
try:
os.remove(KEYBOARD_FILE)
except:
pass
dialog.ok(AddonTitle, "[B][COLOR white]Success, we have removed the keyboards.xml file.[/COLOR][/B]",
'[COLOR white]Thank you for using %s[/COLOR]' % AddonTitle)
# xbmc.executebuiltin("Container.Refresh")
def libinstaller(name, url):
if "Android" in name:
if not xbmc.getCondVisibility('system.platform.android'):
dialog.ok(AddonTitle + " - Android",
"[B][COLOR white]Sorry, this file is only for Android devices[/COLOR][/B]", '')
sys.exit(1)
else:
name = "librtmp.so"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
if "Windows" in name:
if not xbmc.getCondVisibility('system.platform.windows'):
dialog.ok(AddonTitle + " -Windows",
"[B][COLOR white]Sorry, this file is only for Windows devices[/COLOR][/B]", '')
return
else:
name = "librtmp.dll"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
if "Linux" in name:
if not xbmc.getCondVisibility('system.platform.linux'):
dialog.ok(AddonTitle + " - Linux", "[B][COLOR white]Sorry, this file is only for Linux devices[/COLOR][/B]",
'')
return
else:
name = "librtmp.so.1"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
if "OSX" in name:
if not xbmc.getCondVisibility('system.platform.osx'):
dialog.ok(AddonTitle + " - MacOSX",
"[B][COLOR white]Sorry, this file is only for MacOSX devices[/COLOR][/B]", '')
return
else:
name = "librtmp.1.dylib"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
if "TV" in name:
if not xbmc.getCondVisibility('system.platform.atv2'):
dialog.ok(AddonTitle + " - ATV", "[B][COLOR white]Sorry, this file is only for ATV devices[/COLOR][/B]", '')
return
else:
name = "librtmp.1.dylib"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
if "iOS" in name:
if not xbmc.getCondVisibility('system.platform.ios'):
dialog.ok(AddonTitle + " - iOS", "[B][COLOR white]Sorry, this file is only for iOS devices[/COLOR][/B]", '')
return
else:
name = "librtmp.1.dylib"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
if "RPi" in name:
if not xbmc.getCondVisibility('system.platform.rpi'):
dialog.ok(AddonTitle + " - RPi", "[B][COLOR white]Sorry, this file is only for RPi devices[/COLOR][/B]", '')
return
else:
name = "librtmp.1.so"
path = xbmc.translatePath(os.path.join('special://home', ''))
make_lib(path, name)
def make_lib(path, name):
addon_title = AddonTitle + " Installer"
dp = xbmcgui.DialogProgress()
dp.create(addon_title, "", "", "")
lib = os.path.join(path, name)
try:
os.remove(lib)
except:
pass
downloader.download(url, lib, dp)
dialog.ok(addon_title, "[COLOR gold]Download complete, File can be found at: [/COLOR][COLOR blue]" + lib + "[/COLOR]")
##############
def ver_cmp(x, y):
for i, j in izip_longest(*[x.split('.'), y.split('.')], fillvalue=0):
if int(i) < int(j):
return -1
elif int(i) > int(j):
return 1
return 0
# New Dependency Routine #####################
def NEW_Depend(dataurl, script):
kodi.log("SCRIPT LOOKED FOR IS : " + script)
if "github" in dataurl:
kodi.log("Is Github Repo")
GITHUBGET(script, dataurl)
else:
kodi.log("Is Private Repo")
try:
aList = []
link = OPEN_URL(tvpath)
if script in link:
script_url = tvpath + script + '/'
link = OPEN_URL(script_url)
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
aList.sort(cmp=ver_cmp, reverse=True)
orglist = script_url + script + '-' + aList[0] + '.zip'
kodi.log(' DOWNLOADING TVA FILE to ' + script + '.zip')
DEPENDINSTALL(script, orglist)
else:
link = OPEN_URL(krypton_url)
if script in link:
script_url = krypton_url + script + '/'
link = OPEN_URL(script_url)
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
aList.sort(cmp=ver_cmp, reverse=True)
orglist = script_url + script + '-' + aList[0] + '.zip'
kodi.log(' DOWNLOADING ORG FILE to ' + script + '.zip')
DEPENDINSTALL(script, orglist)
else:
try:
script_urls = dataurl + script + '/'
link = OPEN_URL(script_urls)
if not link:
script_url = script_urls.replace("raw.", "").replace("/master/", "/tree/master/")
link = OPEN_URL(script_url)
if "Invalid request" in link:
kodi.log("DEAD REPO LOCATION = " + dataurl)
else:
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
aList.sort(cmp=ver_cmp, reverse=True)
orglist = dataurl + script + '/' + script + '-' + aList[0] + '.zip'
kodi.log(' DOWNLOADING NATIVE to ' + script + '.zip')
DEPENDINSTALL(script, orglist)
except:
kodi.log("No local depend found = " + script + " Unfound URL is " + orglist)
except:
kodi.log("FAILED TO GET DEPENDS")
def GITHUBGET(script, dataurl):
try:
fix_urls = dataurl + script + '/'
fixed_url = fix_urls.replace("raw/", "").replace("/master/", "/blob/master/").replace("githubusercontent", "github")
aList = []
link = OPEN_URL(tvpath)
if script in link:
script_url = tvpath + script + '/'
link = OPEN_URL(script_url)
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
aList.sort(cmp=ver_cmp, reverse=True)
orglist = script_url + script + '-' + aList[0] + '.zip'
kodi.log(' DOWNLOADING TVA FILE to ' + script + '.zip')
DEPENDINSTALL(script, orglist)
else:
link = OPEN_URL(krypton_url)
if script in link:
script_url = krypton_url + script + '/'
link = OPEN_URL(script_url)
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
aList.sort(cmp=ver_cmp, reverse=True)
orglist = script_url + script + '-' + aList[0] + '.zip'
kodi.log(' DOWNLOADING ORG FILE to ' + script + '.zip')
# kodi.log('From: '+orglist)
DEPENDINSTALL(script, orglist)
else:
try:
link = OPEN_URL(fixed_url)
if link:
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
# aList.sort(cmp=ver_cmp, reverse=True)
aList.sort(reverse=True)
orglist = dataurl + script + '/' + script + '-' + aList[0] + '.zip'
# kodi.log(' DOWNLOADING to ' + script + '.zip')
DEPENDINSTALL(script, orglist)
kodi.log("TRYING NATIVE LOCATION")
if "Invalid request" in link:
kodi.log("DEAD REPO LOCATION = " + dataurl)
else:
matcher = script + '-(.+?).zip'
match = re.compile(matcher).findall(link)
for version in match:
aList.append(version)
# aList.sort(cmp=ver_cmp, reverse=True)
aList.sort(reverse=True)
orglist = dataurl + script + '/' + script + '-' + aList[0] + '.zip'
kodi.log(' DOWNLOADING NATIVE to ' + script + '.zip')
DEPENDINSTALL(script, orglist)
except:
kodi.log("Could not find required files ")
except:
kodi.log("Failed to find required files")
def DEPENDINSTALL(name, url):
path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))
lib = os.path.join(path, name + '.zip')
addonfolder = xbmc.translatePath(os.path.join('special://', 'home', 'addons'))
try:
os.remove(lib)
except:
pass
download(url, lib, addonfolder, name)
addon_able.set_enabled(name)
xbmc.executebuiltin("XBMC.UpdateLocalAddons()")
#################################################################
def ADDONINSTALL(name, url, description, filetype, repourl, Auto=False, v='', vO=''):
try:
name = name.split('[COLOR FF0077D7]Install [/COLOR][COLOR FFFFFFFF]')[1].split('[/COLOR][COLOR FF0077D7] (v')[0]
except:
pass
kodi.log("Installer: Installing: " + name)
newfile = '-'.join(url.split('/')[-1].split('-')[:-1])
addonname = str(newfile).replace('[', '').replace(']', '').replace('"', '').replace('[', '').replace("'", '')
path = xbmc.translatePath(os.path.join('special://home', 'addons', 'packages'))