Advertisement
abeksis

sdfsdf

Jan 26th, 2016
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 9.30 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. path = xbmc.translatePath(os.path.join('special://home/addons','packages'))
  54. dp = xbmcgui.DialogProgress()
  55. dp.create("Abeksis Wizard","Downloading ",'', 'Please Wait')
  56. lib=os.path.join(path, name+'.zip')
  57. try:
  58. os.remove(lib)
  59. except:
  60. pass
  61. downloader.download(url, lib, dp)
  62. addonfolder = xbmc.translatePath(os.path.join('special://','home'))
  63. time.sleep(2)
  64. dp.update(0,"", "Extracting Zip Please Wait")
  65. print '======================================='
  66. print addonfolder
  67. print '======================================='
  68. extract.all(lib,addonfolder,dp)
  69. dialog = xbmcgui.Dialog()
  70. 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')
  71. killxbmc()
  72.  
  73.  
  74.  
  75. def killxbmc():
  76. choice = xbmcgui.Dialog().yesno('Force Close Kodi', 'You are about to close Kodi', 'Would you like to continue?', nolabel='No, Cancel',yeslabel='Yes, Close')
  77. if choice == 0:
  78. return
  79. elif choice == 1:
  80. pass
  81. myplatform = platform()
  82. print "Platform: " + str(myplatform)
  83. if myplatform == 'osx': # OSX
  84. print "############ try osx force close #################"
  85. try: os.system('killall -9 XBMC')
  86. except: pass
  87. try: os.system('killall -9 Kodi')
  88. except: pass
  89. 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.",'')
  90. elif myplatform == 'linux': #Linux
  91. print "############ try linux force close #################"
  92. try: os.system('killall XBMC')
  93. except: pass
  94. try: os.system('killall Kodi')
  95. except: pass
  96. try: os.system('killall -9 xbmc.bin')
  97. except: pass
  98. try: os.system('killall -9 kodi.bin')
  99. except: pass
  100. 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.",'')
  101. elif myplatform == 'android': # Android
  102. print "############ try android force close #################"
  103. try: os.system('adb shell am force-stop org.xbmc.kodi')
  104. except: pass
  105. try: os.system('adb shell am force-stop org.kodi')
  106. except: pass
  107. try: os.system('adb shell am force-stop org.xbmc.xbmc')
  108. except: pass
  109. try: os.system('adb shell am force-stop org.xbmc')
  110. except: pass
  111. 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).")
  112. elif myplatform == 'windows': # Windows
  113. print "############ try windows force close #################"
  114. try:
  115. os.system('@ECHO off')
  116. os.system('tskill XBMC.exe')
  117. except: pass
  118. try:
  119. os.system('@ECHO off')
  120. os.system('tskill Kodi.exe')
  121. except: pass
  122. try:
  123. os.system('@ECHO off')
  124. os.system('TASKKILL /im Kodi.exe /f')
  125. except: pass
  126. try:
  127. os.system('@ECHO off')
  128. os.system('TASKKILL /im XBMC.exe /f')
  129. except: pass
  130. 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")
  131. else: #ATV
  132. print "############ try atv force close #################"
  133. try: os.system('killall AppleTV')
  134. except: pass
  135. print "############ try raspbmc force close #################" #OSMC / Raspbmc
  136. try: os.system('sudo initctl stop kodi')
  137. except: pass
  138. try: os.system('sudo initctl stop xbmc')
  139. except: pass
  140. 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.")
  141.  
  142. def platform():
  143. if xbmc.getCondVisibility('system.platform.android'):
  144. return 'android'
  145. elif xbmc.getCondVisibility('system.platform.linux'):
  146. return 'linux'
  147. elif xbmc.getCondVisibility('system.platform.windows'):
  148. return 'windows'
  149. elif xbmc.getCondVisibility('system.platform.osx'):
  150. return 'osx'
  151. elif xbmc.getCondVisibility('system.platform.atv2'):
  152. return 'atv2'
  153. elif xbmc.getCondVisibility('system.platform.ios'):
  154. return 'ios'
  155.  
  156.  
  157. def addDir(name,url,mode,iconimage,fanart,description):
  158. 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)
  159. ok=True
  160. liz=xbmcgui.ListItem(name, iconImage="DefaultFolder.png", thumbnailImage=iconimage)
  161. liz.setInfo( type="Video", infoLabels={ "Title": name, "Plot": description } )
  162. liz.setProperty( "Fanart_Image", fanart )
  163. ok=xbmcplugin.addDirectoryItem(handle=int(sys.argv[1]),url=u,listitem=liz,isFolder=False)
  164. return ok
  165.  
  166.  
  167.  
  168. def get_params():
  169. param=[]
  170. paramstring=sys.argv[2]
  171. if len(paramstring)>=2:
  172. params=sys.argv[2]
  173. cleanedparams=params.replace('?','')
  174. if (params[len(params)-1]=='/'):
  175. params=params[0:len(params)-2]
  176. pairsofparams=cleanedparams.split('&')
  177. param={}
  178. for i in range(len(pairsofparams)):
  179. splitparams={}
  180. splitparams=pairsofparams[i].split('=')
  181. if (len(splitparams))==2:
  182. param[splitparams[0]]=splitparams[1]
  183.  
  184. return param
  185.  
  186.  
  187. params=get_params()
  188. url=None
  189. name=None
  190. mode=None
  191. iconimage=None
  192. fanart=None
  193. description=None
  194.  
  195.  
  196. try:
  197. url=urllib.unquote_plus(params["url"])
  198. except:
  199. pass
  200. try:
  201. name=urllib.unquote_plus(params["name"])
  202. except:
  203. pass
  204. try:
  205. iconimage=urllib.unquote_plus(params["iconimage"])
  206. except:
  207. pass
  208. try:
  209. mode=int(params["mode"])
  210. except:
  211. pass
  212. try:
  213. fanart=urllib.unquote_plus(params["fanart"])
  214. except:
  215. pass
  216. try:
  217. description=urllib.unquote_plus(params["description"])
  218. except:
  219. pass
  220.  
  221.  
  222. print str(PATH)+': '+str(VERSION)
  223. print "Mode: "+str(mode)
  224. print "URL: "+str(url)
  225. print "Name: "+str(name)
  226. print "IconImage: "+str(iconimage)
  227.  
  228.  
  229. def setView(content, viewType):
  230. # set content type so library shows more views and info
  231. if content:
  232. xbmcplugin.setContent(int(sys.argv[1]), content)
  233. if ADDON.getSetting('auto-view')=='true':
  234. xbmc.executebuiltin("Container.SetViewMode(%s)" % ADDON.getSetting(viewType) )
  235.  
  236.  
  237. if mode==None or url==None or len(url)<1:
  238. CATEGORIES()
  239.  
  240. elif mode==1:
  241. wizard(name,url,description)
  242.  
  243.  
  244.  
  245. xbmcplugin.endOfDirectory(int(sys.argv[1]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement