Advertisement
abeksis

dddd

Jan 26th, 2016
155
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.37 KB | None | 0 0
  1. import xbmc, xbmcaddon, xbmcgui, xbmcplugin,os,sys
  2. import shutil
  3. import urllib2,urllib
  4. import re
  5. import extract
  6. import time
  7. import downloader
  8. import plugintools
  9. import zipfile
  10. import ntpath
  11.  
  12.  
  13. USER_AGENT = 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.9.0.3) Gecko/2008092417 Firefox/3.0.3'
  14. base='http://www.abeksis.com'
  15. ADDON=xbmcaddon.Addon(id='plugin.video.AbeksisWizard')
  16. dialog = xbmcgui.Dialog()
  17. VERSION = "1.0.1"
  18. PATH = "Abeksis Wizard"
  19.  
  20.  
  21. def ShowBk(skin):
  22. link = OPEN_URL('http://abeksis.com/Wizard/wizard.txt').replace('\n','').replace('\r','')
  23. match = re.compile('name="(.+?)".+?rl="(.+?)".+?mg="(.+?)".+?anart="(.+?)".+?escription="(.+?)"').findall(link)
  24. for name,url,iconimage,fanart,description in match:
  25. if name.find(skin)>-1:
  26. addDir(name,url,1,iconimage,fanart,description)
  27. setView('movies', 'MAIN')
  28. return True
  29.  
  30.  
  31. def CATEGORIES():
  32. dialog = xbmcgui.Dialog()
  33. choice = dialog.select('Choose Skin', ['Abeksis Wizard For Kids','Abeksis Wizard +18'],0)
  34. skin='NNN'
  35. if choice == 0:
  36. skin='Abeksis Wizard For Kids'
  37. ShowBk(skin)
  38. elif choice == 1:
  39. skin='Abeksis Wizard +18'
  40. ShowBk(skin)
  41.  
  42.  
  43. def OPEN_URL(url):
  44. req = urllib2.Request(url)
  45. 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')
  46. response = urllib2.urlopen(req)
  47. link=response.read()
  48. response.close()
  49. return link
  50.  
  51.  
  52. def wizard(name,url,description):
  53. print "wizard"
  54. print name
  55. print os.path.join(path, name+'.zip')
  56. path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
  57. dp = xbmcgui.DialogProgress()
  58. dp.create("Abeksis Wizard","Downloading ",'', 'Please Wait')
  59. lib=os.path.join(path, name+'.zip')
  60. try:
  61. os.remove(lib)
  62. except:
  63. pass
  64. downloader.download(url, lib, dp)
  65. addonfolder = xbmc.translatePath(os.path.join('special://','home'))
  66. time.sleep(2)
  67. dp.update(0,"", "Extracting Zip Please Wait")
  68. print '======================================='
  69. print addonfolder
  70. print '======================================='
  71. extract.all(lib,addonfolder,dp)
  72. dialog = xbmcgui.Dialog()
  73. dialog.ok("DOWNLOAD COMPLETE", 'Unfortunately the only way to get the new changes to stick is', 'to force close kodi. Click ok to force Kodi to close,', 'DO NOT use the quit/exit options in Kodi., If the Force close does not close for some reason please Restart Device or kill task manaully')
  74. killxbmc()
  75.  
  76.  
  77.  
  78. def killxbmc():
  79. choice = xbmcgui.Dialog().yesno('Force Close Kodi', 'You are about to close Kodi', 'Would you like to continue?', nolabel='No, Cancel',yeslabel='Yes, Close')
  80. if choice == 0:
  81. return
  82. elif choice == 1:
  83. pass
  84. myplatform = platform()
  85. print "Platform: " + str(myplatform)
  86. if myplatform == 'osx': # OSX
  87. print "############ try osx force close #################"
  88. try: os.system('killall -9 XBMC')
  89. except: pass
  90. try: os.system('killall -9 Kodi')
  91. except: pass
  92. 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.",'')
  93. elif myplatform == 'linux': #Linux
  94. print "############ try linux force close #################"
  95. try: os.system('killall XBMC')
  96. except: pass
  97. try: os.system('killall Kodi')
  98. except: pass
  99. try: os.system('killall -9 xbmc.bin')
  100. except: pass
  101. try: os.system('killall -9 kodi.bin')
  102. except: pass
  103. 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.",'')
  104. elif myplatform == 'android': # Android
  105. print "############ try android force close #################"
  106. try: os.system('adb shell am force-stop org.xbmc.kodi')
  107. except: pass
  108. try: os.system('adb shell am force-stop org.kodi')
  109. except: pass
  110. try: os.system('adb shell am force-stop org.xbmc.xbmc')
  111. except: pass
  112. try: os.system('adb shell am force-stop org.xbmc')
  113. except: pass
  114. dialog.ok("[COLOR=red][B]WARNING !!![/COLOR][/B]", "Your system has been detected as Android, you ", "[COLOR=yellow][B]MUST[/COLOR][/B] force close XBMC/Kodi. [COLOR=lime]DO NOT[/COLOR] exit cleanly via the menu.","Either close using Task Manager (If unsure pull the plug).")
  115. elif myplatform == 'windows': # Windows
  116. print "############ try windows force close #################"
  117. try:
  118. os.system('@ECHO off')
  119. os.system('tskill XBMC.exe')
  120. except: pass
  121. try:
  122. os.system('@ECHO off')
  123. os.system('tskill Kodi.exe')
  124. except: pass
  125. try:
  126. os.system('@ECHO off')
  127. os.system('TASKKILL /im Kodi.exe /f')
  128. except: pass
  129. try:
  130. os.system('@ECHO off')
  131. os.system('TASKKILL /im XBMC.exe /f')
  132. except: pass
  133. 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")
  134. else: #ATV
  135. print "############ try atv force close #################"
  136. try: os.system('killall AppleTV')
  137. except: pass
  138. print "############ try raspbmc force close #################" #OSMC / Raspbmc
  139. try: os.system('sudo initctl stop kodi')
  140. except: pass
  141. try: os.system('sudo initctl stop xbmc')
  142. except: pass
  143. 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.","Your platform could not be detected so just pull the power cable.")
  144.  
  145. def platform():
  146. if xbmc.getCondVisibility('system.platform.android'):
  147. return 'android'
  148. elif xbmc.getCondVisibility('system.platform.linux'):
  149. return 'linux'
  150. elif xbmc.getCondVisibility('system.platform.windows'):
  151. return 'windows'
  152. elif xbmc.getCondVisibility('system.platform.osx'):
  153. return 'osx'
  154. elif xbmc.getCondVisibility('system.platform.atv2'):
  155. return 'atv2'
  156. elif xbmc.getCondVisibility('system.platform.ios'):
  157. return 'ios'
  158.  
  159.  
  160. def addDir(name,url,mode,iconimage,fanart,description):
  161. 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)
  162. ok=True
  163. liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
  164. liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
  165. liz.setProperty( "Fanart_Image", fanart )
  166. ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
  167. return ok
  168.  
  169.  
  170.  
  171. def get_params():
  172. param=[]
  173. paramstring=sys.argv[2]
  174. if len(paramstring)>=2:
  175. params=sys.argv[2]
  176. cleanedparams=params.replace('?','')
  177. if (params[len(params)-1]=='/'):
  178. params=params[0:len(params)-2]
  179. pairsofparams=cleanedparams.split('&')
  180. param={}
  181. for i in range(len(pairsofparams)):
  182. splitparams={}
  183. splitparams=pairsofparams[i].split('=')
  184. if (len(splitparams))==2:
  185. param[splitparams[0]]=splitparams[1]
  186.  
  187. return param
  188.  
  189.  
  190. params=get_params()
  191. url=None
  192. name=None
  193. mode=None
  194. iconimage=None
  195. fanart=None
  196. description=None
  197.  
  198.  
  199. try:
  200. url=urllib.unquote_plus(params["url"])
  201. except:
  202. pass
  203. try:
  204. name=urllib.unquote_plus(params["name"])
  205. except:
  206. pass
  207. try:
  208. iconimage=urllib.unquote_plus(params["iconimage"])
  209. except:
  210. pass
  211. try:
  212. mode=int(params["mode"])
  213. except:
  214. pass
  215. try:
  216. fanart=urllib.unquote_plus(params["fanart"])
  217. except:
  218. pass
  219. try:
  220. description=urllib.unquote_plus(params["description"])
  221. except:
  222. pass
  223.  
  224.  
  225. print str(PATH)+': '+str(VERSION)
  226. print "Mode: "+str(mode)
  227. print "URL: "+str(url)
  228. print "Name: "+str(name)
  229. print "IconImage: "+str(iconimage)
  230.  
  231.  
  232. def setView(content, viewType):
  233. # set content type so library shows more views and info
  234. if content:
  235. xbmcplugin.setContent(int(sys.argv[1]), content)
  236. if ADDON.getSetting('auto-view')=='true':
  237. xbmc.executebuiltin("Container.SetViewMode(%s)" % ADDON.getSetting(viewType) )
  238.  
  239.  
  240. if mode==None or url==None or len(url)<1:
  241. CATEGORIES()
  242.  
  243. elif mode==1:
  244. wizard(name,url,description)
  245.  
  246.  
  247.  
  248. xbmcplugin.endOfDirectory(int(sys.argv[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement