/
default.py
executable file
·579 lines (473 loc) · 23.7 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
import xbmc, xbmcaddon, xbmcgui, xbmcplugin,os,base64,sys,xbmcvfs
import shutil
import urllib2,urllib
import re
import extract
import downloader
import time
import plugintools
from addon.common.addon import Addon
from addon.common.net import Net
###THANK YOU TO THE PEOPLE THAT ORIGINALY WROTE SOME OF THIS CODE WITHOUT YOU I STILL PROBABLY WOULDNT HAVE A CLUE WHERE TO START###
USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
addon_id = 'plugin.program.miwizard-master'
ADDON = xbmcaddon.Addon(id=addon_id)
AddonID='plugin.program.miwizard-master'
AddonTitle="mikodi.uk"
dialog = xbmcgui.Dialog()
net = Net()
U = ADDON.getSetting('User')
FANART = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id , 'fanart.jpg'))
ICON = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id, 'icon.png'))
ART = xbmc.translatePath(os.path.join('special://home/addons/' + addon_id + '/resources/art/'))
VERSION = "0.0.1"
DBPATH = xbmc.translatePath('special://database')
TNPATH = xbmc.translatePath('special://thumbnails');
PATH = "mikodi.uk"
BASEURL = "https://www.dropbox.com"
H = 'http://'
EXCLUDES = ['plugin.program.miwizard-master','script.module.addon.common']
def INDEX():
addDir('Update',BASEURL,2,ART+'downloads.png',FANART,'')
#addDir('MAINTENANCE',BASEURL,3,ART+'maintenance.png',FANART,'')
setView('movies', 'MAIN')
def BUILDMENU():
addDir('UPDATE',BASEURL+'/s/2y4mghkd05ac9an/14.04.zip?dl=1',5,ART+'downloads.png',FANART,'')
setView('movies', 'MAIN')
#def MAINTENANCE():
# addDir('DELETE CACHE','url',4,ART+'deletecache.png',FANART,'')
# addDir('FRESH START','url',6,ART+'freshstart.png',FANART,'')
# addDir('DELETE PACKAGES','url',7,ART+'deletepackages.png',FANART,'')
# setView('movies', 'MAIN')
#################################
####### POPUP TEXT BOXES ########
#################################
def TextBoxes(heading,announce):
class TextBox():
WINDOW=10147
CONTROL_LABEL=1
CONTROL_TEXTBOX=5
def __init__(self,*args,**kwargs):
xbmc.executebuiltin("ActivateWindow(%d)" % (self.WINDOW, )) # activate the text viewer window
self.win=xbmcgui.Window(self.WINDOW) # get window
xbmc.sleep(500) # give window time to initialize
self.setControls()
def setControls(self):
self.win.getControl(self.CONTROL_LABEL).setLabel(heading) # set heading
try: f=open(announce); text=f.read()
except: text=announce
self.win.getControl(self.CONTROL_TEXTBOX).setText(str(text))
return
TextBox()
#################################
####BUILD INSTALL################
#################################
def WIZARD(name,url,description):
path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
dp = xbmcgui.DialogProgress()
dp.create("mikodi.uk","Downloading Your Build ",'', 'Please Wait')
lib=os.path.join(path, name+'.zip')
try:
os.remove(lib)
except:
pass
downloader.download(url, lib, dp)
addonfolder = xbmc.translatePath(os.path.join('special://','home'))
time.sleep(2)
dp.update(0, "Installing Build. Please Wait")
print '======================================='
print addonfolder
print '======================================='
extract.all(lib,addonfolder,dp)
dialog = xbmcgui.Dialog()
dialog.ok("www.mikodi.uk", "To save changes you now need to force close Kodi, Press OK to force close Kodi")
killxbmc()
################################
###DELETE PACKAGES##############
####THANKS GUYS @ XUNITY########
def DeletePackages(url):
print '############################################################ DELETING PACKAGES ###############################################################'
packages_cache_path = xbmc.translatePath(os.path.join('special://home/addons/packages', ''))
try:
for root, dirs, files in os.walk(packages_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete Package Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
dialog = xbmcgui.Dialog()
dialog.ok("www.mikodi.uk", "Packages Successfuly Removed", "[COLOR steelblue]Brought To You By LLovell[/COLOR]")
except:
dialog = xbmcgui.Dialog()
dialog.ok("www.mikodi.uk", "Sorry we were not able to remove Package Files", "[COLOR steelblue]Brought To You By LLovell[/COLOR]")
#################################
###DELETE CACHE##################
####THANKS GUYS @ XUNITY########
def deletecachefiles(url):
print '############################################################ DELETING STANDARD CACHE ###############################################################'
xbmc_cache_path = os.path.join(xbmc.translatePath('special://home'), 'cache')
if os.path.exists(xbmc_cache_path)==True:
for root, dirs, files in os.walk(xbmc_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
try:
os.unlink(os.path.join(root, f))
except:
pass
for d in dirs:
try:
shutil.rmtree(os.path.join(root, d))
except:
pass
else:
pass
if xbmc.getCondVisibility('system.platform.ATV2'):
atv2_cache_a = os.path.join('/private/var/mobile/Library/Caches/AppleTV/Video/', 'Other')
for root, dirs, files in os.walk(atv2_cache_a):
file_count = 0
file_count += len(files)
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete ATV2 Cache Files", str(file_count) + " files found in 'Other'", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
atv2_cache_b = os.path.join('/private/var/mobile/Library/Caches/AppleTV/Video/', 'LocalAndRental')
for root, dirs, files in os.walk(atv2_cache_b):
file_count = 0
file_count += len(files)
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete ATV2 Cache Files", str(file_count) + " files found in 'LocalAndRental'", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
# Set path to Cydia Archives cache files
# Set path to What th Furk cache files
wtf_cache_path = os.path.join(xbmc.translatePath('special://profile/addon_data/plugin.video.whatthefurk/cache'), '')
if os.path.exists(wtf_cache_path)==True:
for root, dirs, files in os.walk(wtf_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete WTF Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
# Set path to 4oD cache files
channel4_cache_path= os.path.join(xbmc.translatePath('special://profile/addon_data/plugin.video.4od/cache'), '')
if os.path.exists(channel4_cache_path)==True:
for root, dirs, files in os.walk(channel4_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete 4oD Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
# Set path to BBC iPlayer cache files
iplayer_cache_path= os.path.join(xbmc.translatePath('special://profile/addon_data/plugin.video.iplayer/iplayer_http_cache'), '')
if os.path.exists(iplayer_cache_path)==True:
for root, dirs, files in os.walk(iplayer_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete BBC iPlayer Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
# Set path to Simple Downloader cache files
downloader_cache_path = os.path.join(xbmc.translatePath('special://profile/addon_data/script.module.simple.downloader'), '')
if os.path.exists(downloader_cache_path)==True:
for root, dirs, files in os.walk(downloader_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete Simple Downloader Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
# Set path to ITV cache files
itv_cache_path = os.path.join(xbmc.translatePath('special://profile/addon_data/plugin.video.itv/Images'), '')
if os.path.exists(itv_cache_path)==True:
for root, dirs, files in os.walk(itv_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete ITV Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
# Set path to temp cache files
temp_cache_path = os.path.join(xbmc.translatePath('special://home/temp'), '')
if os.path.exists(temp_cache_path)==True:
for root, dirs, files in os.walk(temp_cache_path):
file_count = 0
file_count += len(files)
# Count files and give option to delete
if file_count > 0:
dialog = xbmcgui.Dialog()
if dialog.yesno("Delete TEMP dir Cache Files", str(file_count) + " files found", "Do you want to delete them?"):
for f in files:
os.unlink(os.path.join(root, f))
for d in dirs:
shutil.rmtree(os.path.join(root, d))
else:
pass
dialog = xbmcgui.Dialog()
dialog.ok("ARB Updater", " All Cache Files Removed", "[COLOR steelblue]Brought To You By ARB[/COLOR]")
def OPEN_URL(url):
req = urllib2.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3')
response = urllib2.urlopen(req)
link=response.read()
response.close()
return link
###############################################################
###FORCE CLOSE KODI - ANDROID ONLY WORKS IF ROOTED#############
#######LEE @ COMMUNITY BUILDS##################################
def killxbmc():
choice = xbmcgui.Dialog().yesno('Force Close Kodi', 'You are about to close Kodi', 'Would you like to continue?', nolabel='No, Cancel',yeslabel='Yes, Close')
if choice == 0:
return
elif choice == 1:
pass
myplatform = platform()
print "Platform: " + str(myplatform)
if myplatform == 'osx': # OSX
print "############ try osx force close #################"
try: os.system('killall -9 XBMC')
except: pass
try: os.system('killall -9 Kodi')
except: pass
dialog.ok("[COLOR=red][B]WARNING !!![/COLOR][/B]", "If you\'re seeing this message it means the force close", "was unsuccessful. Please force close XBMC/Kodi [COLOR=lime]DO NOT[/COLOR] exit cleanly via the menu.",'')
elif myplatform == 'linux': #Linux
print "############ try linux force close #################"
try: os.system('killall XBMC')
except: pass
try: os.system('killall Kodi')
except: pass
try: os.system('killall -9 xbmc.bin')
except: pass
try: os.system('killall -9 kodi.bin')
except: pass
dialog.ok("[COLOR=red][B]WARNING !!![/COLOR][/B]", "If you\'re seeing this message it means the force close", "was unsuccessful. Please force close XBMC/Kodi [COLOR=lime]DO NOT[/COLOR] exit cleanly via the menu.",'')
elif myplatform == 'android': # Android
print "############ try android force close #################"
try: os.system('adb shell am force-stop org.xbmc.kodi')
except: pass
try: os.system('adb shell am force-stop com.semperpax.spmc16')
except: pass
try: os.system('adb shell am force-stop org.kodi')
except: pass
try: os.system('adb shell am force-stop org.xbmc.xbmc')
except: pass
try: os.system('adb shell am force-stop org.xbmc')
except: pass
dialog.ok("[B]TO COMPLETE THE UPDATE[/B]", "Press the HOME button on your remote then on your Amazon FIRETV HOME SCREEN GOTO [B]: Settings/ Applications/ Manage Installed Applications/ [THE NAME OF YOUR PROGRAM] ie Kodi/ Force Close. Then re-launch [THE NAME OF YOUR PROGRAM] ie Kodi[/B]")
elif myplatform == 'windows': # Windows
print "############ try windows force close #################"
try:
os.system('@ECHO off')
os.system('tskill XBMC.exe')
except: pass
try:
os.system('@ECHO off')
os.system('tskill Kodi.exe')
except: pass
try:
os.system('@ECHO off')
os.system('TASKKILL /im Kodi.exe /f')
except: pass
try:
os.system('@ECHO off')
os.system('TASKKILL /im XBMC.exe /f')
except: pass
dialog.ok("[COLOR=red][B]WARNING !!![/COLOR][/B]", "If you\'re seeing this message it means the force close", "was unsuccessful. Please force close XBMC/Kodi [COLOR=lime]DO NOT[/COLOR] exit cleanly via the menu.","Use task manager and NOT ALT F4")
else: #ATV
print "############ try atv force close #################"
try: os.system('killall AppleTV')
except: pass
print "############ try raspbmc force close #################" #OSMC / Raspbmc
try: os.system('sudo initctl stop kodi')
except: pass
try: os.system('sudo initctl stop xbmc')
except: pass
dialog.ok("[COLOR=red][B]WARNING !!![/COLOR][/B]", "If you\'re seeing this message it means the force close", "was unsuccessful. Please force close XBMC/Kodi [COLOR=lime]DO NOT[/COLOR] exit via the menu.","iOS detected. Press and hold both the Sleep/Wake and Home button for at least 10 seconds, until you see the Apple logo.")
##########################
###DETERMINE PLATFORM#####
##########################
def platform():
if xbmc.getCondVisibility('system.platform.android'):
return 'android'
elif xbmc.getCondVisibility('system.platform.linux'):
return 'linux'
elif xbmc.getCondVisibility('system.platform.windows'):
return 'windows'
elif xbmc.getCondVisibility('system.platform.osx'):
return 'osx'
elif xbmc.getCondVisibility('system.platform.atv2'):
return 'atv2'
elif xbmc.getCondVisibility('system.platform.ios'):
return 'ios'
############################
###FRESH START##############
####THANKS TO TVADDONS######
def FRESHSTART(params):
plugintools.log("freshstart.main_list "+repr(params)); yes_pressed=plugintools.message_yes_no(AddonTitle,"Do you wish to restore your","Kodi configuration to default settings?")
if yes_pressed:
addonPath=xbmcaddon.Addon(id=AddonID).getAddonInfo('path'); addonPath=xbmc.translatePath(addonPath);
xbmcPath=os.path.join(addonPath,"..",".."); xbmcPath=os.path.abspath(xbmcPath); plugintools.log("freshstart.main_list xbmcPath="+xbmcPath); failed=False
try:
for root, dirs, files in os.walk(xbmcPath,topdown=True):
dirs[:] = [d for d in dirs if d not in EXCLUDES]
for name in files:
try: os.remove(os.path.join(root,name))
except:
if name not in ["Addons15.db","MyVideos75.db","Textures13.db","xbmc.log"]: failed=True
plugintools.log("Error removing "+root+" "+name)
for name in dirs:
try: os.rmdir(os.path.join(root,name))
except:
if name not in ["Database","userdata"]: failed=True
plugintools.log("Error removing "+root+" "+name)
if not failed: plugintools.log("freshstart.main_list All user files removed, you now have a clean install"); plugintools.message(AddonTitle,"The process is complete, you're now back to a fresh Kodi configuration with ARB Updater!","Please reboot your system or restart Kodi in order for the changes to be applied.")
else: plugintools.log("freshstart.main_list User files partially removed"); plugintools.message(AddonTitle,"The process is complete, you're now back to a fresh Kodi configuration with ARB Updater","Please reboot your system or restart Kodi in order for the changes to be applied.")
except: plugintools.message(AddonTitle,"Problem found","Your settings has not been changed"); import traceback; plugintools.log(traceback.format_exc()); plugintools.log("freshstart.main_list NOT removed")
plugintools.add_item(action="",title="Now Exit Kodi",folder=False)
else: plugintools.message(AddonTitle,"Your settings","has not been changed"); plugintools.add_item(action="",title="Done",folder=False)
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
N = base64.decodestring('')
T = base64.decodestring('L2FkZG9ucy50eHQ=')
B = base64.decodestring('')
F = base64.decodestring('')
def addDir(name,url,mode,iconimage,fanart,description):
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)
ok=True
liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
liz.setProperty( "Fanart_Image", fanart )
if mode==5 :
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
else:
ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=True)
return ok
params=get_params()
url=None
name=None
mode=None
iconimage=None
fanart=None
description=None
try:
url=urllib.unquote_plus(params["url"])
except:
pass
try:
name=urllib.unquote_plus(params["name"])
except:
pass
try:
iconimage=urllib.unquote_plus(params["iconimage"])
except:
pass
try:
mode=int(params["mode"])
except:
pass
try:
fanart=urllib.unquote_plus(params["fanart"])
except:
pass
try:
description=urllib.unquote_plus(params["description"])
except:
pass
print str(PATH)+': '+str(VERSION)
print "Mode: "+str(mode)
print "URL: "+str(url)
print "Name: "+str(name)
print "IconImage: "+str(iconimage)
def setView(content, viewType):
# set content type so library shows more views and info
if content:
xbmcplugin.setContent(int(sys.argv[1]), content)
if ADDON.getSetting('auto-view')=='true':
xbmc.executebuiltin("Container.SetViewMode(%s)" % ADDON.getSetting(viewType) )
if mode==None or url==None or len(url)<1:
INDEX()
elif mode==2:
BUILDMENU()
elif mode==3:
MAINTENANCE()
elif mode==4:
deletecachefiles(url)
elif mode==5:
WIZARD(name,url,description)
elif mode==6:
FRESHSTART(params)
elif mode==7:
DeletePackages(url)
elif mode==8:
facebook()
elif mode==9:
donation()
elif mode==11:
DELETEIVUEDB()
xbmcplugin.endOfDirectory(int(sys.argv[1]))