Esempio n. 1
0
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
    try:
        percent = min(numblocks * blocksize * 100 / filesize, 100)
        currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
        kbps_speed = numblocks * blocksize / (time.time() - start_time)
        if kbps_speed > 0 and not percent == 100:
            eta = (filesize - numblocks * blocksize) / kbps_speed
        else:
            eta = 0
        kbps_speed = kbps_speed / 1024
        type_speed = 'KB'
        if kbps_speed >= 1024:
            kbps_speed = kbps_speed / 1024
            type_speed = 'MB'
        total = float(filesize) / (1024 * 1024)
        mbs = '[COLOR %s][B]Size:[/B] [COLOR %s]%.02f[/COLOR] MB of [COLOR %s]%.02f[/COLOR] MB[/COLOR]' % (
            COLOR2, COLOR1, currently_downloaded, COLOR1, total)
        e = '[COLOR %s][B]Speed:[/B] [COLOR %s]%.02f [/COLOR]%s/s ' % (
            COLOR2, COLOR1, kbps_speed, type_speed)
        e += '[B]ETA:[/B] [COLOR ' + COLOR1 + ']%02d:%02d[/COLOR][/COLOR]' % divmod(
            eta, 60)
        dp.update(percent, '', mbs, e)
        if dp.iscanceled():
            dp.close()
    except:
        percent = 100
        dp.update(percent)
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Download Cancelled[/COLOR]" % COLOR2)
        sys.exit()
Esempio n. 2
0
def swapUS():
	new = '"addons.unknownsources"'
	value = 'true'
	query = '{"jsonrpc":"2.0", "method":"Settings.GetSettingValue","params":{"setting":%s}, "id":1}' % (new)
	response = xbmc.executeJSONRPC(query)
	wiz.log("Unknown Sources Get Settings: %s" % str(response), xbmc.LOGDEBUG)
	if 'false' in response:
		thread.start_new_thread(dialogWatch, ())
		xbmc.sleep(200)
		query = '{"jsonrpc":"2.0", "method":"Settings.SetSettingValue","params":{"setting":%s,"value":%s}, "id":1}' % (new, value)
		response = xbmc.executeJSONRPC(query)
		wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE), '[COLOR %s]Unknown Sources:[/COLOR] [COLOR %s]Enabled[/COLOR]' % (COLOR1, COLOR2))
		wiz.log("Unknown Sources Set Settings: %s" % str(response), xbmc.LOGDEBUG)
Esempio n. 3
0
def download(url, dest, dp=None):
    if not dp:
        dp = xbmcgui.DialogProgress()
        dp.create(ADDONTITLE, "Downloading Content", ' ', ' ')
    dp.update(0)
    start_time = time.time()
    try:
        urllib.urlretrieve(
            url, dest, lambda nb, bs, fs: _pbhook(nb, bs, fs, dp, start_time))
    except Exception, e:
        wiz.log("ERROR Downloading(%s): %s" % (dest, str(e)), xbmc.LOGERROR)
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Download Timed Out[/COLOR]" % COLOR2)
        sys.exit()
Esempio n. 4
0
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
    try:
        percent = min(numblocks * blocksize * 100 / filesize, 100)
        currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
        kbps_speed = numblocks * blocksize / (time.time() - start_time)
        if kbps_speed > 0 and not percent == 100:
            eta = (filesize - numblocks * blocksize) / kbps_speed
        else:
            eta = 0
        kbps_speed = kbps_speed / 1024
        type_speed = 'KB'
        if kbps_speed >= 1024:
            kbps_speed = kbps_speed / 1024
            type_speed = 'MB'
        total = float(filesize) / (1024 * 1024)
        mbs = '[COLOR %s][B]Tamanho:[/B] [COLOR %s]%.02f[/COLOR] MB de [COLOR %s]%.02f[/COLOR] MB[/COLOR]' % (
            COLOR2, COLOR1, currently_downloaded, COLOR1, total)
        e = '[COLOR %s][B]Velocidade:[/B] [COLOR %s]%.02f [/COLOR]%s/s ' % (
            COLOR2, COLOR1, kbps_speed, type_speed)
        e += '[B]Tempo Restante:[/B] [COLOR ' + COLOR1 + ']%02d:%02d[/COLOR][/COLOR]' % divmod(
            eta, 60)
        dp.update(percent, '', mbs, e)
    except Exception, e:
        wiz.log("Erro ao Fazer Download: %s" % str(e), xbmc.LOGERROR)
        pass
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Download Cancelado[/COLOR]" % COLOR2)
        sys.exit()
Esempio n. 5
0
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
    try:
        percent = min(numblocks * blocksize * 100 / filesize, 100)
        currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
        kbps_speed = numblocks * blocksize / (time.time() - start_time)
        if kbps_speed > 0 and not percent == 100:
            eta = (filesize - numblocks * blocksize) / kbps_speed
        else:
            eta = 0
        kbps_speed = kbps_speed / 1024
        type_speed = 'KB'
        if kbps_speed >= 1024:
            kbps_speed = kbps_speed / 1024
            type_speed = 'MB'
        total = float(filesize) / (1024 * 1024)
        mbs = '[COLOR lime]Velicina:[/COLOR] [COLOR white]%.02f[/COLOR] [COLOR lime]MB of[/COLOR] [COLOR white]%.02f[/COLOR] [COLOR lime]MB[/COLOR]' % (
            currently_downloaded, total)
        e = '[COLOR lime]Brzina:[/COLOR] [COLOR white]%.02f [/COLOR][COLOR lime]%s/s[/COLOR] ' % (
            kbps_speed, type_speed)
        e = '[COLOR lime]Preostalo:[/COLOR] [COLOR white]%02d:%02d[/COLOR] [COLOR lime]minuta[/COLOR]' % divmod(
            eta, 60)
        dp.update(percent, '', mbs, e)
    except Exception, e:
        wiz.log("Greska preuzimanja: %s" % str(e), xbmc.LOGERROR)
        pass
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR white]%s[/COLOR]" % (ADDONTITLE),
                      "[COLOR lime]Preuzimanje prekinuto[/COLOR]")
        sys.exit()
Esempio n. 6
0
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
    try:
        percent = min(numblocks * blocksize * 100 / filesize, 100)
        currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
        kbps_speed = numblocks * blocksize / (time.time() - start_time)
        if kbps_speed > 0 and not percent == 100:
            eta = (filesize - numblocks * blocksize) / kbps_speed
        else:
            eta = 0
        kbps_speed = kbps_speed / 1024
        type_speed = 'KB'
        if kbps_speed >= 1024:
            kbps_speed = kbps_speed / 1024
            type_speed = 'MB'
        total = float(filesize) / (1024 * 1024)
        mbs = '[COLOR %s][B]Boyut:[/B] [COLOR %s]%.02f[/COLOR] MB of [COLOR %s]%.02f[/COLOR] MB[/COLOR]' % (
            COLOR2, COLOR1, currently_downloaded, COLOR1, total)
        e = '[COLOR %s][B]Hiz:[/B] [COLOR %s]%.02f [/COLOR]%s/s ' % (
            COLOR2, COLOR1, kbps_speed, type_speed)
        e += '[B]SURE:[/B] [COLOR ' + COLOR1 + ']%02d:%02d[/COLOR][/COLOR]' % divmod(
            eta, 60)
        dp.update(percent, '', mbs, e)
    except Exception, e:
        wiz.log("Hatali Indirme: %s" % str(e), xbmc.LOGERROR)
        return str(e)
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Indirme Iptal[/COLOR]" % COLOR2)
        sys.exit()
Esempio n. 7
0
                                         ) == -1 and KEEPSUPER == 'true':
            skip = True
        elif not str(item.filename).find(ADDON_ID) == -1 and ignore == None:
            skip = True
        if skip == True:
            wiz.log("Skipping: %s" % item.filename, xbmc.LOGNOTICE)
        else:
            try:
                zin.extract(item, _out)
            except Exception, e:
                errormsg = "[COLOR %s]File:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (
                    COLOR2, COLOR1, file[-1])
                errormsg += "[COLOR %s]Folder:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (
                    COLOR2, COLOR1, (item.filename).replace(file[-1], ''))
                errormsg += "[COLOR %s]Error:[/COLOR] [COLOR %s]%s[/COLOR]\n\n" % (
                    COLOR2, COLOR1, str(e).replace('\\\\', '\\').replace(
                        "'%s'" % item.filename, ''))
                errors += 1
                error += errormsg
                wiz.log('Error Extracting: %s(%s)' % (item.filename, str(e)),
                        xbmc.LOGERROR)
                pass
        dp.update(prog, line1, line2, line3)
        if dp.iscanceled(): break
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Extract Cancelled[/COLOR]" % COLOR2)
        sys.exit()
    return prog, errors, error
		line2 += '[COLOR %s][B]Tamanho:[/B][/COLOR] [COLOR %s]%s/%s[/COLOR]' % (COLOR2, COLOR1, wiz.convertSize(size), zipsize)
		line3  = '[COLOR %s]%s[/COLOR]' % (COLOR1, item.filename)
		if item.filename == 'userdata/sources.xml' and KEEPSOURCES == 'true': skip = True
		elif item.filename == 'userdata/favourites.xml' and KEEPFAVS == 'true': skip = True
		elif item.filename == 'userdata/profiles.xml' and KEEPPROFILES == 'true': skip = True
		elif item.filename == 'userdata/advancedsettings.xml' and KEEPADVANCED == 'true': skip = True
		elif file[0] == 'addons' and file[1] in excludes: skip = True
		elif file[0] == 'userdata' and file[1] == 'addon_data' and file[2] in excludes: skip = True
		elif file[-1] in LOGFILES: skip = True
		elif file[-1] in bad_files: skip = True
		elif file[-1].endswith('.csv'): skip = True
		elif not str(item.filename).find('plugin.program.super.favourites') == -1 and KEEPSUPER == 'true': skip = True
		elif not str(item.filename).find(ADDON_ID) == -1 and ignore == None: skip = True
		if skip == True: wiz.log("Skipping: %s" % item.filename, xbmc.LOGNOTICE)
		else:
			try:
				zin.extract(item, _out)
			except Exception, e:
				errormsg  = "[COLOR %s]Tamanho:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (COLOR2, COLOR1, file[-1])
				errormsg += "[COLOR %s]Pasta:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (COLOR2, COLOR1, (item.filename).replace(file[-1],''))
				errormsg += "[COLOR %s]Erro:[/COLOR] [COLOR %s]%s[/COLOR]\n\n" % (COLOR2, COLOR1, str(e).replace('\\\\','\\').replace("'%s'" % item.filename, ''))
				errors += 1; error += errormsg
				wiz.log('Erros de extração: %s(%s)' % (item.filename, str(e)), xbmc.LOGERROR)
				pass
		dp.update(prog, line1, line2, line3)
		if dp.iscanceled(): break
	if dp.iscanceled(): 
		dp.close()
		wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE), "[COLOR %s]Extração cancelado[/COLOR]" % COLOR2)
		sys.exit()
	return prog, errors, error
Esempio n. 9
0
                                         ) == -1 and KEEPSUPER == 'true':
            skip = True
        elif not str(item.filename).find(ADDON_ID) == -1 and ignore == None:
            skip = True
        if skip == True:
            wiz.log("Skipping: %s" % item.filename, xbmc.LOGNOTICE)
        else:
            try:
                zin.extract(item, _out)
            except Exception, e:
                errormsg = "[COLOR %s]Datei:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (
                    COLOR2, COLOR1, file[-1])
                errormsg += "[COLOR %s]Ordner:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (
                    COLOR2, COLOR1, (item.filename).replace(file[-1], ''))
                errormsg += "[COLOR %s]Fehler:[/COLOR] [COLOR %s]%s[/COLOR]\n\n" % (
                    COLOR2, COLOR1, str(e).replace('\\\\', '\\').replace(
                        "'%s'" % item.filename, ''))
                errors += 1
                error += errormsg
                wiz.log('Error Extracting: %s(%s)' % (item.filename, str(e)),
                        xbmc.LOGERROR)
                pass
        dp.update(prog, line1, line2, line3)
        if dp.iscanceled(): break
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Entpacken abgebrochen[/COLOR]" % COLOR2)
        sys.exit()
    return prog, errors, error
Esempio n. 10
0
		line2 += '[COLOR %s][B]Tamano:[/B][/COLOR] [COLOR %s]%s/%s[/COLOR]' % (COLOR2, COLOR1, wiz.convertSize(size), zipsize)
		line3  = '[COLOR %s]%s[/COLOR]' % (COLOR1, item.filename)
		if item.filename == 'userdata/sources.xml' and KEEPSOURCES == 'true': skip = True
		elif item.filename == 'userdata/favourites.xml' and KEEPFAVS == 'true': skip = True
		elif item.filename == 'userdata/profiles.xml' and KEEPPROFILES == 'true': skip = True
		elif item.filename == 'userdata/advancedsettings.xml' and KEEPADVANCED == 'true': skip = True
		elif file[0] == 'addons' and file[1] in excludes: skip = True
		elif file[0] == 'userdata' and file[1] == 'addon_data' and file[2] in excludes: skip = True
		elif file[-1] in LOGFILES: skip = True
		elif file[-1] in bad_files: skip = True
		elif file[-1].endswith('.csv'): skip = True
		elif not str(item.filename).find('plugin.program.super.favourites') == -1 and KEEPSUPER == 'true': skip = True
		elif not str(item.filename).find(ADDON_ID) == -1 and ignore == None: skip = True
		if skip == True: wiz.log("Saltando: %s" % item.filename, xbmc.LOGNOTICE)
		else:
			try:
				zin.extract(item, _out)
			except Exception, e:
				errormsg  = "[COLOR %s]Archivo:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (COLOR2, COLOR1, file[-1])
				errormsg += "[COLOR %s]Carpeta:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (COLOR2, COLOR1, (item.filename).replace(file[-1],''))
				errormsg += "[COLOR %s]Error:[/COLOR] [COLOR %s]%s[/COLOR]\n\n" % (COLOR2, COLOR1, str(e).replace('\\\\','\\').replace("'%s'" % item.filename, ''))
				errors += 1; error += errormsg
				wiz.log('Error Extracting: %s(%s)' % (item.filename, str(e)), xbmc.LOGERROR)
				pass
		dp.update(prog, line1, line2, line3)
		if dp.iscanceled(): break
	if dp.iscanceled(): 
		dp.close()
		wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE), "[COLOR %s]Extraccion cancelada![/COLOR]" % COLOR2)
		sys.exit()
	return prog, errors, error
Esempio n. 11
0
		dp.create(ADDONTITLE ,"Downloading Content",' ', ' ')
	dp.update(0)
	start_time=time.time()
	urllib.urlretrieve(url, dest, lambda nb, bs, fs: _pbhook(nb, bs, fs, dp, start_time))

def _pbhook(numblocks, blocksize, filesize, dp, start_time):
	try: 
		percent = min(numblocks * blocksize * 100 / filesize, 100) 
		currently_downloaded = float(numblocks) * blocksize / (1024 * 1024) 
		kbps_speed = numblocks * blocksize / (time.time() - start_time) 
		if kbps_speed > 0 and not percent == 100: 
			eta = (filesize - numblocks * blocksize) / kbps_speed 
		else: 
			eta = 0
		kbps_speed = kbps_speed / 1024 
		type_speed = 'KB'
		if kbps_speed >= 1024:
			kbps_speed = kbps_speed / 1024 
			type_speed = 'MB'
		total = float(filesize) / (1024 * 1024) 
		mbs = '[COLOR %s][B]Peso:[/B] [COLOR %s]%.02f[/COLOR] MB de [COLOR %s]%.02f[/COLOR] MB[/COLOR]' % (COLOR2, COLOR1, currently_downloaded, COLOR1, total) 
		e   = '[COLOR %s][B]Velocidad:[/B] [COLOR %s]%.02f [/COLOR]%s/s ' % (COLOR2, COLOR1, kbps_speed, type_speed)
		e  += '[B]ETA:[/B] [COLOR '+COLOR1+']%02d:%02d[/COLOR][/COLOR]' % divmod(eta, 60)
		dp.update(percent, '', mbs, e)
	except Exception, e:
		wiz.log("ERROR Descargando: %s" % str(e), xbmc.LOGERROR)
		return str(e)
	if dp.iscanceled(): 
		dp.close()
		wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE), "[COLOR %s]Descarga Cancelada[/COLOR]" % COLOR2)
		sys.exit()
Esempio n. 12
0
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
    try:
        percent = min(numblocks * blocksize * 100 / filesize, 100)
        currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
        kbps_speed = numblocks * blocksize / (time.time() - start_time)
        if kbps_speed > 0 and not percent == 100:
            eta = (filesize - numblocks * blocksize) / kbps_speed
        else:
            eta = 0
        kbps_speed = kbps_speed / 1024
        type_speed = 'KB'
        if kbps_speed >= 1024:
            kbps_speed = kbps_speed / 1024
            type_speed = 'MB'
        total = float(filesize) / (1024 * 1024)
        mbs = '[COLOR %s][B]Grosse:[/B] [COLOR %s]%.02f[/COLOR] MB von [COLOR %s]%.02f[/COLOR] MB[/COLOR]' % (
            COLOR2, COLOR1, currently_downloaded, COLOR1, total)
        e = '[COLOR %s][B]Geschwindigkeit:[/B] [COLOR %s]%.02f [/COLOR]%s/s ' % (
            COLOR2, COLOR1, kbps_speed, type_speed)
        e += '[B]Verbleibende Zeit:[/B] [COLOR ' + COLOR1 + ']%02d:%02d[/COLOR][/COLOR]' % divmod(
            eta, 60)
        dp.update(percent, '', mbs, e)
    except Exception, e:
        wiz.log("ERROR Downloading: %s" % str(e), xbmc.LOGERROR)
        return str(e)
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Download abgebrochen[/COLOR]" % COLOR2)
        sys.exit()
Esempio n. 13
0
                                         ) == -1 and KEEPSUPER == 'true':
            skip = True
        elif not str(item.filename).find(ADDON_ID) == -1 and ignore == None:
            skip = True
        if skip == True:
            wiz.log("Skipping: %s" % item.filename, xbmc.LOGNOTICE)
        else:
            try:
                zin.extract(item, _out)
            except Exception, e:
                errormsg = "[COLOR %s]Dosya:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (
                    COLOR2, COLOR1, file[-1])
                errormsg += "[COLOR %s]Klasor:[/COLOR] [COLOR %s]%s[/COLOR]\n" % (
                    COLOR2, COLOR1, (item.filename).replace(file[-1], ''))
                errormsg += "[COLOR %s]Hata:[/COLOR] [COLOR %s]%s[/COLOR]\n\n" % (
                    COLOR2, COLOR1, str(e).replace('\\\\', '\\').replace(
                        "'%s'" % item.filename, ''))
                errors += 1
                error += errormsg
                wiz.log('Ayiklama Hatasi: %s(%s)' % (item.filename, str(e)),
                        xbmc.LOGERROR)
                pass
        dp.update(prog, line1, line2, line3)
        if dp.iscanceled(): break
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Ayiklama Iptal[/COLOR]" % COLOR2)
        sys.exit()
    return prog, errors, error
Esempio n. 14
0
def _pbhook(numblocks, blocksize, filesize, dp, start_time):
    try:
        percent = min(numblocks * blocksize * 100 / filesize, 100)
        currently_downloaded = float(numblocks) * blocksize / (1024 * 1024)
        kbps_speed = numblocks * blocksize / (time.time() - start_time)
        if kbps_speed > 0 and not percent == 100:
            eta = (filesize - numblocks * blocksize) / kbps_speed
        else:
            eta = 0
        kbps_speed = kbps_speed / 1024
        type_speed = 'KB'
        if kbps_speed >= 1024:
            kbps_speed = kbps_speed / 1024
            type_speed = 'MB'
        total = float(filesize) / (1024 * 1024)
        mbs = '[COLOR %s][B]Tamano:[/B] [COLOR %s]%.02f[/COLOR] MB de [COLOR %s]%.02f[/COLOR] MB[/COLOR]' % (
            COLOR2, COLOR1, currently_downloaded, COLOR1, total)
        e = '[COLOR %s][B]Velocidad:[/B] [COLOR %s]%.02f [/COLOR]%s/s ' % (
            COLOR2, COLOR1, kbps_speed, type_speed)
        e += '[B]ETA:[/B] [COLOR ' + COLOR1 + ']%02d:%02d[/COLOR][/COLOR]' % divmod(
            eta, 60)
        dp.update(percent, '', mbs, e)
    except Exception, e:
        wiz.log("ERROR Descargando: %s" % str(e), xbmc.LOGERROR)
        return str(e)
    if dp.iscanceled():
        dp.close()
        wiz.LogNotify("[COLOR %s]%s[/COLOR]" % (COLOR1, ADDONTITLE),
                      "[COLOR %s]Descarga Completa[/COLOR]" % COLOR2)
        sys.exit()