def import_advancedxml():
	userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8')))
	advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml')
	advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml')
	if xbmcvfs.exists(advancedsettings_var):
		print("An advanced settings XML file already exists")
		if xbmcvfs.exists(advancedsettingsbackup_var):
			print("An advanced settings backup already exists")
			xbmcvfs.delete(advancedsettingsbackup_var)
			xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var)
			advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
			advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
			index = xbmcgui.Dialog().select(translate(40185), advancedname)
    			if index > -1:
    				download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
				mensagemok(translate(40000),translate(40060))
		else:	
			xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var)
			advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
			advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
			index = xbmcgui.Dialog().select(translate(40185), advancedname)
    			if index > -1:
    				download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
				mensagemok(translate(40000),translate(40060))
	else:
		print("No advancedsettings.xml in the system yet")
		advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
		advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
		index = xbmcgui.Dialog().select(translate(40185), advancedname)
    		if index > -1:
    			download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
			mensagemok(translate(40000),translate(40060))
	xbmc.executebuiltin("Container.Refresh")
def import_advancedxml():
	userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8')))
	advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml')
	advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml')
	if xbmcvfs.exists(advancedsettings_var):
		print("An advanced settings XML file already exists")
		if xbmcvfs.exists(advancedsettingsbackup_var):
			print("An advanced settings backup already exists")
			xbmcvfs.delete(advancedsettingsbackup_var)
			xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var)
			advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
			advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
			index = xbmcgui.Dialog().select(translate(40185), advancedname)
    			if index > -1:
    				download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
				mensagemok(translate(40000),translate(40060))
		else:	
			xbmcvfs.rename(advancedsettings_var,advancedsettingsbackup_var)
			advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
			advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
			index = xbmcgui.Dialog().select(translate(40185), advancedname)
    			if index > -1:
    				download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
				mensagemok(translate(40000),translate(40060))
	else:
		print("No advancedsettings.xml in the system yet")
		advancedname = ["Cachemembuffer=252420","freememorycachepercent=5"]
		advancedurl = ["http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettings.xml","http://p2p-strm.googlecode.com/svn/trunk/Advancedsettings/advancedsettingstonicillo.xml"]
		index = xbmcgui.Dialog().select(translate(40185), advancedname)
    		if index > -1:
    			download_tools().Downloader(advancedurl[index],advancedsettings_var,translate(40059),translate(40000))
			mensagemok(translate(40000),translate(40060))
	xbmc.executebuiltin("Container.Refresh")
Ejemplo n.º 3
0
def configure_acestream(latest_version):
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			print("Detected linux armv6 - possible Raspberry PI")
			if settings.getSetting('openelecarm6') == "true": acestream_rpi = acestream_openelec_raspberry
			else: acestream_rpi = acestream_generic_raspberry
			ACE_KIT = os.path.join(addonpath,acestream_rpi.split("/")[-1])
			download_tools().Downloader(acestream_rpi,ACE_KIT,translate(40026),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		#Linux Armv7
		elif os.uname()[4] == "armv7l":
			if settings.getSetting('openelecarm7') == "true": acestream_package = acestream_armv7_openelec
			elif settings.getSetting('xbianarm7') == "true": acestream_package = acestream_armv7_xbian
			elif settings.getSetting('mxlinuxarm7') == "true" or settings.getSetting('jynxbox_arm7') == "true": acestream_package = acestream_mxlinux
		
			ACE_KIT = os.path.join(addonpath,acestream_package.split("/")[-1])
			download_tools().Downloader(acestream_package,ACE_KIT,translate(40026),translate(40000))
			import tarfile
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return

		elif os.uname()[4] == "x86_64":
			if settings.getSetting('openelecx86_64') == "true":
				print("OpenELEC x86_64 Acestream configuration")
				ACE_KIT = os.path.join(addonpath,openeelcx86_64_acestream.split("/")[-1])
				download_tools().Downloader(openeelcx86_64_acestream ,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

			else:
				print("64 bit Linux Disto Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_x64_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_x64_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

		elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
			if settings.getSetting('openeleci386') == "true":
				print("32 bit Openelec Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,openeelcxi386_acestream.split("/")[-1])
				download_tools().Downloader(openeelcxi386_acestream,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return
			else:
				print("32 bit Linux general distro Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_i386_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_i386_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
          #Ace
		SPSC_KIT = os.path.join(addonpath,acestream_windows.split("/")[-1])
		download_tools().Downloader(acestream_windows,SPSC_KIT,translate(40026),translate(40000))
		import shutil
		if xbmcvfs.exists(os.path.join(pastaperfil,"acestream")):
			shutil.rmtree(os.path.join(pastaperfil,"acestream"))
		if xbmcvfs.exists(os.path.join(pastaperfil,"player")):
			shutil.rmtree(os.path.join(pastaperfil,"player"))
		import tarfile
		if tarfile.is_tarfile(SPSC_KIT):
			path_libraries = os.path.join(pastaperfil)
			download_tools().extract(SPSC_KIT,path_libraries)
			download_tools().remove(SPSC_KIT)
		if latest_version: settings.setSetting('acestream_version',value=latest_version)
		return
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x64_acestream
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386_acestream
			available = True
		else:
			available = False
		if available == True:		
			if not xbmcvfs.exists(pastaperfil):
				xbmcvfs.mkdir(pastaperfil)		
			MAC_KIT = os.path.join(addonpath,mac_package.split("/")[-1])
			download_tools().Downloader(mac_package,MAC_KIT,translate(40026),translate(40000))
			import tarfile
			if tarfile.is_tarfile(MAC_KIT):
				path_libraries = os.path.join(pastaperfil)
				download_tools().extract(MAC_KIT,pastaperfil)
				download_tools().remove(MAC_KIT)
				sp_sc_auth = os.path.join(pastaperfil,"sopcast","sp-sc-auth")
				st = os.stat(sp_sc_auth)
				import stat
				os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		else:
			mensagemok(translate(40000),translate(600014))
			return
			
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		print("Starting Acestream Configuration")
		#acestream config for android
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
		#Hack to get xbmc app id
		xbmcfolder=xbmc.translatePath(addonpath).split("/")
		
		i = 0
		found = False
		sopcast_installed = False
		
		for folder in xbmcfolder:
			if folder.count('.') >= 2 and folder != addon_id :
				found = True
				break
			else:
				i+=1

		if found == True:
			uid = os.getuid()
			app_id = xbmcfolder[i]
			settings.setSetting('app_id',app_id)
			#Acestreamconfiguration for android starts here
			if "arm" in os.uname()[4]:
				acebundle = os.path.join(pastaperfil,android_aceengine_arm.split("/")[-1])
				download_tools().Downloader(android_aceengine_arm,acebundle,translate(70014),translate(40000))
			else:
				acebundle = os.path.join(pastaperfil,android_aceengine_x86.split("/")[-1])
				download_tools().Downloader(android_aceengine_x86,acebundle,translate(70014),translate(40000))
			import tarfile
			if tarfile.is_tarfile(acebundle):
				download_tools().extract(acebundle,pastaperfil)
				download_tools().remove(acebundle)
			orgacestreamenginefolder = os.path.join(pastaperfil,"org.acestream.engine")
			xbmc_data_path = os.path.join("/data", "data", app_id)
			if os.path.exists(xbmc_data_path) and uid == os.stat(xbmc_data_path).st_uid:
				android_binary_dir = os.path.join(xbmc_data_path, "files", "plugin.video.p2p-streams")
				if not os.path.exists(android_binary_dir): os.makedirs(android_binary_dir)
            		android_acestream_folder = os.path.join(android_binary_dir,"org.acestream.engine")
            		if not os.path.exists(android_acestream_folder): os.makedirs(android_acestream_folder)
            		xbmc.sleep(200)
            		recursive_overwrite(orgacestreamenginefolder, android_acestream_folder, ignore=None)
            		pythonbin = os.path.join(android_acestream_folder,"files","python","bin","python")
            		st = os.stat(pythonbin)
            		import stat
            		os.chmod(pythonbin, st.st_mode | stat.S_IEXEC)
			opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70015),translate(70016))
			if not opcao:
				settings.setSetting('engine_app','0')
			else:
				mensagemok(translate(40000),translate(50018),translate(50019),translate(50020))
				if xbmcvfs.exists(os.path.join("sdcard","Download")):
					pasta = os.path.join("sdcard","Download")
					if "arm" in os.uname()[4]: acefile = os.path.join("sdcard","Download",acestreamengine_apk_arm.split("/")[-1])
					else: acefile = os.path.join("sdcard","Download",acestreamengine_apk_x86.split("/")[-1])
				else:
					dialog = xbmcgui.Dialog()
					pasta = dialog.browse(int(0), translate(40190), 'myprograms')
					if "arm" in os.uname()[4]: acefile = os.path.join(pasta,acestreamengine_apk_arm.split("/")[-1])
					else: acefile = os.path.join(pasta,acestreamengine_apk_x86.split("/")[-1])
				if "arm" in os.uname()[4]: download_tools().Downloader(acestreamengine_apk_arm,acefile,translate(40072),translate(40000))
				else: download_tools().Downloader(acestreamengine_apk_x86,acefile,translate(40072),translate(40000))
				import tarfile
				if tarfile.is_tarfile(acefile):
					download_tools().extract(acefile,pasta)
					download_tools().remove(acefile)
				xbmc.sleep(2000)
				mensagemok(translate(40000),translate(50021),pasta,translate(50016))
				mensagemok(translate(40000),translate(50023),translate(50024),translate(50025))
				settings.setSetting('engine_app','1')
			opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70017),translate(70018))
			if opcao:
				if xbmcvfs.exists(os.path.join("sdcard","Download")):
					pasta = os.path.join("sdcard","Download")
					if "arm" in os.uname()[4]: acefile = os.path.join("sdcard","Download",android_aceplayer_arm.split("/")[-1])
					else: os.path.join("sdcard","Download",android_aceplayer_x86.split("/")[-1])
				else:
					dialog = xbmcgui.Dialog()
					pasta = dialog.browse(int(0), translate(40190), 'myprograms')
					if "arm" in os.uname()[4]: acefile = os.path.join(pasta,acestreamengine_apk_arm.split("/")[-1])
					else: acefile = os.path.join(pasta,acestreamengine_apk_x86.split("/")[-1])
				if "arm" in os.uname()[4]: download_tools().Downloader(android_aceplayer_arm,acefile,translate(70019),translate(40000))
				else: download_tools().Downloader(android_aceplayer_x86,acefile,translate(70019),translate(40000))
				import tarfile
				if tarfile.is_tarfile(acefile):
					download_tools().extract(acefile,pasta)
					download_tools().remove(acefile)
				xbmc.sleep(2000)
				mensagemok(translate(40000),translate(70020),pasta,translate(50016))
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70021))
				if opcao:
					settings.setSetting('engine_app','2')							
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			mensagemok(translate(40000),translate(50022))
			return			
		else:
			mensagemok(translate(40000),translate(50017))
			return	
Ejemplo n.º 4
0
def configure_sopcast(latest_version):
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			print("Detected linux armv6 - possible Raspberry PI")
			#Sop
			SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
			download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(SPSC_KIT):
				path_libraries = os.path.join(pastaperfil,"sopcast")
				download_tools().extract(SPSC_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)
			if latest_version: settings.setSetting('sopcast_version',value=latest_version)
			return

		elif os.uname()[4] == "armv7l":
			if settings.getSetting('jynxbox_arm7') == "true":
				SPSC_KIT = os.path.join(addonpath,sopcast_jynxbox.split("/")[-1])
				download_tools().Downloader(sopcast_jynxbox,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil)
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return
			else:
				SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
				download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"sopcast")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return

		elif os.uname()[4] == "x86_64":
			generic = False
			if settings.getSetting('openelecx86_64') == "true":
				print("Detected OpenELEC x86_64")
				SPSC_KIT = os.path.join(addonpath,openelecx86_64_sopcast.split("/")[-1])
				download_tools().Downloader(openelecx86_64_sopcast,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					download_tools().extract(SPSC_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return
			else: generic = True
		elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
			generic = False
			if settings.getSetting('openeleci386') == "true":
				SPSC_KIT = os.path.join(addonpath,openelecxi386_sopcast.split("/")[-1])
				download_tools().Downloader(openelecxi386_sopcast,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					download_tools().extract(SPSC_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return
			else: generic = True
		if generic == True:
			SPSC_KIT = os.path.join(addonpath,sopcast_linux_generico.split("/")[-1])
			download_tools().Downloader(sopcast_linux_generico,SPSC_KIT,translate(40025),translate(40000))
			import tarfile
			if tarfile.is_tarfile(SPSC_KIT):
				path_libraries = os.path.join(pastaperfil,"sopcast")
				download_tools().extract(SPSC_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)
			#set every single file from the bundle as executable
			path_libraries = os.path.join(pastaperfil,"sopcast")
			dirs, files = xbmcvfs.listdir(path_libraries)
			for ficheiro in files:
				binary_path = os.path.join(path_libraries,ficheiro)
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
			path_libraries = os.path.join(path_libraries,"lib")
			dirs, files = xbmcvfs.listdir(path_libraries)
			for ficheiro in files:
				binary_path = os.path.join(path_libraries,ficheiro)
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('sopcast_version',value=latest_version)
			return


	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
        	#Sop
		import ctypes
                is_admin=ctypes.windll.shell32.IsUserAnAdmin() != 0
                if is_admin == False:
                    mensagemok(translate(40000),translate(40158),translate(40159))
                else:
		    import subprocess
                    cmd = ['sc','delete','sopcastp2p']
                    proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                    for line in proc.stdout:
                        print("cmd out: " + line.rstrip())
                    xbmc.sleep(1000)
                    ret = mensagemprogresso.create(translate(40000),translate(40000))
                    mensagemprogresso.update(0,translate(40160),"  ")
                    xbmc.sleep(1000)
                    import _winreg
                    aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                    try:
                        aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath',0, _winreg.KEY_READ)
                        name, value, type = _winreg.EnumValue(aKey, 0)
                        sopcast_executable = value
                        print("Installation executable of sopcast was found: " + sopcast_executable)
                        _winreg.CloseKey(aKey)
                        mensagemprogresso.update(10,translate(40160),translate(40161))
                    except:
                        sopcast_executable = ""
                        mensagemok(translate(40000),translate(40162),translate(40163))
                    if not sopcast_executable: pass
                    else:
                        xbmc.sleep(1000)
                        mensagemprogresso.update(20,translate(40164),"  ")
                        xbmc.sleep(1000)
                        print ("Getting windows users IDS")
                        aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                        aKey = _winreg.OpenKey(aReg, r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList')
                        users = []
                        for i in range(1024):
                            try:
                                asubkey=_winreg.EnumKey(aKey,i)
                                print(asubkey)
                                aKeydois = _winreg.OpenKey(aReg, os.path.join('SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList',asubkey))
                                val=_winreg.QueryValueEx(aKeydois, "ProfileImagePath")
                                try:
                                    print(val[0])
                                except:
                                    print("Notice: User with strange characters, print cmd ignored.")
                                if "Windows" in val[0] or "%systemroot%" in val[0]:
                                    pass
                                else:
                                    users.append(asubkey)
                            except:
                                pass
                        if not users:
                            mensagemok(translate(40000),translate(40165))
                        else:
                            mensagemprogresso.update(30,translate(40164),translate(40161))
                            xbmc.sleep(200)
                            mensagemprogresso.update(30,translate(40166),"   ")
                            xbmc.sleep(1000)
                            print("System Users", users)
                            srvany_final_location = os.path.join(sopcast_executable.replace("SopCast.exe",""),"srvany.exe")
                            srvany_download_location = os.path.join(addonpath,"srvany.exe")
                            srvanytgz_download_location = os.path.join(addonpath,"srvany.tar.gz")                            
                            download_tools().Downloader(srvany_executable,srvanytgz_download_location,translate(40167),translate(40000)) 
                            xbmc.sleep(1000)
                            import tarfile
                            if tarfile.is_tarfile(srvanytgz_download_location):
                                path_libraries = addonpath
                                download_tools().extract(srvanytgz_download_location,path_libraries)
                                xbmcvfs.copy(srvany_download_location,srvany_final_location)
                                download_tools().remove(srvanytgz_download_location)
                                download_tools().remove(srvany_download_location)
                            xbmc.sleep(1000)
                            ret = mensagemprogresso.create(translate(40000),translate(40000))
                            xbmc.sleep(200)
                            mensagemprogresso.update(35,translate(40168),"  ")
                            xbmc.sleep(1000)
                            import subprocess
                            cmd = ['sc','create','sopcastp2p','binpath=',os.path.join(os.path.join(sopcast_executable.replace("SopCast.exe","")),'srvany.exe')]
                            proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                            servicecreator = False
                            for line in proc.stdout:
                                print ("cmd out: " + line.rstrip())
                                servicecreator = True
                            if servicecreator == False:
                                mensagemok(translate(40000),translate(40169))
                            else:
                                mensagemprogresso.update(40,translate(40168),translate(40161))
                                xbmc.sleep(1000)
                                mensagemprogresso.update(45,translate(40170),"  ")
                                xbmc.sleep(1000)
                                print("Trying to modify regedit....")
                                try:
                                    aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                                    key = _winreg.CreateKey(aReg, r'SYSTEM\CurrentControlSet\Services\sopcastp2p\Parameters')
                                    _winreg.SetValueEx(key, 'AppDirectory', 0, _winreg.REG_SZ, os.path.join(sopcast_executable.replace("SopCast.exe","")))
                                    _winreg.SetValueEx(key, 'Application', 0, _winreg.REG_SZ, os.path.join(os.path.join(sopcast_executable.replace("SopCast.exe","")),"SopCast.exe"))
                                    _winreg.SetValueEx(key, 'AppParameters', 0, _winreg.REG_SZ, "sop://")
                                    mensagemprogresso.update(50,translate(40170), translate(40161))
                                    regedit = True
                                except:
                                    mensagemok(translate(40000),translate(40171))
                                    regedit = False
                                if regedit == False: pass
                                else:
                                    xbmc.sleep(1000)
                                    mensagemprogresso.update(50,translate(40172), "   ")
                                    cmd = ['sc','sdshow','sopcastp2p']
                                    proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                    lines = []
                                    for line in proc.stdout:
					print(line.rstrip())
                                        if line.rstrip() != "" and "(" in line.rstrip(): lines.append(line.rstrip())
                                        else: pass
                                    if len(lines) != 1: mensagemok(translate(40000),translate(40173))
                                    else:
                                        linha_arr = []
                                        for user in users:
                                            linha_arr.append('(A;;RPWPCR;;;' + user + ')')
                                        linha_add = ''
                                        for linha in linha_arr:
                                            linha_add += linha
                                        print("line peace to add: " + linha_add)
                                        linha_final = lines[0].replace("S:(",linha_add + "S:(")
                                        print("Final line: " + linha_final)
                                        permissions = False
                                        xbmc.sleep(500)
                                        mensagemprogresso.update(60,translate(40172), translate(40161))
                                        xbmc.sleep(500)
                                        mensagemprogresso.update(60,translate(40174), "   ")
                                        cmd = ['sc','sdset','sopcastp2p',linha_final]
                                        proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                        for line in proc.stdout:
                                            print(line.rstrip())
                                            permissions = True
                                        if permissions == False: mensagemok(translate(40000),translate(40175))
                                        else:
                                            mensagemprogresso.update(70,translate(40174), translate(40161))
                                            xbmc.sleep(1000)
                                            mensagemprogresso.update(70,translate(40176), "   ")
                                            print("Trying to set sopcastp2p service regedit permissions...")
                                            download_tools().Downloader(srvany_permissions,os.path.join(pastaperfil,"sopcastp2p-permissions.txt"),translate(40177),translate(40000))
                                            xbmc.sleep(500)
                                            ret = mensagemprogresso.create(translate(40000),translate(40000))
                                            xbmc.sleep(500)
                                            mensagemprogresso.update(80,translate(40178), "   ")
                                            xbmc.sleep(1000)
                                            cmd = ['regini',os.path.join(pastaperfil,"sopcastp2p-permissions.txt")]
                                            proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                            for line in proc.stdout:
                                                print(line.rstrip())
                                            mensagemprogresso.update(90,translate(40178), translate(40178))
                                            mensagemprogresso.update(100,translate(40179), "   ")
                                            xbmc.sleep(2000)
                                            mensagemprogresso.close()
                                            if latest_version: settings.setSetting('sopcast_version',value=latest_version)
                                            return
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x64_sopcast
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386_sopcast
			available = True
		else:
			available = False
		if available == True:		
			if not xbmcvfs.exists(pastaperfil):
				xbmcvfs.mkdir(pastaperfil)		
			MAC_KIT = os.path.join(addonpath,mac_package.split("/")[-1])
			download_tools().Downloader(mac_package,MAC_KIT,translate(40025),translate(40000))
			import tarfile
			if tarfile.is_tarfile(MAC_KIT):
				path_libraries = os.path.join(pastaperfil)
				download_tools().extract(MAC_KIT,pastaperfil)
				download_tools().remove(MAC_KIT)
				sp_sc_auth = os.path.join(pastaperfil,"sopcast","sp-sc-auth")
				st = os.stat(sp_sc_auth)
				import stat
				os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('sopcast_version',value=latest_version)
			return
		else:
			mensagemok(translate(40000),translate(600014))
			return
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		#Sopcast configuration
		print("Starting SopCast Configuration")

		#Moving sopclient to ext4 hack - tks steeve from xbmctorrent

		sopclient_builtin_location = os.path.join(addonpath,"resources","binaries","sopclient")

		#Hack to get current xbmc app id
		xbmcfolder=xbmc.translatePath(addonpath).split("/")

		i = 0
		found = False
		sopcast_installed = False
		
		for folder in xbmcfolder:
			if folder.count('.') >= 2 and folder != addon_id :
				found = True
				break
			else:
				i+=1

		if found == True:
			uid = os.getuid()
			app_id = xbmcfolder[i]
			xbmc_data_path = os.path.join("/data", "data", app_id)
			if os.path.exists(xbmc_data_path) and uid == os.stat(xbmc_data_path).st_uid:
				android_binary_dir = os.path.join(xbmc_data_path, "files", "plugin.video.p2p-streams")
				if not os.path.exists(android_binary_dir):
            				os.makedirs(android_binary_dir)
				android_binary_path = os.path.join(android_binary_dir, "sopclient")
		        	if not os.path.exists(android_binary_path) or os.path.getsize(android_binary_path) != os.path.getsize(sopclient_builtin_location):
					import shutil
					shutil.copy2(sopclient_builtin_location, android_binary_path)
				binary_path = android_binary_path
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
				settings.setSetting('android_sopclient',value=binary_path)
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(50011),translate(50012))
				if not opcao:
					settings.setSetting('external-sopcast',value='1')
					settings.setSetting('force_android',value='true')
					sopcast_installed = True
					mensagemok(translate(40000),translate(50014))
				else:
					mensagemok(translate(40000),translate(50013))
					if xbmcvfs.exists(os.path.join("sdcard","Download")):
						pasta = os.path.join("sdcard","Download")
						sopfile = os.path.join("sdcard","Download",sopcast_apk.split("/")[-1])
					else:
						dialog = xbmcgui.Dialog()
						pasta = dialog.browse(int(0), translate(40190), 'myprograms')
						sopfile = os.path.join(pasta,sopcast_apk.split("/")[-1])
					download_tools().Downloader(sopcast_apk,sopfile,translate(40073),translate(40000))
					import tarfile
					if tarfile.is_tarfile(sopfile):
						download_tools().extract(sopfile,pasta)
						download_tools().remove(sopfile)
					mensagemok(translate(40000),translate(50015),pasta,translate(50016))
					sopcast_installed = True
					settings.setSetting('external-sopcast',value='0')
					mensagemok(translate(40000),translate(50014))
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return

		else:
			mensagemok(translate(40000),translate(50017))
			return
Ejemplo n.º 5
0
def autoconf():
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			try:
				if re.search(os.uname()[1],"openelec",re.IGNORECASE): acestream_rpi = acestream_openelec_raspberry
				elif re.search(os.uname()[1],"raspbmc",re.IGNORECASE): acestream_rpi = acestream_generic_raspberry
				elif os.path.isfile("/etc/xbian_version"): acestream_rpi = acestream_generic_raspberry
				elif "ARCH" in os.uname()[2]:
					acestream_rpi = acestream_generic_raspberry
					settings.setSetting('python_cmd',value='python2')
				else:
					mensagemok(translate(40000),translate(400007),translate(400008))
					OS_list = ["OpenELEC","Raspbmc","Xbian","Pipplware","Arch Linux Arm"]
					url_packagerpi_list = [acestream_openelec_raspberry, acestream_generic_raspberry, acestream_generic_raspberry,acestream_generic_raspberry, acestream_generic_raspberry]
					OS_Rpi_choose = xbmcgui.Dialog().select
					choose=OS_Rpi_choose('Select your OS',OS_list)
					if choose > -1:
						acestream_rpi= url_packagerpi_list[choose]
						if OS_list[choose] == "Arch Linux Arm": settings.setSetting('python_cmd',value='python2')
			except: acestream_rpi = ""
			print("Detected linux armv6 - possible Raspberry PI")
			#Sop

			SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
			download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(SPSC_KIT):
				path_libraries = os.path.join(pastaperfil,"sopcast")
				download_tools().extract(SPSC_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)

            		#Ace
			SPSC_KIT = os.path.join(addonpath,acestream_rpi.split("/")[-1])
			download_tools().Downloader(acestream_rpi,SPSC_KIT,translate(40026),translate(40000))
        
			if tarfile.is_tarfile(SPSC_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(SPSC_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)

			settings.setSetting('autoconfig',value='false')


                elif os.uname()[4] == "armv7l":
			if re.search(os.uname()[1],"openelec",re.IGNORECASE):
				OS_Choose = "OpenELEC"
			elif os.path.isfile("/etc/xbian_version"):
				OS_Choose = "Xbian"
			else:
                		mensagemok(translate(40000),translate(40109),translate(40110))
                		OS_list = ["MXLinux","OpenELEC","Xbian"]
                		choose=xbmcgui.Dialog().select('Select your OS',OS_list)
                		if choose > -1:
                			OS_Choose= OS_list[choose]

			#Linux armv7 configuration according to platform

			#MXLINUX
                	if OS_Choose == "MXLinux":
				acestream_installed = False
				sopcast_installed = False
               			print("Detected MXLinux armv7")
               			SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
               			download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
               			import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"sopcast")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
					sopcast_installed = True

				SPSC_KIT = os.path.join(addonpath,acestream_mxlinux.split("/")[-1])
				download_tools().Downloader(acestream_mxlinux,SPSC_KIT,translate(40026),translate(40000))
        			if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"acestream")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
					acestream_installed = True
				if acestream_installed and sopcast_installed:
					settings.setSetting('autoconfig',value='false')	

			#OPENELEC

                	if OS_Choose == "OpenELEC":
                		import tarfile
				acestream_installed = False
				sopcast_installed = False
                		print("Openelec armv7 platform detected")
                		SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
                		download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"sopcast")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
					sopcast_installed = True
				SPSC_KIT = os.path.join(addonpath,acestream_armv7_openelec.split("/")[-1])
				download_tools().Downloader(acestream_armv7_openelec,SPSC_KIT,translate(40026),translate(40000))
        			if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"acestream")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
					acestream_installed = True
				if acestream_installed and sopcast_installed:
					settings.setSetting('autoconfig',value='false')	

			#XBIAN
               		if OS_Choose == "Xbian":
               			import tarfile
				acestream_installed = False
				sopcast_installed = False
               			print("Xbian armv7 platform detected")
               			SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
               			download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"sopcast")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
					sopcast_installed = True
				SPSC_KIT = os.path.join(addonpath,acestream_armv7_xbian.split("/")[-1])
				download_tools().Downloader(acestream_armv7_xbian,SPSC_KIT,translate(40026),translate(40000))
       				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"acestream")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
					acestream_installed = True
				if acestream_installed and sopcast_installed:
					settings.setSetting('autoconfig',value='false')	


			
		elif (os.uname()[4] == "x86_64" and re.search(os.uname()[1],"openelec",re.IGNORECASE)) or settings.getSetting('openelecx86_64') == "true":
			settings.setSetting('openelecx86_64',value='true')
			print("Detected OpenELEC x86_64")
			SPSC_KIT = os.path.join(addonpath,openelecx86_64_package.split("/")[-1])
			download_tools().Downloader(openelecx86_64_package,SPSC_KIT,translate(40112),translate(40000))
			import tarfile
			if tarfile.is_tarfile(SPSC_KIT):
				download_tools().extract(SPSC_KIT,pastaperfil)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)
			settings.setSetting('autoconfig',value='false')

		elif (os.uname()[4] == "i386" and re.search(os.uname()[1],"openelec",re.IGNORECASE)) or (os.uname()[4] == "i686" and re.search(os.uname()[1],"openelec",re.IGNORECASE)) or settings.getSetting('openeleci386') == "true":
			settings.setSetting('openeleci386',value='true')
			print("Detected OpenELEC i386")
			SPSC_KIT = os.path.join(addonpath,openeleci386_package.split("/")[-1])
			download_tools().Downloader(openeleci386_package,SPSC_KIT,translate(40112),translate(40000))
			import tarfile
			if tarfile.is_tarfile(SPSC_KIT):
				download_tools().extract(SPSC_KIT,pastaperfil)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)
			settings.setSetting('autoconfig',value='false')		
	
		else:
			if os.uname()[4] == "x86_64":
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(40113))
				if opcao: 
					settings.setSetting('openelecx86_64',value='true')
					autoconf()
			elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(600023))
				if opcao: 
					settings.setSetting('openeleci386',value='true')
					autoconf()

			else: mensagemok(translate(40000),translate(40056))
			

			#Linux but not openelec i386 nor openelec x86_64 - General Linux platforms configuration
			
			if settings.getSetting('openeleci386') == "false" and settings.getSetting('openelecx86_64') == "false":

				print("Detected Other Linux i386 Plataform")

            		#Sop
            		#Download and extract sopcast-bundle
				SPSC_KIT = os.path.join(addonpath,sopcast_linux_generico.split("/")[-1])
				download_tools().Downloader(sopcast_linux_generico,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"sopcast")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				#set every single file from the bundle as executable
				path_libraries = os.path.join(pastaperfil,"sopcast")
				dirs, files = xbmcvfs.listdir(path_libraries)
				for ficheiro in files:
					binary_path = os.path.join(path_libraries,ficheiro)
					st = os.stat(binary_path)
					import stat
					os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
				path_libraries = os.path.join(path_libraries,"lib")
				dirs, files = xbmcvfs.listdir(path_libraries)
				for ficheiro in files:
					binary_path = os.path.join(path_libraries,ficheiro)
					st = os.stat(binary_path)
					import stat
					os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
	   		 
	   		 #Ace
	   		 
				import subprocess
				proc_response = []
				proc = subprocess.Popen(['whereis','acestreamengine'],stdout=subprocess.PIPE)
				for line in proc.stdout:
					print("Output of acestream subprocess check",line.rstrip())
					proc_response.append(line.rstrip())
					if "acestreamengine: /" in str(proc_response):
						print("Acestream engine is already installed")
						try:
							proc.kill()
							proc.wait()
						except:pass
					else:
						mensagemok(AceStream,translate(40027),translate(40028) + linkwiki,translate(40029))
						sys.exit(0)
				settings.setSetting('autoconfig',value='false')


	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
        	#Sop
		import ctypes
                is_admin=ctypes.windll.shell32.IsUserAnAdmin() != 0
                if is_admin == False:
                    mensagemok(translate(40000),translate(40158),translate(40159))
                else:
		    import subprocess
                    cmd = ['sc','delete','sopcastp2p']
                    proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                    for line in proc.stdout:
                        print("cmd out: " + line.rstrip())
                    xbmc.sleep(1000)
                    ret = mensagemprogresso.create(translate(40000),translate(40000))
                    mensagemprogresso.update(0,translate(40160),"  ")
                    xbmc.sleep(1000)
                    import _winreg
                    aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                    try:
                        aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath',0, _winreg.KEY_READ)
                        name, value, type = _winreg.EnumValue(aKey, 0)
                        sopcast_executable = value
                        print("Installation executable of sopcast was found: " + sopcast_executable)
                        _winreg.CloseKey(aKey)
                        mensagemprogresso.update(10,translate(40160),translate(40161))
                    except:
                        sopcast_executable = ""
                        mensagemok(translate(40000),translate(40162),translate(40163))
                    if not sopcast_executable: pass
                    else:
                        xbmc.sleep(1000)
                        mensagemprogresso.update(20,translate(40164),"  ")
                        xbmc.sleep(1000)
                        print ("Getting windows users IDS")
                        aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                        aKey = _winreg.OpenKey(aReg, r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList')
                        users = []
                        for i in range(1024):
                            try:
                                asubkey=_winreg.EnumKey(aKey,i)
                                print(asubkey)
                                aKeydois = _winreg.OpenKey(aReg, os.path.join('SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList',asubkey))
                                val=_winreg.QueryValueEx(aKeydois, "ProfileImagePath")
                                try:
                                    print(val[0])
                                except:
                                    print("Notice: User with strange characters, print cmd ignored.")
                                if "Windows" in val[0] or "%systemroot%" in val[0]:
                                    pass
                                else:
                                    users.append(asubkey)
                            except:
                                pass
                        if not users:
                            mensagemok(translate(40000),translate(40165))
                        else:
                            mensagemprogresso.update(30,translate(40164),translate(40161))
                            xbmc.sleep(200)
                            mensagemprogresso.update(30,translate(40166),"   ")
                            xbmc.sleep(1000)
                            print("System Users", users)
                            srvany_final_location = os.path.join(sopcast_executable.replace("SopCast.exe",""),"srvany.exe")
                            srvany_download_location = os.path.join(addonpath,"srvany.exe")
                            srvanytgz_download_location = os.path.join(addonpath,"srvany.tar.gz")                            
                            download_tools().Downloader(srvany_executable,srvanytgz_download_location,translate(40167),translate(40000)) 
                            xbmc.sleep(1000)
                            import tarfile
                            if tarfile.is_tarfile(srvanytgz_download_location):
                                path_libraries = addonpath
                                download_tools().extract(srvanytgz_download_location,path_libraries)
                                xbmcvfs.copy(srvany_download_location,srvany_final_location)
                                download_tools().remove(srvanytgz_download_location)
                                download_tools().remove(srvany_download_location)
                            xbmc.sleep(1000)
                            ret = mensagemprogresso.create(translate(40000),translate(40000))
                            xbmc.sleep(200)
                            mensagemprogresso.update(35,translate(40168),"  ")
                            xbmc.sleep(1000)
                            import subprocess
                            cmd = ['sc','create','sopcastp2p','binpath=',os.path.join(os.path.join(sopcast_executable.replace("SopCast.exe","")),'srvany.exe')]
                            proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                            servicecreator = False
                            for line in proc.stdout:
                                print ("cmd out: " + line.rstrip())
                                servicecreator = True
                            if servicecreator == False:
                                mensagemok(translate(40000),translate(40169))
                            else:
                                mensagemprogresso.update(40,translate(40168),translate(40161))
                                xbmc.sleep(1000)
                                mensagemprogresso.update(45,translate(40170),"  ")
                                xbmc.sleep(1000)
                                print("Trying to modify regedit....")
                                try:
                                    aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                                    key = _winreg.CreateKey(aReg, r'SYSTEM\CurrentControlSet\Services\sopcastp2p\Parameters')
                                    _winreg.SetValueEx(key, 'AppDirectory', 0, _winreg.REG_SZ, os.path.join(sopcast_executable.replace("SopCast.exe","")))
                                    _winreg.SetValueEx(key, 'Application', 0, _winreg.REG_SZ, os.path.join(os.path.join(sopcast_executable.replace("SopCast.exe","")),"SopCast.exe"))
                                    _winreg.SetValueEx(key, 'AppParameters', 0, _winreg.REG_SZ, "sop://")
                                    mensagemprogresso.update(50,translate(40170), translate(40161))
                                    regedit = True
                                except:
                                    mensagemok(translate(40000),translate(40171))
                                    regedit = False
                                if regedit == False: pass
                                else:
                                    xbmc.sleep(1000)
                                    mensagemprogresso.update(50,translate(40172), "   ")
                                    cmd = ['sc','sdshow','sopcastp2p']
                                    proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                    lines = []
                                    for line in proc.stdout:
					print(line.rstrip())
                                        if line.rstrip() != "" and "(" in line.rstrip(): lines.append(line.rstrip())
                                        else: pass
                                    if len(lines) != 1: mensagemok(translate(40000),translate(40173))
                                    else:
                                        linha_arr = []
                                        for user in users:
                                            linha_arr.append('(A;;RPWPCR;;;' + user + ')')
                                        linha_add = ''
                                        for linha in linha_arr:
                                            linha_add += linha
                                        print("line peace to add: " + linha_add)
                                        linha_final = lines[0].replace("S:(",linha_add + "S:(")
                                        print("Final line: " + linha_final)
                                        permissions = False
                                        xbmc.sleep(500)
                                        mensagemprogresso.update(60,translate(40172), translate(40161))
                                        xbmc.sleep(500)
                                        mensagemprogresso.update(60,translate(40174), "   ")
                                        cmd = ['sc','sdset','sopcastp2p',linha_final]
                                        proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                        for line in proc.stdout:
                                            print(line.rstrip())
                                            permissions = True
                                        if permissions == False: mensagemok(translate(40000),translate(40175))
                                        else:
                                            mensagemprogresso.update(70,translate(40174), translate(40161))
                                            xbmc.sleep(1000)
                                            mensagemprogresso.update(70,translate(40176), "   ")
                                            print("Trying to set sopcastp2p service regedit permissions...")
                                            download_tools().Downloader(srvany_permissions,os.path.join(pastaperfil,"sopcastp2p-permissions.txt"),translate(40177),translate(40000))
                                            xbmc.sleep(500)
                                            ret = mensagemprogresso.create(translate(40000),translate(40000))
                                            xbmc.sleep(500)
                                            mensagemprogresso.update(80,translate(40178), "   ")
                                            xbmc.sleep(1000)
                                            cmd = ['regini',os.path.join(pastaperfil,"sopcastp2p-permissions.txt")]
                                            proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                            for line in proc.stdout:
                                                print(line.rstrip())
                                            mensagemprogresso.update(90,translate(40178), translate(40178))
                                            mensagemprogresso.update(100,translate(40179), "   ")
                                            xbmc.sleep(2000)
                                            mensagemprogresso.close()
        #Ace
		SPSC_KIT = os.path.join(addonpath,acestream_windows.split("/")[-1])
		download_tools().Downloader(acestream_windows,SPSC_KIT,translate(40026),translate(40000))
		import shutil
		if xbmcvfs.exists(os.path.join(pastaperfil,"acestream")):
			shutil.rmtree(os.path.join(pastaperfil,"acestream"))
		if xbmcvfs.exists(os.path.join(pastaperfil,"player")):
			shutil.rmtree(os.path.join(pastaperfil,"player"))
		import tarfile
		if tarfile.is_tarfile(SPSC_KIT):
			path_libraries = os.path.join(pastaperfil)
			download_tools().extract(SPSC_KIT,path_libraries)
			download_tools().remove(SPSC_KIT)
		settings.setSetting('autoconfig',value='false')
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x86_64
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386
			available = True
		else:
			available = False
		if available == True:		
			if not xbmcvfs.exists(pastaperfil):
				xbmcvfs.mkdir(pastaperfil)		
			MAC_KIT = os.path.join(addonpath,mac_package.split("/")[-1])
			download_tools().Downloader(mac_package,MAC_KIT,translate(40112),translate(40000))
			import tarfile
			if tarfile.is_tarfile(MAC_KIT):
				path_libraries = os.path.join(pastaperfil)
				download_tools().extract(MAC_KIT,pastaperfil)
				download_tools().remove(MAC_KIT)
				sp_sc_auth = os.path.join(pastaperfil,"sopcast","sp-sc-auth")
				st = os.stat(sp_sc_auth)
				import stat
				os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
				settings.setSetting('autoconfig',value='false')
		else:
			mensagemok(translate(40000),translate(600014))
			sys.exit(0)
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		#Sopcast configuration
		print("Starting SopCast Configuration")

		#Moving sopclient to ext4 hack - tks steeve from xbmctorrent

		sopclient_builtin_location = os.path.join(addonpath,"resources","binaries","sopclient")

		#Hack to get current xbmc app id
		xbmcfolder=xbmc.translatePath(addonpath).split("/")

		i = 0
		found = False
		sopcast_installed = False
		
		for folder in xbmcfolder:
			if folder.count('.') >= 2 and folder != addon_id :
				found = True
				break
			else:
				i+=1

		if found == True:
			uid = os.getuid()
			app_id = xbmcfolder[i]
			xbmc_data_path = os.path.join("/data", "data", app_id)
			if os.path.exists(xbmc_data_path) and uid == os.stat(xbmc_data_path).st_uid:
				android_binary_dir = os.path.join(xbmc_data_path, "files", "plugin.video.p2p-streams")
				if not os.path.exists(android_binary_dir):
            				os.makedirs(android_binary_dir)
				android_binary_path = os.path.join(android_binary_dir, "sopclient")
		        	if not os.path.exists(android_binary_path) or os.path.getsize(android_binary_path) != os.path.getsize(sopclient_builtin_location):
					import shutil
					shutil.copy2(sopclient_builtin_location, android_binary_path)
				binary_path = android_binary_path
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
				settings.setSetting('android_sopclient',value=binary_path)
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(50011),translate(50012))
				if not opcao:
					settings.setSetting('external_sopcast',value='1')
					settings.setSetting('force_android',value='true')
					sopcast_installed = True
					mensagemok(translate(40000),translate(50014))
				else:
					mensagemok(translate(40000),translate(50013))
					if xbmcvfs.exists(os.path.join("sdcard","Download")):
						pasta = os.path.join("sdcard","Download")
						sopfile = os.path.join("sdcard","Download",sopcast_apk.split("/")[-1])
					else:
						dialog = xbmcgui.Dialog()
						pasta = dialog.browse(int(0), translate(40190), 'myprograms')
						sopfile = os.path.join(pasta,sopcast_apk.split("/")[-1])
					download_tools().Downloader(sopcast_apk,sopfile,translate(40073),translate(40000))
					import tarfile
					if tarfile.is_tarfile(sopfile):
						download_tools().extract(sopfile,pasta)
						download_tools().remove(sopfile)
					mensagemok(translate(40000),translate(50015),pasta,translate(50016))
					sopcast_installed = True
					settings.setSetting('external_sopcast',value='0')
					mensagemok(translate(40000),translate(50014))

		else:
			mensagemok(translate(40000),translate(50017))

		#acestream config for android

		if sopcast_installed == True:
			mensagemok(translate(40000),translate(50018),translate(50019),translate(50020))
			if xbmcvfs.exists(os.path.join("sdcard","Download")):
				pasta = os.path.join("sdcard","Download")
				acefile = os.path.join("sdcard","Download",acestreamengine_apk.split("/")[-1])
			else:
				dialog = xbmcgui.Dialog()
				pasta = dialog.browse(int(0), translate(40190), 'myprograms')
				acefile = os.path.join(pasta,acestreamengine_apk.split("/")[-1])
			download_tools().Downloader(acestreamengine_apk,acefile,translate(40072),translate(40000))
			import tarfile
			if tarfile.is_tarfile(acefile):
				download_tools().extract(acefile,pasta)
				download_tools().remove(acefile)
			xbmc.sleep(2000)
			mensagemok(translate(40000),translate(50021),pasta,translate(50016))
			mensagemok(translate(40000),translate(50022))
			mensagemok(translate(40000),translate(50023),translate(50024),translate(50025))
			settings.setSetting('autoconfig',value='false')	
Ejemplo n.º 6
0
def configure_acestream(latest_version):
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			print("Detected linux armv6 - possible Raspberry PI")
			if settings.getSetting('openelecarm6') == "true": acestream_rpi = acestream_openelec_raspberry
			else: acestream_rpi = acestream_generic_raspberry
			ACE_KIT = os.path.join(addonpath,acestream_rpi.split("/")[-1])
			download_tools().Downloader(acestream_rpi,ACE_KIT,translate(40026),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		#Linux Armv7
		elif os.uname()[4] == "armv7l":
			if settings.getSetting('openelecarm7') == "true": acestream_package = acestream_armv7_openelec
			elif settings.getSetting('xbianarm7') == "true": acestream_package = acestream_armv7_xbian
			elif settings.getSetting('mxlinuxarm7') == "true": acestream_package = acestream_mxlinux
		
			ACE_KIT = os.path.join(addonpath,acestream_package.split("/")[-1])
			download_tools().Downloader(acestream_package,ACE_KIT,translate(40026),translate(40000))
			import tarfile
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return

		elif os.uname()[4] == "x86_64":
			if settings.getSetting('openelecx86_64') == "true":
				print("OpenELEC x86_64 Acestream configuration")
				ACE_KIT = os.path.join(addonpath,openeelcx86_64_acestream.split("/")[-1])
				download_tools().Downloader(openeelcx86_64_acestream ,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

			else:
				print("64 bit Linux Disto Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_x64_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_x64_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

		elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
			if settings.getSetting('openeleci386') == "true":
				print("32 bit Openelec Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,openeelcxi386_acestream.split("/")[-1])
				download_tools().Downloader(openeelcxi386_acestream,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return
			else:
				print("32 bit Linux general distro Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_i386_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_i386_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
          #Ace
		SPSC_KIT = os.path.join(addonpath,acestream_windows.split("/")[-1])
		download_tools().Downloader(acestream_windows,SPSC_KIT,translate(40026),translate(40000))
		import shutil
		if xbmcvfs.exists(os.path.join(pastaperfil,"acestream")):
			shutil.rmtree(os.path.join(pastaperfil,"acestream"))
		if xbmcvfs.exists(os.path.join(pastaperfil,"player")):
			shutil.rmtree(os.path.join(pastaperfil,"player"))
		import tarfile
		if tarfile.is_tarfile(SPSC_KIT):
			path_libraries = os.path.join(pastaperfil)
			download_tools().extract(SPSC_KIT,path_libraries)
			download_tools().remove(SPSC_KIT)
		if latest_version: settings.setSetting('acestream_version',value=latest_version)
		return
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x64_acestream
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386_acestream
			available = True
		else:
			available = False
		if available == True:		
			if not xbmcvfs.exists(pastaperfil):
				xbmcvfs.mkdir(pastaperfil)		
			MAC_KIT = os.path.join(addonpath,mac_package.split("/")[-1])
			download_tools().Downloader(mac_package,MAC_KIT,translate(40112),translate(40000))
			import tarfile
			if tarfile.is_tarfile(MAC_KIT):
				path_libraries = os.path.join(pastaperfil)
				download_tools().extract(MAC_KIT,pastaperfil)
				download_tools().remove(MAC_KIT)
				sp_sc_auth = os.path.join(pastaperfil,"sopcast","sp-sc-auth")
				st = os.stat(sp_sc_auth)
				import stat
				os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		else:
			mensagemok(translate(40000),translate(600014))
			return
			
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		print("Starting Acestream Configuration")
		#acestream config for android

		if sopcast_installed == True:
			mensagemok(translate(40000),translate(50018),translate(50019),translate(50020))
			if xbmcvfs.exists(os.path.join("sdcard","Download")):
				pasta = os.path.join("sdcard","Download")
				acefile = os.path.join("sdcard","Download",acestreamengine_apk.split("/")[-1])
			else:
				dialog = xbmcgui.Dialog()
				pasta = dialog.browse(int(0), translate(40190), 'myprograms')
				acefile = os.path.join(pasta,acestreamengine_apk.split("/")[-1])
			download_tools().Downloader(acestreamengine_apk,acefile,translate(40072),translate(40000))
			import tarfile
			if tarfile.is_tarfile(acefile):
				download_tools().extract(acefile,pasta)
				download_tools().remove(acefile)
			xbmc.sleep(2000)
			mensagemok(translate(40000),translate(50021),pasta,translate(50016))
			mensagemok(translate(40000),translate(50022))
			mensagemok(translate(40000),translate(50023),translate(50024),translate(50025))
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
Ejemplo n.º 7
0
def autoconf():
    #Configuration for LINUX
    if xbmc.getCondVisibility(
            'system.platform.linux') and not xbmc.getCondVisibility(
                'system.platform.Android') and not settings.getSetting(
                    'force_android') == "true":
        print("Detected OS: Linux")
        #Linux Armv6
        if os.uname()[4] == "armv6l":
            try:
                if re.search(os.uname()[1], "openelec", re.IGNORECASE):
                    acestream_rpi = acestream_openelec_raspberry
                elif re.search(os.uname()[1], "raspbmc", re.IGNORECASE):
                    acestream_rpi = acestream_generic_raspberry
                elif os.path.isfile("/etc/xbian_version"):
                    acestream_rpi = acestream_generic_raspberry
                elif "ARCH" in os.uname()[2]:
                    acestream_rpi = acestream_generic_raspberry
                    settings.setSetting('python_cmd', value='python2')
                else:
                    mensagemok(translate(40000), translate(400007),
                               translate(400008))
                    OS_list = [
                        "OpenELEC", "Raspbmc", "Xbian", "Pipplware",
                        "Arch Linux Arm"
                    ]
                    url_packagerpi_list = [
                        acestream_openelec_raspberry,
                        acestream_generic_raspberry,
                        acestream_generic_raspberry,
                        acestream_generic_raspberry,
                        acestream_generic_raspberry
                    ]
                    OS_Rpi_choose = xbmcgui.Dialog().select
                    choose = OS_Rpi_choose('Select your OS', OS_list)
                    if choose > -1:
                        acestream_rpi = url_packagerpi_list[choose]
                        if OS_list[choose] == "Arch Linux Arm":
                            settings.setSetting('python_cmd', value='python2')
            except:
                acestream_rpi = ""
            print("Detected linux armv6 - possible Raspberry PI")
            #Sop

            SPSC_KIT = os.path.join(addonpath,
                                    sopcast_raspberry.split("/")[-1])
            download_tools().Downloader(sopcast_raspberry, SPSC_KIT,
                                        translate(40025), translate(40000))
            import tarfile
            if tarfile.is_tarfile(SPSC_KIT):
                path_libraries = os.path.join(pastaperfil, "sopcast")
                download_tools().extract(SPSC_KIT, path_libraries)
                xbmc.sleep(500)
                download_tools().remove(SPSC_KIT)

#Ace
            SPSC_KIT = os.path.join(addonpath, acestream_rpi.split("/")[-1])
            download_tools().Downloader(acestream_rpi, SPSC_KIT,
                                        translate(40026), translate(40000))

            if tarfile.is_tarfile(SPSC_KIT):
                path_libraries = os.path.join(pastaperfil, "acestream")
                download_tools().extract(SPSC_KIT, path_libraries)
                xbmc.sleep(500)
                download_tools().remove(SPSC_KIT)

            settings.setSetting('autoconfig', value='false')

        elif os.uname()[4] == "armv7l":
            if re.search(os.uname()[1], "openelec", re.IGNORECASE):
                OS_Choose = "OpenELEC"
            elif os.path.isfile("/etc/xbian_version"):
                OS_Choose = "Xbian"
            else:
                mensagemok(translate(40000), translate(40109),
                           translate(40110))
                OS_list = ["MXLinux", "OpenELEC", "Xbian"]
                choose = xbmcgui.Dialog().select('Select your OS', OS_list)
                if choose > -1:
                    OS_Choose = OS_list[choose]

            #Linux armv7 configuration according to platform

            #MXLINUX
            if OS_Choose == "MXLinux":
                acestream_installed = False
                sopcast_installed = False
                print("Detected MXLinux armv7")
                SPSC_KIT = os.path.join(addonpath,
                                        sopcast_raspberry.split("/")[-1])
                download_tools().Downloader(sopcast_raspberry, SPSC_KIT,
                                            translate(40025), translate(40000))
                import tarfile
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "sopcast")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                    sopcast_installed = True

                SPSC_KIT = os.path.join(addonpath,
                                        acestream_mxlinux.split("/")[-1])
                download_tools().Downloader(acestream_mxlinux, SPSC_KIT,
                                            translate(40026), translate(40000))
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "acestream")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                    acestream_installed = True
                if acestream_installed and sopcast_installed:
                    settings.setSetting('autoconfig', value='false')

            #OPENELEC

            if OS_Choose == "OpenELEC":
                import tarfile
                acestream_installed = False
                sopcast_installed = False
                print("Openelec armv7 platform detected")
                SPSC_KIT = os.path.join(addonpath,
                                        sopcast_raspberry.split("/")[-1])
                download_tools().Downloader(sopcast_raspberry, SPSC_KIT,
                                            translate(40025), translate(40000))
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "sopcast")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                    sopcast_installed = True
                SPSC_KIT = os.path.join(
                    addonpath,
                    acestream_armv7_openelec.split("/")[-1])
                download_tools().Downloader(acestream_armv7_openelec, SPSC_KIT,
                                            translate(40026), translate(40000))
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "acestream")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                    acestream_installed = True
                if acestream_installed and sopcast_installed:
                    settings.setSetting('autoconfig', value='false')

            #XBIAN
            if OS_Choose == "Xbian":
                import tarfile
                acestream_installed = False
                sopcast_installed = False
                print("Xbian armv7 platform detected")
                SPSC_KIT = os.path.join(addonpath,
                                        sopcast_raspberry.split("/")[-1])
                download_tools().Downloader(sopcast_raspberry, SPSC_KIT,
                                            translate(40025), translate(40000))
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "sopcast")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                    sopcast_installed = True
                SPSC_KIT = os.path.join(addonpath,
                                        acestream_armv7_xbian.split("/")[-1])
                download_tools().Downloader(acestream_armv7_xbian, SPSC_KIT,
                                            translate(40026), translate(40000))
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "acestream")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                    acestream_installed = True
                if acestream_installed and sopcast_installed:
                    settings.setSetting('autoconfig', value='false')

        elif (os.uname()[4] == "x86_64"
              and re.search(os.uname()[1], "openelec", re.IGNORECASE)
              ) or settings.getSetting('openelecx86_64') == "true":
            settings.setSetting('openelecx86_64', value='true')
            print("Detected OpenELEC x86_64")
            SPSC_KIT = os.path.join(addonpath,
                                    openelecx86_64_package.split("/")[-1])
            download_tools().Downloader(openelecx86_64_package, SPSC_KIT,
                                        translate(40112), translate(40000))
            import tarfile
            if tarfile.is_tarfile(SPSC_KIT):
                download_tools().extract(SPSC_KIT, pastaperfil)
                xbmc.sleep(500)
                download_tools().remove(SPSC_KIT)
            settings.setSetting('autoconfig', value='false')

        elif (os.uname()[4] == "i386"
              and re.search(os.uname()[1], "openelec", re.IGNORECASE)) or (
                  os.uname()[4] == "i686"
                  and re.search(os.uname()[1], "openelec", re.IGNORECASE)
              ) or settings.getSetting('openeleci386') == "true":
            settings.setSetting('openeleci386', value='true')
            print("Detected OpenELEC i386")
            SPSC_KIT = os.path.join(addonpath,
                                    openeleci386_package.split("/")[-1])
            download_tools().Downloader(openeleci386_package, SPSC_KIT,
                                        translate(40112), translate(40000))
            import tarfile
            if tarfile.is_tarfile(SPSC_KIT):
                download_tools().extract(SPSC_KIT, pastaperfil)
                xbmc.sleep(500)
                download_tools().remove(SPSC_KIT)
            settings.setSetting('autoconfig', value='false')

        else:
            if os.uname()[4] == "x86_64":
                opcao = xbmcgui.Dialog().yesno(translate(40000),
                                               translate(40113))
                if opcao:
                    settings.setSetting('openelecx86_64', value='true')
                    autoconf()
            elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
                opcao = xbmcgui.Dialog().yesno(translate(40000),
                                               translate(600023))
                if opcao:
                    settings.setSetting('openeleci386', value='true')
                    autoconf()

            else:
                mensagemok(translate(40000), translate(40056))

            #Linux but not openelec i386 nor openelec x86_64 - General Linux platforms configuration

            if settings.getSetting(
                    'openeleci386') == "false" and settings.getSetting(
                        'openelecx86_64') == "false":

                print("Detected Other Linux i386 Plataform")

                #Sop
                #Download and extract sopcast-bundle
                SPSC_KIT = os.path.join(addonpath,
                                        sopcast_linux_generico.split("/")[-1])
                download_tools().Downloader(sopcast_linux_generico, SPSC_KIT,
                                            translate(40025), translate(40000))
                import tarfile
                if tarfile.is_tarfile(SPSC_KIT):
                    path_libraries = os.path.join(pastaperfil, "sopcast")
                    download_tools().extract(SPSC_KIT, path_libraries)
                    xbmc.sleep(500)
                    download_tools().remove(SPSC_KIT)
                #set every single file from the bundle as executable
                path_libraries = os.path.join(pastaperfil, "sopcast")
                dirs, files = xbmcvfs.listdir(path_libraries)
                for ficheiro in files:
                    binary_path = os.path.join(path_libraries, ficheiro)
                    st = os.stat(binary_path)
                    import stat
                    os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
                path_libraries = os.path.join(path_libraries, "lib")
                dirs, files = xbmcvfs.listdir(path_libraries)
                for ficheiro in files:
                    binary_path = os.path.join(path_libraries, ficheiro)
                    st = os.stat(binary_path)
                    import stat
                    os.chmod(binary_path, st.st_mode | stat.S_IEXEC)

    #Ace

                import subprocess
                proc_response = []
                proc = subprocess.Popen(['whereis', 'acestreamengine'],
                                        stdout=subprocess.PIPE)
                for line in proc.stdout:
                    print("Output of acestream subprocess check",
                          line.rstrip())
                    proc_response.append(line.rstrip())
                    if "acestreamengine: /" in str(proc_response):
                        print("Acestream engine is already installed")
                        try:
                            proc.kill()
                            proc.wait()
                        except:
                            pass
                    else:
                        mensagemok(AceStream, translate(40027),
                                   translate(40028) + linkwiki,
                                   translate(40029))
                        sys.exit(0)
                settings.setSetting('autoconfig', value='false')

    elif xbmc.getCondVisibility('system.platform.windows'):
        print("Detected OS: Windows")
        if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
        #Sop
        import ctypes
        is_admin = ctypes.windll.shell32.IsUserAnAdmin() != 0
        if is_admin == False:
            mensagemok(translate(40000), translate(40158), translate(40159))
        else:
            import subprocess
            cmd = ['sc', 'delete', 'sopcastp2p']
            proc = subprocess.Popen(cmd, stdout=subprocess.PIPE, shell=True)
            for line in proc.stdout:
                print("cmd out: " + line.rstrip())
            xbmc.sleep(1000)
            ret = mensagemprogresso.create(translate(40000), translate(40000))
            mensagemprogresso.update(0, translate(40160), "  ")
            xbmc.sleep(1000)
            import _winreg
            aReg = _winreg.ConnectRegistry(None, _winreg.HKEY_LOCAL_MACHINE)
            try:
                aKey = _winreg.OpenKey(aReg,
                                       r'SOFTWARE\SopCast\Player\InstallPath',
                                       0, _winreg.KEY_READ)
                name, value, type = _winreg.EnumValue(aKey, 0)
                sopcast_executable = value
                print("Installation executable of sopcast was found: " +
                      sopcast_executable)
                _winreg.CloseKey(aKey)
                mensagemprogresso.update(10, translate(40160),
                                         translate(40161))
            except:
                sopcast_executable = ""
                mensagemok(translate(40000), translate(40162),
                           translate(40163))
            if not sopcast_executable: pass
            else:
                xbmc.sleep(1000)
                mensagemprogresso.update(20, translate(40164), "  ")
                xbmc.sleep(1000)
                print("Getting windows users IDS")
                aReg = _winreg.ConnectRegistry(None,
                                               _winreg.HKEY_LOCAL_MACHINE)
                aKey = _winreg.OpenKey(
                    aReg,
                    r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList'
                )
                users = []
                for i in range(1024):
                    try:
                        asubkey = _winreg.EnumKey(aKey, i)
                        print(asubkey)
                        aKeydois = _winreg.OpenKey(
                            aReg,
                            os.path.join(
                                'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList',
                                asubkey))
                        val = _winreg.QueryValueEx(aKeydois,
                                                   "ProfileImagePath")
                        try:
                            print(val[0])
                        except:
                            print(
                                "Notice: User with strange characters, print cmd ignored."
                            )
                        if "Windows" in val[0] or "%systemroot%" in val[0]:
                            pass
                        else:
                            users.append(asubkey)
                    except:
                        pass
                if not users:
                    mensagemok(translate(40000), translate(40165))
                else:
                    mensagemprogresso.update(30, translate(40164),
                                             translate(40161))
                    xbmc.sleep(200)
                    mensagemprogresso.update(30, translate(40166), "   ")
                    xbmc.sleep(1000)
                    print("System Users", users)
                    srvany_final_location = os.path.join(
                        sopcast_executable.replace("SopCast.exe", ""),
                        "srvany.exe")
                    srvany_download_location = os.path.join(
                        addonpath, "srvany.exe")
                    srvanytgz_download_location = os.path.join(
                        addonpath, "srvany.tar.gz")
                    download_tools().Downloader(srvany_executable,
                                                srvanytgz_download_location,
                                                translate(40167),
                                                translate(40000))
                    xbmc.sleep(1000)
                    import tarfile
                    if tarfile.is_tarfile(srvanytgz_download_location):
                        path_libraries = addonpath
                        download_tools().extract(srvanytgz_download_location,
                                                 path_libraries)
                        xbmcvfs.copy(srvany_download_location,
                                     srvany_final_location)
                        download_tools().remove(srvanytgz_download_location)
                        download_tools().remove(srvany_download_location)
                    xbmc.sleep(1000)
                    ret = mensagemprogresso.create(translate(40000),
                                                   translate(40000))
                    xbmc.sleep(200)
                    mensagemprogresso.update(35, translate(40168), "  ")
                    xbmc.sleep(1000)
                    import subprocess
                    cmd = [
                        'sc', 'create', 'sopcastp2p', 'binpath=',
                        os.path.join(
                            os.path.join(
                                sopcast_executable.replace("SopCast.exe", "")),
                            'srvany.exe')
                    ]
                    proc = subprocess.Popen(cmd,
                                            stdout=subprocess.PIPE,
                                            shell=True)
                    servicecreator = False
                    for line in proc.stdout:
                        print("cmd out: " + line.rstrip())
                        servicecreator = True
                    if servicecreator == False:
                        mensagemok(translate(40000), translate(40169))
                    else:
                        mensagemprogresso.update(40, translate(40168),
                                                 translate(40161))
                        xbmc.sleep(1000)
                        mensagemprogresso.update(45, translate(40170), "  ")
                        xbmc.sleep(1000)
                        print("Trying to modify regedit....")
                        try:
                            aReg = _winreg.ConnectRegistry(
                                None, _winreg.HKEY_LOCAL_MACHINE)
                            key = _winreg.CreateKey(
                                aReg,
                                r'SYSTEM\CurrentControlSet\Services\sopcastp2p\Parameters'
                            )
                            _winreg.SetValueEx(
                                key, 'AppDirectory', 0, _winreg.REG_SZ,
                                os.path.join(
                                    sopcast_executable.replace(
                                        "SopCast.exe", "")))
                            _winreg.SetValueEx(
                                key, 'Application', 0, _winreg.REG_SZ,
                                os.path.join(
                                    os.path.join(
                                        sopcast_executable.replace(
                                            "SopCast.exe", "")),
                                    "SopCast.exe"))
                            _winreg.SetValueEx(key, 'AppParameters', 0,
                                               _winreg.REG_SZ, "sop://")
                            mensagemprogresso.update(50, translate(40170),
                                                     translate(40161))
                            regedit = True
                        except:
                            mensagemok(translate(40000), translate(40171))
                            regedit = False
                        if regedit == False: pass
                        else:
                            xbmc.sleep(1000)
                            mensagemprogresso.update(50, translate(40172),
                                                     "   ")
                            cmd = ['sc', 'sdshow', 'sopcastp2p']
                            proc = subprocess.Popen(cmd,
                                                    stdout=subprocess.PIPE,
                                                    shell=True)
                            lines = []
                            for line in proc.stdout:
                                print(line.rstrip())
                                if line.rstrip() != "" and "(" in line.rstrip(
                                ):
                                    lines.append(line.rstrip())
                                else:
                                    pass
                            if len(lines) != 1:
                                mensagemok(translate(40000), translate(40173))
                            else:
                                linha_arr = []
                                for user in users:
                                    linha_arr.append('(A;;RPWPCR;;;' + user +
                                                     ')')
                                linha_add = ''
                                for linha in linha_arr:
                                    linha_add += linha
                                print("line peace to add: " + linha_add)
                                linha_final = lines[0].replace(
                                    "S:(", linha_add + "S:(")
                                print("Final line: " + linha_final)
                                permissions = False
                                xbmc.sleep(500)
                                mensagemprogresso.update(
                                    60, translate(40172), translate(40161))
                                xbmc.sleep(500)
                                mensagemprogresso.update(
                                    60, translate(40174), "   ")
                                cmd = [
                                    'sc', 'sdset', 'sopcastp2p', linha_final
                                ]
                                proc = subprocess.Popen(cmd,
                                                        stdout=subprocess.PIPE,
                                                        shell=True)
                                for line in proc.stdout:
                                    print(line.rstrip())
                                    permissions = True
                                if permissions == False:
                                    mensagemok(translate(40000),
                                               translate(40175))
                                else:
                                    mensagemprogresso.update(
                                        70, translate(40174), translate(40161))
                                    xbmc.sleep(1000)
                                    mensagemprogresso.update(
                                        70, translate(40176), "   ")
                                    print(
                                        "Trying to set sopcastp2p service regedit permissions..."
                                    )
                                    download_tools().Downloader(
                                        srvany_permissions,
                                        os.path.join(
                                            pastaperfil,
                                            "sopcastp2p-permissions.txt"),
                                        translate(40177), translate(40000))
                                    xbmc.sleep(500)
                                    ret = mensagemprogresso.create(
                                        translate(40000), translate(40000))
                                    xbmc.sleep(500)
                                    mensagemprogresso.update(
                                        80, translate(40178), "   ")
                                    xbmc.sleep(1000)
                                    cmd = [
                                        'regini',
                                        os.path.join(
                                            pastaperfil,
                                            "sopcastp2p-permissions.txt")
                                    ]
                                    proc = subprocess.Popen(
                                        cmd,
                                        stdout=subprocess.PIPE,
                                        shell=True)
                                    for line in proc.stdout:
                                        print(line.rstrip())
                                    mensagemprogresso.update(
                                        90, translate(40178), translate(40178))
                                    mensagemprogresso.update(
                                        100, translate(40179), "   ")
                                    xbmc.sleep(2000)
                                    mensagemprogresso.close()
#Ace
        SPSC_KIT = os.path.join(addonpath, acestream_windows.split("/")[-1])
        download_tools().Downloader(acestream_windows, SPSC_KIT,
                                    translate(40026), translate(40000))
        import shutil
        if xbmcvfs.exists(os.path.join(pastaperfil, "acestream")):
            shutil.rmtree(os.path.join(pastaperfil, "acestream"))
        if xbmcvfs.exists(os.path.join(pastaperfil, "player")):
            shutil.rmtree(os.path.join(pastaperfil, "player"))
        import tarfile
        if tarfile.is_tarfile(SPSC_KIT):
            path_libraries = os.path.join(pastaperfil)
            download_tools().extract(SPSC_KIT, path_libraries)
            download_tools().remove(SPSC_KIT)
        settings.setSetting('autoconfig', value='false')

    elif xbmc.getCondVisibility('System.Platform.OSX'):
        print("Detected OS: Mac OSX")
        available = False
        if os.uname()[-1] == "x86_64":
            mac_package = osx_x86_64
            available = True
        elif os.uname()[-1] == "i386":
            mac_package = osx_i386
            available = True
        else:
            available = False
        if available == True:
            if not xbmcvfs.exists(pastaperfil):
                xbmcvfs.mkdir(pastaperfil)
            MAC_KIT = os.path.join(addonpath, mac_package.split("/")[-1])
            download_tools().Downloader(mac_package, MAC_KIT, translate(40112),
                                        translate(40000))
            import tarfile
            if tarfile.is_tarfile(MAC_KIT):
                path_libraries = os.path.join(pastaperfil)
                download_tools().extract(MAC_KIT, pastaperfil)
                download_tools().remove(MAC_KIT)
                sp_sc_auth = os.path.join(pastaperfil, "sopcast", "sp-sc-auth")
                st = os.stat(sp_sc_auth)
                import stat
                os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
                settings.setSetting('autoconfig', value='false')
        else:
            mensagemok(translate(40000), translate(600014))
            sys.exit(0)

    elif xbmc.getCondVisibility(
            'System.Platform.Android') or settings.getSetting(
                'force_android') == "true":

        print("Detected OS: Android")
        #Sopcast configuration
        print("Starting SopCast Configuration")

        #Moving sopclient to ext4 hack - tks steeve from xbmctorrent

        sopclient_builtin_location = os.path.join(addonpath, "resources",
                                                  "binaries", "sopclient")

        #Hack to get current xbmc app id
        xbmcfolder = xbmc.translatePath(addonpath).split("/")

        i = 0
        found = False
        sopcast_installed = False

        for folder in xbmcfolder:
            if folder.count('.') >= 2 and folder != addon_id:
                found = True
                break
            else:
                i += 1

        if found == True:
            uid = os.getuid()
            app_id = xbmcfolder[i]
            xbmc_data_path = os.path.join("/data", "data", app_id)
            if os.path.exists(xbmc_data_path) and uid == os.stat(
                    xbmc_data_path).st_uid:
                android_binary_dir = os.path.join(xbmc_data_path, "files",
                                                  "plugin.video.p2p-streams")
                if not os.path.exists(android_binary_dir):
                    os.makedirs(android_binary_dir)
                android_binary_path = os.path.join(android_binary_dir,
                                                   "sopclient")
                if not os.path.exists(android_binary_path) or os.path.getsize(
                        android_binary_path) != os.path.getsize(
                            sopclient_builtin_location):
                    import shutil
                    shutil.copy2(sopclient_builtin_location,
                                 android_binary_path)
                binary_path = android_binary_path
                st = os.stat(binary_path)
                import stat
                os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
                settings.setSetting('android_sopclient', value=binary_path)
                opcao = xbmcgui.Dialog().yesno(translate(40000),
                                               translate(50011),
                                               translate(50012))
                if not opcao:
                    settings.setSetting('external_sopcast', value='1')
                    settings.setSetting('force_android', value='true')
                    sopcast_installed = True
                    mensagemok(translate(40000), translate(50014))
                else:
                    mensagemok(translate(40000), translate(50013))
                    if xbmcvfs.exists(os.path.join("sdcard", "Download")):
                        pasta = os.path.join("sdcard", "Download")
                        sopfile = os.path.join("sdcard", "Download",
                                               sopcast_apk.split("/")[-1])
                    else:
                        dialog = xbmcgui.Dialog()
                        pasta = dialog.browse(int(0), translate(40190),
                                              'myprograms')
                        sopfile = os.path.join(pasta,
                                               sopcast_apk.split("/")[-1])
                    download_tools().Downloader(sopcast_apk, sopfile,
                                                translate(40073),
                                                translate(40000))
                    import tarfile
                    if tarfile.is_tarfile(sopfile):
                        download_tools().extract(sopfile, pasta)
                        download_tools().remove(sopfile)
                    mensagemok(translate(40000), translate(50015), pasta,
                               translate(50016))
                    sopcast_installed = True
                    settings.setSetting('external_sopcast', value='0')
                    mensagemok(translate(40000), translate(50014))

        else:
            mensagemok(translate(40000), translate(50017))

        #acestream config for android

        if sopcast_installed == True:
            mensagemok(translate(40000), translate(50018), translate(50019),
                       translate(50020))
            if xbmcvfs.exists(os.path.join("sdcard", "Download")):
                pasta = os.path.join("sdcard", "Download")
                acefile = os.path.join("sdcard", "Download",
                                       acestreamengine_apk.split("/")[-1])
            else:
                dialog = xbmcgui.Dialog()
                pasta = dialog.browse(int(0), translate(40190), 'myprograms')
                acefile = os.path.join(pasta,
                                       acestreamengine_apk.split("/")[-1])
            download_tools().Downloader(acestreamengine_apk, acefile,
                                        translate(40072), translate(40000))
            import tarfile
            if tarfile.is_tarfile(acefile):
                download_tools().extract(acefile, pasta)
                download_tools().remove(acefile)
            xbmc.sleep(2000)
            mensagemok(translate(40000), translate(50021), pasta,
                       translate(50016))
            mensagemok(translate(40000), translate(50022))
            mensagemok(translate(40000), translate(50023), translate(50024),
                       translate(50025))
            settings.setSetting('autoconfig', value='false')
Ejemplo n.º 8
0
def configure_acestream(latest_version):
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			print("Detected linux armv6 - possible Raspberry PI")
			if settings.getSetting('openelecarm6') == "true": acestream_rpi = acestream_openelec_raspberry
			else: acestream_rpi = acestream_generic_raspberry
			ACE_KIT = os.path.join(addonpath,acestream_rpi.split("/")[-1])
			download_tools().Downloader(acestream_rpi,ACE_KIT,translate(40026),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		#Linux Armv7
		elif os.uname()[4] == "armv7l":
			if settings.getSetting('openelecarm7') == "true": acestream_package = acestream_armv7_openelec
			elif settings.getSetting('xbianarm7') == "true": acestream_package = acestream_armv7_xbian
			elif settings.getSetting('mxlinuxarm7') == "true" or settings.getSetting('jynxbox_arm7') == "true": acestream_package = acestream_mxlinux
		
			ACE_KIT = os.path.join(addonpath,acestream_package.split("/")[-1])
			download_tools().Downloader(acestream_package,ACE_KIT,translate(40026),translate(40000))
			import tarfile
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return

		elif os.uname()[4] == "x86_64":
			if settings.getSetting('openelecx86_64') == "true":
				print("OpenELEC x86_64 Acestream configuration")
				ACE_KIT = os.path.join(addonpath,openeelcx86_64_acestream.split("/")[-1])
				download_tools().Downloader(openeelcx86_64_acestream ,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

			else:
				print("64 bit Linux Disto Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_x64_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_x64_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

		elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
			if settings.getSetting('openeleci386') == "true":
				print("32 bit Openelec Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,openeelcxi386_acestream.split("/")[-1])
				download_tools().Downloader(openeelcxi386_acestream,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return
			else:
				print("32 bit Linux general distro Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_i386_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_i386_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
          #Ace
		SPSC_KIT = os.path.join(addonpath,acestream_windows.split("/")[-1])
		download_tools().Downloader(acestream_windows,SPSC_KIT,translate(40026),translate(40000))
		import shutil
		if xbmcvfs.exists(os.path.join(pastaperfil,"acestream")):
			shutil.rmtree(os.path.join(pastaperfil,"acestream"))
		if xbmcvfs.exists(os.path.join(pastaperfil,"player")):
			shutil.rmtree(os.path.join(pastaperfil,"player"))
		import tarfile
		if tarfile.is_tarfile(SPSC_KIT):
			path_libraries = os.path.join(pastaperfil)
			download_tools().extract(SPSC_KIT,path_libraries)
			download_tools().remove(SPSC_KIT)
		if latest_version: settings.setSetting('acestream_version',value=latest_version)
		return
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x64_acestream
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386_acestream
			available = True
		else:
			available = False
		if available == True:			
			MAC_KIT = os.path.join('/Applications',mac_package.split("/")[-1])
			if not xbmcvfs.exists(os.path.join('/Applications','Ace Stream.app')):
				download_tools().Downloader(mac_package,MAC_KIT,translate(40026),translate(40000))
				if xbmcvfs.exists(MAC_KIT):
					xbmc.sleep(1000)
					cmd = 'unzip /Applications/AceStreamWineOSX.zip'
					zipa = subprocess.Popen(cmd,shell=True)
					cmd = 'chmod -R 755 /Applications/Ace\ Stream.app'
					print cmd
					chmod = subprocess.Popen(cmd,shell=True)
					try: os.remove(MAC_KIT)
					except: pass
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		else:
			mensagemok(translate(40000),translate(600014))
			return
			
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		print("Starting Acestream Configuration")
		#acestream config for android
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
		#Hack to get xbmc app id
		xbmcfolder=xbmc.translatePath(addonpath).split("/")
		
		i = 0
		found = False
		sopcast_installed = False
		
		for folder in xbmcfolder:
			if folder.count('.') >= 2 and folder != addon_id :
				found = True
				break
			else:
				i+=1

		if found == True:
			uid = os.getuid()
			app_id = xbmcfolder[i]
			settings.setSetting('app_id',app_id)
			#Acestreamconfiguration for android starts here
			if "arm" in os.uname()[4]:
				acebundle = os.path.join(pastaperfil,android_aceengine_arm.split("/")[-1])
				download_tools().Downloader(android_aceengine_arm,acebundle,translate(70014),translate(40000))
			else:
				acebundle = os.path.join(pastaperfil,android_aceengine_x86.split("/")[-1])
				download_tools().Downloader(android_aceengine_x86,acebundle,translate(70014),translate(40000))
			import tarfile
			if tarfile.is_tarfile(acebundle):
				download_tools().extract(acebundle,pastaperfil)
				download_tools().remove(acebundle)
			orgacestreamenginefolder = os.path.join(pastaperfil,"org.acestream.engine")
			xbmc_data_path = os.path.join("/data", "data", app_id)
			if os.path.exists(xbmc_data_path) and uid == os.stat(xbmc_data_path).st_uid:
				android_binary_dir = os.path.join(xbmc_data_path, "files", "plugin.video.p2p-streams")
				if not os.path.exists(android_binary_dir): os.makedirs(android_binary_dir)
            		android_acestream_folder = os.path.join(android_binary_dir,"org.acestream.engine")
            		if not os.path.exists(android_acestream_folder): os.makedirs(android_acestream_folder)
            		xbmc.sleep(200)
            		recursive_overwrite(orgacestreamenginefolder, android_acestream_folder, ignore=None)
            		pythonbin = os.path.join(android_acestream_folder,"files","python","bin","python")
            		st = os.stat(pythonbin)
            		import stat
            		os.chmod(pythonbin, st.st_mode | stat.S_IEXEC)
            		try: xbmcvfs.mkdir(os.path.join('/sdcard','org.acestream.engine'))
            		except: pass
			opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70015),translate(70016))
			if not opcao:
				settings.setSetting('engine_app','0')
			else:
				mensagemok(translate(40000),translate(50018),translate(50019),translate(50020))
				if xbmcvfs.exists(os.path.join("sdcard","Download")):
					pasta = os.path.join("sdcard","Download")
					if "arm" in os.uname()[4]: acefile = os.path.join("sdcard","Download",acestreamengine_apk_arm.split("/")[-1])
					else: acefile = os.path.join("sdcard","Download",acestreamengine_apk_x86.split("/")[-1])
				else:
					dialog = xbmcgui.Dialog()
					pasta = dialog.browse(int(0), translate(40190), 'myprograms')
					if "arm" in os.uname()[4]: acefile = os.path.join(pasta,acestreamengine_apk_arm.split("/")[-1])
					else: acefile = os.path.join(pasta,acestreamengine_apk_x86.split("/")[-1])
				if "arm" in os.uname()[4]: download_tools().Downloader(acestreamengine_apk_arm,acefile,translate(40072),translate(40000))
				else: download_tools().Downloader(acestreamengine_apk_x86,acefile,translate(40072),translate(40000))
				import tarfile
				if tarfile.is_tarfile(acefile):
					download_tools().extract(acefile,pasta)
					download_tools().remove(acefile)
				xbmc.sleep(2000)
				mensagemok(translate(40000),translate(50021),pasta,translate(50016))
				mensagemok(translate(40000),translate(50023),translate(50024),translate(50025))
				settings.setSetting('engine_app','1')
			opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70017),translate(70018))
			if opcao:
				if xbmcvfs.exists(os.path.join("sdcard","Download")):
					pasta = os.path.join("sdcard","Download")
					if "arm" in os.uname()[4]: acefile = os.path.join("sdcard","Download",android_aceplayer_arm.split("/")[-1])
					else: os.path.join("sdcard","Download",android_aceplayer_x86.split("/")[-1])
				else:
					dialog = xbmcgui.Dialog()
					pasta = dialog.browse(int(0), translate(40190), 'myprograms')
					if "arm" in os.uname()[4]: acefile = os.path.join(pasta,acestreamengine_apk_arm.split("/")[-1])
					else: acefile = os.path.join(pasta,acestreamengine_apk_x86.split("/")[-1])
				if "arm" in os.uname()[4]: download_tools().Downloader(android_aceplayer_arm,acefile,translate(70019),translate(40000))
				else: download_tools().Downloader(android_aceplayer_x86,acefile,translate(70019),translate(40000))
				import tarfile
				if tarfile.is_tarfile(acefile):
					download_tools().extract(acefile,pasta)
					download_tools().remove(acefile)
				xbmc.sleep(2000)
				mensagemok(translate(40000),translate(70020),pasta,translate(50016))
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(70021))
				if opcao:
					settings.setSetting('engine_app','2')							
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			mensagemok(translate(40000),translate(50022))
			return			
		else:
			mensagemok(translate(40000),translate(50017))
			return	
Ejemplo n.º 9
0
def configure_sopcast(latest_version):
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			print("Detected linux armv6 - possible Raspberry PI")
			#Sop
			SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
			download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(SPSC_KIT):
				path_libraries = os.path.join(pastaperfil,"sopcast")
				download_tools().extract(SPSC_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)
			if latest_version: settings.setSetting('sopcast_version',value=latest_version)
			return

		elif os.uname()[4] == "armv7l":
			if settings.getSetting('jynxbox_arm7') == "true":
				SPSC_KIT = os.path.join(addonpath,sopcast_jynxbox.split("/")[-1])
				download_tools().Downloader(sopcast_jynxbox,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil)
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return
			else:
				SPSC_KIT = os.path.join(addonpath,sopcast_raspberry.split("/")[-1])
				download_tools().Downloader(sopcast_raspberry,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					path_libraries = os.path.join(pastaperfil,"sopcast")
					download_tools().extract(SPSC_KIT,path_libraries)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return

		elif os.uname()[4] == "x86_64":
			generic = False
			if settings.getSetting('openelecx86_64') == "true":
				print("Detected OpenELEC x86_64")
				SPSC_KIT = os.path.join(addonpath,openelecx86_64_sopcast.split("/")[-1])
				download_tools().Downloader(openelecx86_64_sopcast,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					download_tools().extract(SPSC_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return
			else: generic = True
		elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
			generic = False
			if settings.getSetting('openeleci386') == "true":
				SPSC_KIT = os.path.join(addonpath,openelecxi386_sopcast.split("/")[-1])
				download_tools().Downloader(openelecxi386_sopcast,SPSC_KIT,translate(40025),translate(40000))
				import tarfile
				if tarfile.is_tarfile(SPSC_KIT):
					download_tools().extract(SPSC_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(SPSC_KIT)
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return
			else: generic = True
		if generic == True:
			SPSC_KIT = os.path.join(addonpath,sopcast_linux_generico.split("/")[-1])
			download_tools().Downloader(sopcast_linux_generico,SPSC_KIT,translate(40025),translate(40000))
			import tarfile
			if tarfile.is_tarfile(SPSC_KIT):
				path_libraries = os.path.join(pastaperfil,"sopcast")
				download_tools().extract(SPSC_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(SPSC_KIT)
			#set every single file from the bundle as executable
			path_libraries = os.path.join(pastaperfil,"sopcast")
			dirs, files = xbmcvfs.listdir(path_libraries)
			for ficheiro in files:
				binary_path = os.path.join(path_libraries,ficheiro)
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
			path_libraries = os.path.join(path_libraries,"lib")
			dirs, files = xbmcvfs.listdir(path_libraries)
			for ficheiro in files:
				binary_path = os.path.join(path_libraries,ficheiro)
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('sopcast_version',value=latest_version)
			return


	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
        	#Sop
		import ctypes
                is_admin=ctypes.windll.shell32.IsUserAnAdmin() != 0
                if is_admin == False:
                    mensagemok(translate(40000),translate(40158),translate(40159))
                else:
		    import subprocess
                    cmd = ['sc','delete','sopcastp2p']
                    proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                    for line in proc.stdout:
                        print("cmd out: " + line.rstrip())
                    xbmc.sleep(1000)
                    ret = mensagemprogresso.create(translate(40000),translate(40000))
                    mensagemprogresso.update(0,translate(40160),"  ")
                    xbmc.sleep(1000)
                    import _winreg
                    aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                    try:
                        aKey = _winreg.OpenKey(aReg, r'SOFTWARE\SopCast\Player\InstallPath',0, _winreg.KEY_READ)
                        name, value, type = _winreg.EnumValue(aKey, 0)
                        sopcast_executable = value
                        print("Installation executable of sopcast was found: " + sopcast_executable)
                        _winreg.CloseKey(aKey)
                        mensagemprogresso.update(10,translate(40160),translate(40161))
                    except:
                        sopcast_executable = ""
                        mensagemok(translate(40000),translate(40162),translate(40163))
                    if not sopcast_executable: pass
                    else:
                        xbmc.sleep(1000)
                        mensagemprogresso.update(20,translate(40164),"  ")
                        xbmc.sleep(1000)
                        print ("Getting windows users IDS")
                        aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                        aKey = _winreg.OpenKey(aReg, r'SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList')
                        users = []
                        for i in range(1024):
                            try:
                                asubkey=_winreg.EnumKey(aKey,i)
                                print(asubkey)
                                aKeydois = _winreg.OpenKey(aReg, os.path.join('SOFTWARE\Microsoft\Windows NT\CurrentVersion\ProfileList',asubkey))
                                val=_winreg.QueryValueEx(aKeydois, "ProfileImagePath")
                                try:
                                    print(val[0])
                                except:
                                    print("Notice: User with strange characters, print cmd ignored.")
                                if "Windows" in val[0] or "%systemroot%" in val[0]:
                                    pass
                                else:
                                    users.append(asubkey)
                            except:
                                pass
                        if not users:
                            mensagemok(translate(40000),translate(40165))
                        else:
                            mensagemprogresso.update(30,translate(40164),translate(40161))
                            xbmc.sleep(200)
                            mensagemprogresso.update(30,translate(40166),"   ")
                            xbmc.sleep(1000)
                            print("System Users", users)
                            srvany_final_location = os.path.join(sopcast_executable.replace("SopCast.exe",""),"srvany.exe")
                            srvany_download_location = os.path.join(addonpath,"srvany.exe")
                            srvanytgz_download_location = os.path.join(addonpath,"srvany.tar.gz")                            
                            download_tools().Downloader(srvany_executable,srvanytgz_download_location,translate(40167),translate(40000)) 
                            xbmc.sleep(1000)
                            import tarfile
                            if tarfile.is_tarfile(srvanytgz_download_location):
                                path_libraries = addonpath
                                download_tools().extract(srvanytgz_download_location,path_libraries)
                                xbmcvfs.copy(srvany_download_location,srvany_final_location)
                                download_tools().remove(srvanytgz_download_location)
                                download_tools().remove(srvany_download_location)
                            xbmc.sleep(1000)
                            ret = mensagemprogresso.create(translate(40000),translate(40000))
                            xbmc.sleep(200)
                            mensagemprogresso.update(35,translate(40168),"  ")
                            xbmc.sleep(1000)
                            import subprocess
                            cmd = ['sc','create','sopcastp2p','binpath=',os.path.join(os.path.join(sopcast_executable.replace("SopCast.exe","")),'srvany.exe')]
                            proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                            servicecreator = False
                            for line in proc.stdout:
                                print ("cmd out: " + line.rstrip())
                                servicecreator = True
                            if servicecreator == False:
                                mensagemok(translate(40000),translate(40169))
                            else:
                                mensagemprogresso.update(40,translate(40168),translate(40161))
                                xbmc.sleep(1000)
                                mensagemprogresso.update(45,translate(40170),"  ")
                                xbmc.sleep(1000)
                                print("Trying to modify regedit....")
                                try:
                                    aReg = _winreg.ConnectRegistry(None,_winreg.HKEY_LOCAL_MACHINE)
                                    key = _winreg.CreateKey(aReg, r'SYSTEM\CurrentControlSet\Services\sopcastp2p\Parameters')
                                    _winreg.SetValueEx(key, 'AppDirectory', 0, _winreg.REG_SZ, os.path.join(sopcast_executable.replace("SopCast.exe","")))
                                    _winreg.SetValueEx(key, 'Application', 0, _winreg.REG_SZ, os.path.join(os.path.join(sopcast_executable.replace("SopCast.exe","")),"SopCast.exe"))
                                    _winreg.SetValueEx(key, 'AppParameters', 0, _winreg.REG_SZ, "sop://")
                                    mensagemprogresso.update(50,translate(40170), translate(40161))
                                    regedit = True
                                except:
                                    mensagemok(translate(40000),translate(40171))
                                    regedit = False
                                if regedit == False: pass
                                else:
                                    xbmc.sleep(1000)
                                    mensagemprogresso.update(50,translate(40172), "   ")
                                    cmd = ['sc','sdshow','sopcastp2p']
                                    proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                    lines = []
                                    for line in proc.stdout:
					print(line.rstrip())
                                        if line.rstrip() != "" and "(" in line.rstrip(): lines.append(line.rstrip())
                                        else: pass
                                    if len(lines) != 1: mensagemok(translate(40000),translate(40173))
                                    else:
                                        linha_arr = []
                                        for user in users:
                                            linha_arr.append('(A;;RPWPCR;;;' + user + ')')
                                        linha_add = ''
                                        for linha in linha_arr:
                                            linha_add += linha
                                        print("line peace to add: " + linha_add)
                                        linha_final = lines[0].replace("S:(",linha_add + "S:(")
                                        print("Final line: " + linha_final)
                                        permissions = False
                                        xbmc.sleep(500)
                                        mensagemprogresso.update(60,translate(40172), translate(40161))
                                        xbmc.sleep(500)
                                        mensagemprogresso.update(60,translate(40174), "   ")
                                        cmd = ['sc','sdset','sopcastp2p',linha_final]
                                        proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                        for line in proc.stdout:
                                            print(line.rstrip())
                                            permissions = True
                                        if permissions == False: mensagemok(translate(40000),translate(40175))
                                        else:
                                            mensagemprogresso.update(70,translate(40174), translate(40161))
                                            xbmc.sleep(1000)
                                            mensagemprogresso.update(70,translate(40176), "   ")
                                            print("Trying to set sopcastp2p service regedit permissions...")
                                            download_tools().Downloader(srvany_permissions,os.path.join(pastaperfil,"sopcastp2p-permissions.txt"),translate(40177),translate(40000))
                                            xbmc.sleep(500)
                                            ret = mensagemprogresso.create(translate(40000),translate(40000))
                                            xbmc.sleep(500)
                                            mensagemprogresso.update(80,translate(40178), "   ")
                                            xbmc.sleep(1000)
                                            cmd = ['regini',os.path.join(pastaperfil,"sopcastp2p-permissions.txt")]
                                            proc = subprocess.Popen(cmd,stdout=subprocess.PIPE,shell=True)
                                            for line in proc.stdout:
                                                print(line.rstrip())
                                            mensagemprogresso.update(90,translate(40178), translate(40178))
                                            mensagemprogresso.update(100,translate(40179), "   ")
                                            xbmc.sleep(2000)
                                            mensagemprogresso.close()
                                            if latest_version: settings.setSetting('sopcast_version',value=latest_version)
                                            return
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x64_sopcast
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386_sopcast
			available = True
		else:
			available = False
		if available == True:		
			if not xbmcvfs.exists(pastaperfil):
				xbmcvfs.mkdir(pastaperfil)		
			MAC_KIT = os.path.join(addonpath,mac_package.split("/")[-1])
			download_tools().Downloader(mac_package,MAC_KIT,translate(40025),translate(40000))
			import tarfile
			if tarfile.is_tarfile(MAC_KIT):
				path_libraries = os.path.join(pastaperfil)
				download_tools().extract(MAC_KIT,pastaperfil)
				download_tools().remove(MAC_KIT)
				sp_sc_auth = os.path.join(pastaperfil,"sopcast","sp-sc-auth")
				st = os.stat(sp_sc_auth)
				import stat
				os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('sopcast_version',value=latest_version)
			return
		else:
			mensagemok(translate(40000),translate(600014))
			return
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		#Sopcast configuration
		print("Starting SopCast Configuration")

		#Moving sopclient to ext4 hack - tks steeve from xbmctorrent

		sopclient_builtin_location = os.path.join(addonpath,"resources","binaries","sopclient")

		#Hack to get current xbmc app id
		xbmcfolder=xbmc.translatePath(addonpath).split("/")

		i = 0
		found = False
		sopcast_installed = False
		
		for folder in xbmcfolder:
			if folder.count('.') >= 2 and folder != addon_id :
				found = True
				break
			else:
				i+=1

		if found == True:
			uid = os.getuid()
			app_id = xbmcfolder[i]
			xbmc_data_path = os.path.join("/data", "data", app_id)
			if os.path.exists(xbmc_data_path) and uid == os.stat(xbmc_data_path).st_uid:
				android_binary_dir = os.path.join(xbmc_data_path, "files", "plugin.video.p2p-streams")
				if not os.path.exists(android_binary_dir):
            				os.makedirs(android_binary_dir)
				android_binary_path = os.path.join(android_binary_dir, "sopclient")
		        	if not os.path.exists(android_binary_path) or os.path.getsize(android_binary_path) != os.path.getsize(sopclient_builtin_location):
					import shutil
					shutil.copy2(sopclient_builtin_location, android_binary_path)
				binary_path = android_binary_path
				st = os.stat(binary_path)
				import stat
				os.chmod(binary_path, st.st_mode | stat.S_IEXEC)
				settings.setSetting('android_sopclient',value=binary_path)
				opcao= xbmcgui.Dialog().yesno(translate(40000), translate(50011),translate(50012))
				if not opcao:
					settings.setSetting('external-sopcast',value='1')
					settings.setSetting('force_android',value='true')
					sopcast_installed = True
					mensagemok(translate(40000),translate(50014))
				else:
					mensagemok(translate(40000),translate(50013))
					if xbmcvfs.exists(os.path.join("sdcard","Download")):
						pasta = os.path.join("sdcard","Download")
						sopfile = os.path.join("sdcard","Download",sopcast_apk.split("/")[-1])
					else:
						dialog = xbmcgui.Dialog()
						pasta = dialog.browse(int(0), translate(40190), 'myprograms')
						sopfile = os.path.join(pasta,sopcast_apk.split("/")[-1])
					download_tools().Downloader(sopcast_apk,sopfile,translate(40073),translate(40000))
					import tarfile
					if tarfile.is_tarfile(sopfile):
						download_tools().extract(sopfile,pasta)
						download_tools().remove(sopfile)
					mensagemok(translate(40000),translate(50015),pasta,translate(50016))
					sopcast_installed = True
					settings.setSetting('external-sopcast',value='0')
					mensagemok(translate(40000),translate(50014))
				if latest_version: settings.setSetting('sopcast_version',value=latest_version)
				return

		else:
			mensagemok(translate(40000),translate(50017))
			return
Ejemplo n.º 10
0
def advanced_menu():
	addLink('[COLOR orange]XBMC Advancedsettings.xml:[/COLOR]','',addonpath + art + 'settings_menu.png')
	lock_file = xbmc.translatePath('special://temp/'+ 'ts.lock')
	if xbmcvfs.exists(lock_file):
		addDir(translate(40068),MainURL,306,'',2,False)
	userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8')))
	advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml')
	advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml')
	addDir(translate(40058),MainURL,301,'p2p',2,False)
	if xbmcvfs.exists(advancedsettings_var):
		addDir(translate(40063),MainURL,303,'p2p',2,False)
		addDir(translate(40065),MainURL,304,'p2p',2,False)
	if xbmcvfs.exists(advancedsettingsbackup_var):
		addDir(translate(40061),MainURL,302,'p2p',2,False)
	addLink('','','p2p')
	if xbmcvfs.exists(advancedsettings_var):
		content = readfile(advancedsettings_var)
		match = re.compile('<cachemembuffersize>(.+?)</cachemembuffersize>').findall(content)
		if match:
			if match[0] != '252420': valuebuff = '[COLOR red]' + match[0] + '[/COLOR]'
			else : valuebuff =  '[COLOR green]' + match[0] + '[/COLOR]'
			addLink(translate(40067) +valuebuff+']','','p2p')
			addLink('','','p2p')
	#Apply shutdown hooks
	addLink('[COLOR orange]'+translate(70025)+'[/COLOR]','',addonpath + art + 'settings_menu.png')
	addDir(translate(70026),MainURL,310,'p2p',2,False)
	#Change engine settings from xbmc menus
	eligible = False
	if xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('force_android') != "true":
		if os.uname()[4] == "armv6l" or os.uname()[4] == "armv7l":
			eligible = True
	elif xbmc.getCondVisibility('system.platform.OSX'): eligible = True
	elif settings.getSetting('openeleci386') == "true": eligible = False
	elif settings.getSetting('force_android') == "true": eligible = False
	else: eligible = False
	if eligible and xbmcvfs.exists(os.path.join(pastaperfil,'acestream','ace','ACEStream','values')):
		addLink('[COLOR orange]Acestream engine settings:[/COLOR]','',addonpath + art + 'settings_menu.png')
		acestream_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
		acestream_cache_size = str(int(getDirectorySize(acestream_cachefolder))/(1024*1024))
		addDir(translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]',acestream_cachefolder,307,'p2p',1,False)
		try:
			porta = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","port.txt"))
		except: porta = "N/A"
		try:
			acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','sessconfig.pickle')
			sessconfig = readfile(acestream_settings_file)
			portvector = re.compile("S'minport'\np(\d+)\nI(\d+)\n").findall(sessconfig)
			maxport = re.compile("S'maxport'\np(\d+)\nI(\d+)\n").findall(sessconfig)
		except: portvector = [];maxport=[]
		addDir(translate(600015) +"[COLOR orange][ " + str(int(porta))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","port.txt") + '|' + str(portvector)+'|'+str(maxport),305,'p2p',2,False)
		try:
			vodbuffer = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","vodbuffer.txt"))
		except: vodbuffer = "N/A"
		addDir(translate(600016) + "[COLOR orange][ " + str(int(vodbuffer))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","vodbuffer.txt"),305,'p2p',2,False)
		try:
			livebuffer = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","livebuffer.txt"))
		except: livebuffer = "N/A"
		addDir(translate(600017)+"[COLOR orange][ " + str(int(livebuffer))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","livebuffer.txt"),305,'p2p',2,False)
		try:
			downloadlimit = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","downloadlimit.txt"))
		except: downloadlimit = "N/A"
		addDir(translate(600018) +"[COLOR orange][ " + str(int(downloadlimit))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","downloadlimit.txt"),305,'p2p',2,False)
		try:
			uploadlimit = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","uploadlimit.txt"))
		except: uploadlimit = "N/A"
		addDir(translate(600019)+"[COLOR orange][ " + str(int(uploadlimit))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","uploadlimit.txt"),305,'p2p',2,False)
		try:
			maxconnections = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnections.txt"))
		except: maxconnections = "N/A"
		addDir(translate(600020)+"[COLOR orange][ " + str(int(maxconnections))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnections.txt"),305,'p2p',2,False)
		try:
			maxconnectionsstream = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnectionsstream.txt"))
		except: maxconnectionsstream = "N/A"
		addDir(translate(600021)+"[COLOR orange][ " + str(int(maxconnectionsstream))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnectionsstream.txt"),305,'',2,False)
	elif eligible and not xbmcvfs.exists(os.path.join(pastaperfil,'acestream','ace','ACEStream','values')):
		addLink("[COLOR red][B]"+translate(600027)+"[/COLOR][/B]","",addonpath + art + 'processwarning.png')
	else:
		pass
	if (not eligible and xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('ace_cmd') == "0") or (not eligible and xbmc.getCondVisibility('system.platform.windows')) or (not eligible and xbmc.getCondVisibility('system.platform.Android') and settings.getSetting('engine_app') == "0") or (settings.getSetting('force_android') == "true" and settings.getSetting('engine_app') == "0"):
		if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'):
			default_acefolder = os.path.join(os.getenv("HOME"),'.ACEStream')
			default_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
			pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Linux/playerconf.pickle'
			if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
			else: acestream_cachefolder = settings.getSetting('acestream_cachefolder')
			acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','playerconf.pickle')
		elif xbmc.getCondVisibility('system.platform.Android'):
			default_acefolder = os.path.join('/sdcard','.ACEStream')
			default_cachefolder = os.path.join('/sdcard','.ACEStream','.acestream_cache')
			pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Android/playerconf.pickle'
			if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join('/sdcard','.ACEStream','.acestream_cache')
			else: acestream_cachefolder = settings.getSetting('acestream_cachefolder')
			acestream_settings_file = os.path.join('/sdcard','.ACEStream','playerconf.pickle')
		elif xbmc.getCondVisibility('system.platform.windows'):
			default_acefolder = os.path.join(os.getenv("APPDATA"),".ACEStream")
			pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Windows/playerconf.pickle'
			default_cachefolder = os.path.join(os.getenv("SystemDrive"),'\_acestream_cache_')
			acestream_cachefolder = default_cachefolder
			acestream_settings_file = os.path.join(os.getenv("APPDATA"),".ACEStream","playerconf.pickle")
		#workaround to keep settings file in place if they get deleted
		if not xbmcvfs.exists(default_acefolder): xbmcvfs.mkdir(default_acefolder)
		if not xbmcvfs.exists(default_cachefolder): xbmcvfs.mkdir(default_cachefolder)
		if not xbmcvfs.exists(acestream_settings_file):
			local_file = os.path.join(default_acefolder,pickle_repo.split("/")[-1])
			download_tools().Downloader(pickle_repo,local_file,'',translate(40000))
			xbmc.sleep(200)
			if xbmcvfs.exists(acestream_settings_file):
				settings_text = readfile(acestream_settings_file)
				save(acestream_settings_file,settings_text.replace('my_cache_folder',default_cachefolder))
		if xbmcvfs.exists(acestream_settings_file) and xbmcvfs.exists(acestream_cachefolder):
			addLink('[COLOR orange]Acestream engine settings:[/COLOR]','',addonpath + art + 'settings_menu.png')
			xbmc.sleep(200)
			acestream_cache_size = str(int(getDirectorySize(acestream_cachefolder))/(1024*1024))
			addDir(translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]',acestream_cachefolder,307,'p2p',1,False)
			settings_content = readfile(acestream_settings_file)
			number_of_settings = re.compile('p(\d+)\n').findall(settings_content)
			cachefoldersetting = re.compile("'download_dir'\np\d+\n.+?/(.+?)\n").findall(settings_content)
			if not cachefoldersetting:
				if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'):
					cachefoldersetting = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
					settings.setSetting('acestream_cachefolder',cachefoldersetting)
				elif xbmc.getCondVisibility('system.platform.windows'):
					cachefoldersetting = os.path.join(os.getenv("SystemDrive"),'_acestream_cache_')
					settings.setSetting('acestream_cachefolder',cachefoldersetting)
				else:
					cachefoldersetting = os.path.join('/sdcard','.ACEStream','cache')
					settings.setSetting('acestream_cachefolder',cachefoldersetting)
			else: 
				cachefoldersetting = '/' + cachefoldersetting[0].replace("'","")
				settings.setSetting('acestream_cachefolder',cachefoldersetting)
			if cachefoldersetting: addDir(translate(70013)+"[COLOR orange][ " + cachefoldersetting + " ][/COLOR]",str(cachefoldersetting),309,'p2p',2,False)
			else: addDir(translate(70013)+"[COLOR orange][" + cachefoldersetting + "][/COLOR]",cachefoldersetting,309,'p2p',2,False)
			livebuffervalue = re.compile("S'live_buffer_time'\np(\d+)\nI(\d+)").findall(settings_content)
			if livebuffervalue:	addDir(translate(600017)+"[COLOR orange][ " + livebuffervalue[0][1] + " ][/COLOR]",'live_buffer_time|' + str(livebuffervalue)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600017)+"[COLOR orange][3][/COLOR]",'live_buffer_time|'+str(len(number_of_settings)),308,'p2p',2,False)
			vodbuffervalue = re.compile("S'player_buffer_time'\np(\d+)\nI(\d+)").findall(settings_content)
			if vodbuffervalue: addDir(translate(600016)+"[COLOR orange][ " + vodbuffervalue[0][1] + " ][/COLOR]",'player_buffer_time|'+str(vodbuffervalue)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600016)+"[COLOR orange][10][/COLOR]",'player_buffer_time|'+str(len(number_of_settings)),308,'p2p',2,False)
			downloadlimit = re.compile("S'total_max_download_rate'\np(\d+)\nI(\d+)").findall(settings_content)
			if downloadlimit: addDir(translate(600018)+"[COLOR orange][ " + downloadlimit[0][1] + " ][/COLOR]",'total_max_download_rate|'+str(downloadlimit)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600018)+"[COLOR orange][0][/COLOR]",'total_max_download_rate|'+str(len(number_of_settings)),308,'p2p',2,False)
			uploadlimit = re.compile("S'total_max_upload_rate'\np(\d+)\nI(\d+)").findall(settings_content)
			if uploadlimit: addDir(translate(600019)+"[COLOR orange][ " + uploadlimit[0][1] + " ][/COLOR]",'total_max_upload_rate|'+str(uploadlimit)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600019)+"[COLOR orange][0][/COLOR]",'total_max_upload_rate|'+str(len(number_of_settings)),308,'p2p',2,False)
			maxconnection_per_stream = re.compile("S'max_peers'\np(\d+)\nI(\d+)").findall(settings_content)
			if maxconnection_per_stream: addDir(translate(600021)+"[COLOR orange][ " + maxconnection_per_stream[0][1] + " ][/COLOR]",'max_peers|'+str(maxconnection_per_stream)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600021)+"[COLOR orange][50][/COLOR]",'max_peers|'+str(len(number_of_settings)),308,'p2p',2,False)
def advanced_menu():
	addLink('[COLOR orange]XBMC Advancedsettings.xml:[/COLOR]','',addonpath + art + 'settings_menu.png')
	lock_file = xbmc.translatePath('special://temp/'+ 'ts.lock')
	if xbmcvfs.exists(lock_file):
		addDir(translate(40068),MainURL,306,'',2,False)
	userdatapath = xbmc.translatePath(os.path.join('special://home/userdata'.decode('utf-8'),''.decode('utf-8')))
	advancedsettings_var = os.path.join(userdatapath,'advancedsettings.xml')
	advancedsettingsbackup_var = os.path.join(userdatapath,'advancedsettingsbackup.xml')
	addDir(translate(40058),MainURL,301,'p2p',2,False)
	if xbmcvfs.exists(advancedsettings_var):
		addDir(translate(40063),MainURL,303,'p2p',2,False)
		addDir(translate(40065),MainURL,304,'p2p',2,False)
	if xbmcvfs.exists(advancedsettingsbackup_var):
		addDir(translate(40061),MainURL,302,'p2p',2,False)
	addLink('','','p2p')
	if xbmcvfs.exists(advancedsettings_var):
		content = readfile(advancedsettings_var)
		match = re.compile('<cachemembuffersize>(.+?)</cachemembuffersize>').findall(content)
		if match:
			if match[0] != '252420': valuebuff = '[COLOR red]' + match[0] + '[/COLOR]'
			else : valuebuff =  '[COLOR green]' + match[0] + '[/COLOR]'
			addLink(translate(40067) +valuebuff+']','','p2p')
			addLink('','','p2p')
	#Apply shutdown hooks
	addLink('[COLOR orange]'+translate(70025)+'[/COLOR]','',addonpath + art + 'settings_menu.png')
	addDir(translate(70026),MainURL,310,'p2p',2,False)
	#Change engine settings from xbmc menus
	eligible = False
	if xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('force_android') != "true":
		if os.uname()[4] == "armv6l" or os.uname()[4] == "armv7l":
			eligible = True
	elif xbmc.getCondVisibility('system.platform.OSX'): eligible = False
	elif settings.getSetting('openeleci386') == "true": eligible = False
	elif settings.getSetting('force_android') == "true": eligible = False
	else: eligible = False
	if eligible and xbmcvfs.exists(os.path.join(pastaperfil,'acestream','ace','ACEStream','values')):
		addLink('[COLOR orange]Acestream engine settings:[/COLOR]','',addonpath + art + 'settings_menu.png')
		acestream_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
		acestream_cache_size = str(int(getDirectorySize(acestream_cachefolder))/(1024*1024))
		addDir(translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]',acestream_cachefolder,307,'p2p',1,False)
		try:
			porta = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","port.txt"))
		except: porta = "N/A"
		try:
			acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','sessconfig.pickle')
			sessconfig = readfile(acestream_settings_file)
			portvector = re.compile("S'minport'\np(\d+)\nI(\d+)\n").findall(sessconfig)
			maxport = re.compile("S'maxport'\np(\d+)\nI(\d+)\n").findall(sessconfig)
		except: portvector = [];maxport=[]
		addDir(translate(600015) +"[COLOR orange][ " + str(int(porta))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","port.txt") + '|' + str(portvector)+'|'+str(maxport),305,'p2p',2,False)
		try:
			vodbuffer = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","vodbuffer.txt"))
		except: vodbuffer = "N/A"
		addDir(translate(600016) + "[COLOR orange][ " + str(int(vodbuffer))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","vodbuffer.txt"),305,'p2p',2,False)
		try:
			livebuffer = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","livebuffer.txt"))
		except: livebuffer = "N/A"
		addDir(translate(600017)+"[COLOR orange][ " + str(int(livebuffer))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","livebuffer.txt"),305,'p2p',2,False)
		try:
			downloadlimit = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","downloadlimit.txt"))
		except: downloadlimit = "N/A"
		addDir(translate(600018) +"[COLOR orange][ " + str(int(downloadlimit))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","downloadlimit.txt"),305,'p2p',2,False)
		try:
			uploadlimit = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","uploadlimit.txt"))
		except: uploadlimit = "N/A"
		addDir(translate(600019)+"[COLOR orange][ " + str(int(uploadlimit))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","uploadlimit.txt"),305,'p2p',2,False)
		try:
			maxconnections = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnections.txt"))
		except: maxconnections = "N/A"
		addDir(translate(600020)+"[COLOR orange][ " + str(int(maxconnections))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnections.txt"),305,'p2p',2,False)
		try:
			maxconnectionsstream = readfile(os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnectionsstream.txt"))
		except: maxconnectionsstream = "N/A"
		addDir(translate(600021)+"[COLOR orange][ " + str(int(maxconnectionsstream))+ " ][/COLOR]",os.path.join(pastaperfil,"acestream","ace","ACEStream","values","maxconnectionsstream.txt"),305,'',2,False)
	elif eligible and not xbmcvfs.exists(os.path.join(pastaperfil,'acestream','ace','ACEStream','values')):
		addLink("[COLOR red][B]"+translate(600027)+"[/COLOR][/B]","",addonpath + art + 'processwarning.png')
	else:
		pass
	if (not eligible and xbmc.getCondVisibility('system.platform.linux') and settings.getSetting('ace_cmd') == "0") or (not eligible and xbmc.getCondVisibility('system.platform.windows')) or (not eligible and xbmc.getCondVisibility('system.platform.Android') and settings.getSetting('engine_app') == "0") or (settings.getSetting('force_android') == "true" and settings.getSetting('engine_app') == "0"):
		if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'):
			default_acefolder = os.path.join(os.getenv("HOME"),'.ACEStream')
			default_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
			pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Linux/playerconf.pickle'
			if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
			else: acestream_cachefolder = settings.getSetting('acestream_cachefolder')
			acestream_settings_file = os.path.join(os.getenv("HOME"),'.ACEStream','playerconf.pickle')
		elif xbmc.getCondVisibility('system.platform.Android'):
			default_acefolder = os.path.join('/sdcard','.ACEStream')
			default_cachefolder = os.path.join('/sdcard','.ACEStream','.acestream_cache')
			pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Android/playerconf.pickle'
			if settings.getSetting('acestream_cachefolder') == '': acestream_cachefolder = os.path.join('/sdcard','.ACEStream','.acestream_cache')
			else: acestream_cachefolder = settings.getSetting('acestream_cachefolder')
			acestream_settings_file = os.path.join('/sdcard','.ACEStream','playerconf.pickle')
		elif xbmc.getCondVisibility('system.platform.windows'):
			default_acefolder = os.path.join(os.getenv("APPDATA"),".ACEStream")
			pickle_repo = 'http://p2p-strm.googlecode.com/svn/trunk/Modules/Windows/playerconf.pickle'
			default_cachefolder = os.path.join(os.getenv("SystemDrive"),'\_acestream_cache_')
			acestream_cachefolder = default_cachefolder
			acestream_settings_file = os.path.join(os.getenv("APPDATA"),".ACEStream","playerconf.pickle")
		#workaround to keep settings file in place if they get deleted
		if not xbmcvfs.exists(default_acefolder): xbmcvfs.mkdir(default_acefolder)
		if not xbmcvfs.exists(default_cachefolder): xbmcvfs.mkdir(default_cachefolder)
		if not xbmcvfs.exists(acestream_settings_file):
			local_file = os.path.join(default_acefolder,pickle_repo.split("/")[-1])
			download_tools().Downloader(pickle_repo,local_file,'',translate(40000))
			xbmc.sleep(200)
			if xbmcvfs.exists(acestream_settings_file):
				settings_text = readfile(acestream_settings_file)
				save(acestream_settings_file,settings_text.replace('my_cache_folder',default_cachefolder))
		if xbmcvfs.exists(acestream_settings_file) and xbmcvfs.exists(acestream_cachefolder):
			addLink('[COLOR orange]Acestream engine settings:[/COLOR]','',addonpath + art + 'settings_menu.png')
			xbmc.sleep(200)
			acestream_cache_size = str(int(getDirectorySize(acestream_cachefolder))/(1024*1024))
			addDir(translate(70003) + '[COLOR orange] [' + acestream_cache_size + ' MB][/COLOR]',acestream_cachefolder,307,'p2p',1,False)
			settings_content = readfile(acestream_settings_file)
			number_of_settings = re.compile('p(\d+)\n').findall(settings_content)
			cachefoldersetting = re.compile("'download_dir'\np\d+\n.+?/(.+?)\n").findall(settings_content)
			if not cachefoldersetting:
				if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android'):
					cachefoldersetting = os.path.join(os.getenv("HOME"),'.ACEStream','cache')
					settings.setSetting('acestream_cachefolder',cachefoldersetting)
				elif xbmc.getCondVisibility('system.platform.windows'):
					cachefoldersetting = os.path.join(os.getenv("SystemDrive"),'_acestream_cache_')
					settings.setSetting('acestream_cachefolder',cachefoldersetting)
				else:
					cachefoldersetting = os.path.join('/sdcard','.ACEStream','cache')
					settings.setSetting('acestream_cachefolder',cachefoldersetting)
			else: 
				cachefoldersetting = '/' + cachefoldersetting[0].replace("'","")
				settings.setSetting('acestream_cachefolder',cachefoldersetting)
			if cachefoldersetting: addDir(translate(70013)+"[COLOR orange][ " + cachefoldersetting + " ][/COLOR]",str(cachefoldersetting),309,'p2p',2,False)
			else: addDir(translate(70013)+"[COLOR orange][" + cachefoldersetting + "][/COLOR]",cachefoldersetting,309,'p2p',2,False)
			livebuffervalue = re.compile("S'live_buffer_time'\np(\d+)\nI(\d+)").findall(settings_content)
			if livebuffervalue:	addDir(translate(600017)+"[COLOR orange][ " + livebuffervalue[0][1] + " ][/COLOR]",'live_buffer_time|' + str(livebuffervalue)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600017)+"[COLOR orange][3][/COLOR]",'live_buffer_time|'+str(len(number_of_settings)),308,'p2p',2,False)
			vodbuffervalue = re.compile("S'player_buffer_time'\np(\d+)\nI(\d+)").findall(settings_content)
			if vodbuffervalue: addDir(translate(600016)+"[COLOR orange][ " + vodbuffervalue[0][1] + " ][/COLOR]",'player_buffer_time|'+str(vodbuffervalue)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600016)+"[COLOR orange][10][/COLOR]",'player_buffer_time|'+str(len(number_of_settings)),308,'p2p',2,False)
			downloadlimit = re.compile("S'total_max_download_rate'\np(\d+)\nI(\d+)").findall(settings_content)
			if downloadlimit: addDir(translate(600018)+"[COLOR orange][ " + downloadlimit[0][1] + " ][/COLOR]",'total_max_download_rate|'+str(downloadlimit)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600018)+"[COLOR orange][0][/COLOR]",'total_max_download_rate|'+str(len(number_of_settings)),308,'p2p',2,False)
			uploadlimit = re.compile("S'total_max_upload_rate'\np(\d+)\nI(\d+)").findall(settings_content)
			if uploadlimit: addDir(translate(600019)+"[COLOR orange][ " + uploadlimit[0][1] + " ][/COLOR]",'total_max_upload_rate|'+str(uploadlimit)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600019)+"[COLOR orange][0][/COLOR]",'total_max_upload_rate|'+str(len(number_of_settings)),308,'p2p',2,False)
			maxconnection_per_stream = re.compile("S'max_peers'\np(\d+)\nI(\d+)").findall(settings_content)
			if maxconnection_per_stream: addDir(translate(600021)+"[COLOR orange][ " + maxconnection_per_stream[0][1] + " ][/COLOR]",'max_peers|'+str(maxconnection_per_stream)+'|'+str(len(number_of_settings)),308,'p2p',2,False)
			else: addDir(translate(600021)+"[COLOR orange][50][/COLOR]",'max_peers|'+str(len(number_of_settings)),308,'p2p',2,False)
Ejemplo n.º 12
0
def configure_acestream(latest_version):
	#Configuration for LINUX 
	if xbmc.getCondVisibility('system.platform.linux') and not xbmc.getCondVisibility('system.platform.Android') and not settings.getSetting('force_android') == "true":
		print("Detected OS: Linux")
		#Linux Armv6
		if os.uname()[4] == "armv6l":
			print("Detected linux armv6 - possible Raspberry PI")
			if settings.getSetting('openelecarm6') == "true": acestream_rpi = acestream_openelec_raspberry
			else: acestream_rpi = acestream_generic_raspberry
			ACE_KIT = os.path.join(addonpath,acestream_rpi.split("/")[-1])
			download_tools().Downloader(acestream_rpi,ACE_KIT,translate(40026),translate(40000))
			import tarfile            
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		#Linux Armv7
		elif os.uname()[4] == "armv7l":
			if settings.getSetting('openelecarm7') == "true": acestream_package = acestream_armv7_openelec
			elif settings.getSetting('xbianarm7') == "true": acestream_package = acestream_armv7_xbian
			elif settings.getSetting('mxlinuxarm7') == "true" or settings.getSetting('jynxbox_arm7') == "true": acestream_package = acestream_mxlinux
		
			ACE_KIT = os.path.join(addonpath,acestream_package.split("/")[-1])
			download_tools().Downloader(acestream_package,ACE_KIT,translate(40026),translate(40000))
			import tarfile
			if tarfile.is_tarfile(ACE_KIT):
				path_libraries = os.path.join(pastaperfil,"acestream")
				download_tools().extract(ACE_KIT,path_libraries)
				xbmc.sleep(500)
				download_tools().remove(ACE_KIT)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return

		elif os.uname()[4] == "x86_64":
			if settings.getSetting('openelecx86_64') == "true":
				print("OpenELEC x86_64 Acestream configuration")
				ACE_KIT = os.path.join(addonpath,openeelcx86_64_acestream.split("/")[-1])
				download_tools().Downloader(openeelcx86_64_acestream ,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

			else:
				print("64 bit Linux Disto Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_x64_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_x64_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

		elif os.uname()[4] == "i386" or os.uname()[4] == "i686":
			if settings.getSetting('openeleci386') == "true":
				print("32 bit Openelec Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,openeelcxi386_acestream.split("/")[-1])
				download_tools().Downloader(openeelcxi386_acestream,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return
			else:
				print("32 bit Linux general distro Acestream Configuration")
				ACE_KIT = os.path.join(addonpath,acestream_linux_i386_generic.split("/")[-1])
				download_tools().Downloader(acestream_linux_i386_generic,ACE_KIT,translate(40026),translate(40000))
				import tarfile
				if tarfile.is_tarfile(ACE_KIT):
					download_tools().extract(ACE_KIT,pastaperfil)
					xbmc.sleep(500)
					download_tools().remove(ACE_KIT)
				if latest_version: settings.setSetting('acestream_version',value=latest_version)
				return

	elif xbmc.getCondVisibility('system.platform.windows'):
		print("Detected OS: Windows")
		if not xbmcvfs.exists(pastaperfil): xbmcvfs.mkdir(pastaperfil)
          #Ace
		SPSC_KIT = os.path.join(addonpath,acestream_windows.split("/")[-1])
		download_tools().Downloader(acestream_windows,SPSC_KIT,translate(40026),translate(40000))
		import shutil
		if xbmcvfs.exists(os.path.join(pastaperfil,"acestream")):
			shutil.rmtree(os.path.join(pastaperfil,"acestream"))
		if xbmcvfs.exists(os.path.join(pastaperfil,"player")):
			shutil.rmtree(os.path.join(pastaperfil,"player"))
		import tarfile
		if tarfile.is_tarfile(SPSC_KIT):
			path_libraries = os.path.join(pastaperfil)
			download_tools().extract(SPSC_KIT,path_libraries)
			download_tools().remove(SPSC_KIT)
		if latest_version: settings.setSetting('acestream_version',value=latest_version)
		return
    
	elif xbmc.getCondVisibility('System.Platform.OSX'):
		print("Detected OS: Mac OSX")
		available = False
		if os.uname()[-1] == "x86_64":
			mac_package = osx_x64_acestream
			available = True
		elif os.uname()[-1] == "i386":
			mac_package = osx_i386_acestream
			available = True
		else:
			available = False
		if available == True:		
			if not xbmcvfs.exists(pastaperfil):
				xbmcvfs.mkdir(pastaperfil)		
			MAC_KIT = os.path.join(addonpath,mac_package.split("/")[-1])
			download_tools().Downloader(mac_package,MAC_KIT,translate(40026),translate(40000))
			import tarfile
			if tarfile.is_tarfile(MAC_KIT):
				path_libraries = os.path.join(pastaperfil)
				download_tools().extract(MAC_KIT,pastaperfil)
				download_tools().remove(MAC_KIT)
				sp_sc_auth = os.path.join(pastaperfil,"sopcast","sp-sc-auth")
				st = os.stat(sp_sc_auth)
				import stat
				os.chmod(sp_sc_auth, st.st_mode | stat.S_IEXEC)
			if latest_version: settings.setSetting('acestream_version',value=latest_version)
			return
		else:
			mensagemok(translate(40000),translate(600014))
			return
			
				
	elif xbmc.getCondVisibility('System.Platform.Android') or settings.getSetting('force_android') == "true":

		print("Detected OS: Android")
		print("Starting Acestream Configuration")
		#acestream config for android

		mensagemok(translate(40000),translate(50018),translate(50019),translate(50020))
		if xbmcvfs.exists(os.path.join("sdcard","Download")):
			pasta = os.path.join("sdcard","Download")
			acefile = os.path.join("sdcard","Download",acestreamengine_apk.split("/")[-1])
		else:
			dialog = xbmcgui.Dialog()
			pasta = dialog.browse(int(0), translate(40190), 'myprograms')
			acefile = os.path.join(pasta,acestreamengine_apk.split("/")[-1])
		download_tools().Downloader(acestreamengine_apk,acefile,translate(40072),translate(40000))
		import tarfile
		if tarfile.is_tarfile(acefile):
			download_tools().extract(acefile,pasta)
			download_tools().remove(acefile)
		xbmc.sleep(2000)
		mensagemok(translate(40000),translate(50021),pasta,translate(50016))
		mensagemok(translate(40000),translate(50022))
		mensagemok(translate(40000),translate(50023),translate(50024),translate(50025))
		if latest_version: settings.setSetting('acestream_version',value=latest_version)
		return