コード例 #1
0
def downloadtitle2(url,title):
	# Imprime en el log lo que va a descartar
	xbmc.output("[downloadtools.py] downloadtitle: url="+url )
	#xbmc.output("[downloadtools.py] downloadtitle: title="+urllib.quote_plus( title ))
	plataforma = xbmctools.get_system_platform();
	xbmc.output("[downloadtools.py] downloadtitle: plataforma="+plataforma)

	# Saca el nombre del fichero del título, y la extension de la URL
	nombrefichero = limpia_nombre_caracteres_especiales(title)
	#if plataforma=="xbox":
	nombrefichero = nombrefichero[:8] + url[-4:]
	#else:
	#	nombrefichero = nombrefichero + url[-4:]
	xbmc.output("[downloadtools.py] downloadtitle: nombrefichero="+nombrefichero)
	xbmc.output("[downloadtools.py] downloadtitle: nombrefichero="+nombrefichero[:8])
	xbmc.output("[downloadtools.py] downloadtitle: nombrefichero="+nombrefichero[:4])

	# Intenta crear el fichero, y va sustituyendo caracteres inválidos hasta que lo consigue
	downloadpath = xbmcplugin.getSetting("downloadpath")
	fullpath = ""
	try:
		fullpath = os.path.join( downloadpath , nombrefichero )
		testfile = open( fullpath, "wb")
		testfile.close()
		os.remove(fullpath)
		xbmc.output("[downloadtools.py] downloadtitle: ok 1")
	except:
		try:
			fullpath = os.path.join( downloadpath , limpia_nombre_sin_acentos(nombrefichero) )
			testfile = open( fullpath, "wb")
			testfile.close()
			os.remove(fullpath)
			xbmc.output("[downloadtools.py] downloadtitle: ok 2")
		except:
			try:
				fullpath = os.path.join( downloadpath , limpia_nombre_excepto_1(nombrefichero) )
				testfile = open( fullpath, "wb")
				testfile.close()
				os.remove(fullpath)
				xbmc.output("[downloadtools.py] downloadtitle: ok 3")
			except:
				try:
					fullpath = os.path.join( downloadpath , limpia_nombre_excepto_2(nombrefichero) )
					testfile = open( fullpath, "wb")
					testfile.close()
					os.remove(fullpath)
					xbmc.output("[downloadtools.py] downloadtitle: ok 4")
				except:
					xbmc.output("[downloadtools.py] downloadtitle: ERROR no se ha podido crear el fichero")

	#xbmc.output("[downloadtools.py] downloadtitle: nombrefichero="+nombrefichero)

	downloadfile(url,fullpath)
コード例 #2
0
def GetTitleFromFile(title):
	# Imprime en el log lo que va a descartar
	xbmc.output("[downloadtools.py] GetTitleFromFile: titulo="+title )
	#xbmc.output("[downloadtools.py] downloadtitle: title="+urllib.quote_plus( title ))
	plataforma = xbmctools.get_system_platform();
	xbmc.output("[downloadtools.py] GetTitleFromFile: plataforma="+plataforma)
	
	#nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
	if plataforma=="xbox":
		nombrefichero = title[:38] + title[-4:]
		nombrefichero = limpia_nombre_excepto_1(nombrefichero)
	else:
		nombrefichero = title
	return nombrefichero
コード例 #3
0
def getfilefromtitle(url,title):
	# Imprime en el log lo que va a descartar
	xbmc.output("[downloadtools.py] getfilefromtitle: url="+url )
	#xbmc.output("[downloadtools.py] downloadtitle: title="+urllib.quote_plus( title ))
	plataforma = xbmctools.get_system_platform();
	xbmc.output("[downloadtools.py] getfilefromtitle: plataforma="+plataforma)
	
	#nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
	if plataforma=="xbox":
		nombrefichero = title[:38] + url[-4:]
		nombrefichero = limpia_nombre_excepto_1(nombrefichero)
	else:
		nombrefichero = title + url[-4:]

	xbmc.log("[downloadtools.py] getfilefromtitle: nombrefichero=%s" % nombrefichero)
	fullpath = os.path.join( getDownloadPath() , nombrefichero )
	xbmc.log("[downloadtools.py] getfilefromtitle: fullpath=%s" % fullpath)
	
	return fullpath
コード例 #4
0
def getfilefromtitle(url,title):
	# Imprime en el log lo que va a descartar
	xbmc.output("[downloadtools.py] getfilefromtitle: url="+url )
	#xbmc.output("[downloadtools.py] downloadtitle: title="+urllib.quote_plus( title ))
	plataforma = xbmctools.get_system_platform();
	xbmc.output("[downloadtools.py] getfilefromtitle: plataforma="+plataforma)
	
	#nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
	if plataforma=="xbox":
		nombrefichero = title[:38] + url[-4:]
		nombrefichero = limpia_nombre_excepto_1(nombrefichero)
	else:
		nombrefichero = title + url[-4:]

	xbmc.log("[downloadtools.py] getfilefromtitle: nombrefichero=%s" % nombrefichero)
	fullpath = os.path.join( getDownloadPath() , nombrefichero )
	xbmc.log("[downloadtools.py] getfilefromtitle: fullpath=%s" % fullpath)
	
	return fullpath
コード例 #5
0
def downloadtitle(url,title):
	# Imprime en el log lo que va a descartar
	xbmc.output("[downloadtools.py] downloadtitle: url="+url )
	#xbmc.output("[downloadtools.py] downloadtitle: title="+urllib.quote_plus( title ))
	plataforma = xbmctools.get_system_platform();
	xbmc.output("[downloadtools.py] downloadtitle: plataforma="+plataforma)
	
	nombrefichero = xbmc.makeLegalFilename(title + url[-4:])
	
	keyboard = xbmc.Keyboard(nombrefichero)
	keyboard.doModal()
	if (keyboard.isConfirmed()):
		nombrefichero = keyboard.getText()
	
	xbmc.log("[downloadtools.py] downloadtitle: nombrefichero=%s" % nombrefichero)
	downloadpath = xbmcplugin.getSetting("downloadpath")
	xbmc.log("[downloadtools.py] downloadtitle: downloadpath=%s" % downloadpath)
	fullpath = os.path.join( downloadpath , nombrefichero )
	xbmc.log("[downloadtools.py] downloadtitle: fullpath=%s" % fullpath)
	downloadfile(url,fullpath)