Exemple #1
0
def downloadstr(urlsub):
	
	import downloadtools
	
	fullpath = os.path.join( config.DATA_PATH, 'subtitulo.srt' )
	if os.path.exists(fullpath):
		try:
			subtitfile = open(fullpath,"w")
			subtitfile.close()
		except IOError:
			logger.info("Error al limpiar el archivo subtitulo.srt "+fullpath)
			raise		
	ok = downloadtools.downloadfile(urlsub,fullpath)
	#xbmc.setSubtitles(fullpath)
	return ok
Exemple #2
0
def downloadstr(urlsub):

    import downloadtools

    fullpath = os.path.join(config.DATA_PATH, 'subtitulo.srt')
    if os.path.exists(fullpath):
        try:
            subtitfile = open(fullpath, "w")
            subtitfile.close()
        except IOError:
            logger.info("Error al limpiar el archivo subtitulo.srt " +
                        fullpath)
            raise
    ok = downloadtools.downloadfile(urlsub, fullpath)
    #xbmc.setSubtitles(fullpath)
    return ok
def downloadstr(urlsub):
	
	import downloadtools
	
	fullpath = os.path.join( os.getcwd(), 'resources', 'lib', 'subtitulo.srt' )
	if os.path.exists(fullpath):
		try:
			subtitfile = open(fullpath,"w")
			subtitfile.close()
		except IOError:
			logger.info("Error al limpiar el archivo subtitulo.srt "+fullpath)
			raise
	try:		
		ok = downloadtools.downloadfile(urlsub,fullpath)
	except IOError:
		logger.info("Error al descargar el subtitulo "+urlsub)
		return -1
	return ok
Exemple #4
0
def actualiza(item):
    logger.info("deportesalacarta.channels.update_sports actualiza")

    local_folder = os.path.join(xbmc.translatePath("special://home"), "addons")
    error = False
    url = "https://github.com/CmosGit/Mod_pelisalacarta_deportes/raw/addon/plugin.video.deportesalacarta-%s.zip" % item.version
    progreso = platformtools.dialog_progress("Progreso de la actualización",
                                             "Descargando...")
    filename = 'deportesalacarta-%s.zip' % item.version
    localfilename = filetools.join(config.get_data_path(), filename)
    try:
        result = downloadtools.downloadfile(url, localfilename, continuar=True)
        progreso.update(50, "Descargando archivo", "Descargando...")
        # Lo descomprime
        logger.info(
            "deportesalacarta.channels.configuracion descomprime fichero...")
        from core import ziptools
        unzipper = ziptools.ziptools()
        logger.info("deportesalacarta.channels.configuracion destpathname=%s" %
                    local_folder)
        unzipper.extract(localfilename, local_folder, update=True)
        progreso.close()
    except:
        import traceback
        logger.info("Detalle del error: %s" % traceback.format_exc())
        # Borra el zip descargado
        filetools.remove(localfilename)
        progreso.close()
        platformtools.dialog_ok(
            "Error", "Se ha producido un error extrayendo el archivo")
        return

    # Borra el zip descargado
    logger.info("deportesalacarta.channels.configuracion borra fichero...")
    filetools.remove(localfilename)
    logger.info("deportesalacarta.channels.configuracion ...fichero borrado")

    platformtools.dialog_ok("Actualizado correctamente",
                            "Versión %s instalada con éxito" % item.version)

    xbmc.executebuiltin("Container.Refresh")
Exemple #5
0
def actualiza(item):
    logger.info("deportesalacarta.channels.update_sports actualiza")

    local_folder = os.path.join(xbmc.translatePath("special://home"), "addons")
    error = False
    if not item.url:
        url = "https://github.com/CmosGit/Mod_pelisalacarta_deportes/raw/addon/plugin.video.deportesalacarta-%s.zip" % item.version
    else:
        import servertools
        urls, puede, msg = servertools.resolve_video_urls_for_playing(
            item.server, item.url, "", False, True)
        if puede:
            data_ = httptools.downloadpage(urls[0], hide=True).data
            url = scrapertools.find_single_match(
                data_, '"downloadUrl"\s*:\s*"([^"]+)"')
            if not url:
                url = scrapertools.find_single_match(
                    data_, '<a id="download_button".*?href="([^"]+)"')
            if not item.server and not url:
                try:
                    name, value = scrapertools.find_single_match(
                        data_,
                        'method="post">.*?name="([^"]+)" value="([^"]+)"')
                    post = "%s=%s" % (name, value)
                    data_ = httptools.downloadpage(urls[0], post,
                                                   hide=True).data
                    url = scrapertools.find_single_match(
                        data_, '"downloadUrl"\s*:\s*"([^"]+)"')
                except:
                    pass

            if not url:
                urls, puede, msg = servertools.resolve_video_urls_for_playing(
                    item.server, base64.b64decode(item.url))
                url = urls[0][1]

    progreso = platformtools.dialog_progress("Progreso de la actualización",
                                             "Descargando...")
    filename = 'deportesalacarta-%s.zip' % item.version
    localfilename = filetools.join(config.get_data_path(), filename)
    try:
        result = downloadtools.downloadfile(url, localfilename, [], False,
                                            True, False)
        progreso.update(50, "Descargando archivo", "Descargando...")
        # Lo descomprime
        logger.info(
            "deportesalacarta.channels.configuracion descomprime fichero...")
        from core import ziptools
        unzipper = ziptools.ziptools()
        logger.info("deportesalacarta.channels.configuracion destpathname=%s" %
                    local_folder)
        unzipper.extract(localfilename, local_folder, update=True)
        progreso.close()
    except:
        import traceback
        logger.info("Detalle del error: %s" % traceback.format_exc())
        # Borra el zip descargado
        try:
            filetools.remove(localfilename)
        except:
            pass
        progreso.close()
        platformtools.dialog_ok(
            "Error", "Se ha producido un error extrayendo el archivo")
        return

    # Borra el zip descargado
    logger.info("deportesalacarta.channels.configuracion borra fichero...")
    try:
        filetools.remove(localfilename)
    except:
        pass
    logger.info("deportesalacarta.channels.configuracion ...fichero borrado")

    platformtools.dialog_notification(
        "Actualizado correctamente",
        "Versión %s instalada con éxito" % item.version)

    xbmc.executebuiltin("Container.Refresh")
def downloadall(params,url,category):
	xbmc.output("[downloadall.py] downloadall")

	xbmc.output("[downloadall.py] DOWNLOAD_PATH=%s" % DOWNLOAD_PATH)

	lista = os.listdir(DOWNLOAD_PATH)

	xbmc.output("[downloadall.py] numero de ficheros=%d" % len(lista))

	# Crea un listado con las entradas de favoritos
	for fichero in lista:
		# El primer video de la lista
		xbmc.output("[downloadall.py] fichero="+fichero)

		if fichero!="error":
			# Descarga el vídeo
			try:
				# Lee el bookmark
				titulo,thumbnail,plot,server,url = readbookmark(fichero)
				xbmc.output("[downloadall.py] url="+url)

				# Averigua la URL del vídeo
				if (server=="Megavideo" or server=="Megaupload") and xbmctools.getPluginSetting("megavideopremium")=="true":
					if server=="Megaupload":
						mediaurl = servertools.getmegauploadhigh(url)
					else:
						mediaurl = servertools.getmegavideohigh(url)
				else:
					mediaurl = servertools.findurl(url,server)
				xbmc.output("[downloadall.py] mediaurl="+mediaurl)
				
				# Genera el NFO
				nfofilepath = downloadtools.getfilefromtitle("sample.nfo",titulo)
				outfile = open(nfofilepath,"w")
				outfile.write("<movie>\n")
				outfile.write("<title>"+titulo+")</title>\n")
				outfile.write("<originaltitle></originaltitle>\n")
				outfile.write("<rating>0.000000</rating>\n")
				outfile.write("<year>2009</year>\n")
				outfile.write("<top250>0</top250>\n")
				outfile.write("<votes>0</votes>\n")
				outfile.write("<outline></outline>\n")
				outfile.write("<plot>"+plot+"</plot>\n")
				outfile.write("<tagline></tagline>\n")
				outfile.write("<runtime></runtime>\n")
				outfile.write("<thumb></thumb>\n")
				outfile.write("<mpaa>Not available</mpaa>\n")
				outfile.write("<playcount>0</playcount>\n")
				outfile.write("<watched>false</watched>\n")
				outfile.write("<id>tt0432337</id>\n")
				outfile.write("<filenameandpath></filenameandpath>\n")
				outfile.write("<trailer></trailer>\n")
				outfile.write("<genre></genre>\n")
				outfile.write("<credits></credits>\n")
				outfile.write("<director></director>\n")
				outfile.write("<actor>\n")
				outfile.write("<name></name>\n")
				outfile.write("<role></role>\n")
				outfile.write("</actor>\n")
				outfile.write("</movie>")
				outfile.flush()
				outfile.close()
				xbmc.output("[downloadall.py] Creado fichero NFO")
				
				# Descarga el thumbnail
				xbmc.output("[downloadall.py] thumbnail="+thumbnail)
				thumbnailfile = downloadtools.getfilefromtitle(thumbnail,titulo)
				thumbnailfile = thumbnailfile[:-4] + ".tbn"
				xbmc.output("[downloadall.py] thumbnailfile="+thumbnailfile)
				try:
					downloadtools.downloadfile(thumbnail,thumbnailfile)
					xbmc.output("[downloadall.py] Thumbnail descargado")
				except:
					xbmc.output("[downloadall.py] error al descargar thumbnail")
					for line in sys.exc_info():
						xbmc.output( "%s" % line , xbmc.LOGERROR )
				
				# Descarga el video
				dev = downloadtools.downloadtitle(mediaurl,titulo)
				if dev == -1:
					# El usuario ha cancelado la descarga
					xbmc.output("[downloadall.py] Descarga cancelada")
					return
				elif dev == -2:
					# Error en la descarga, lo mueve a ERROR y continua con el siguiente
					xbmc.output("[downloadall.py] ERROR EN DESCARGA DE "+fichero)
					origen = os.path.join( DOWNLOAD_PATH , fichero )
					destino = os.path.join( ERROR_PATH , fichero )
					shutil.move( origen , destino )
				else:
					xbmc.output("[downloadall.py] Video descargado")
					# Borra el bookmark e itera para obtener el siguiente video
					filepath = os.path.join( DOWNLOAD_PATH , fichero )
					os.remove(filepath)
					xbmc.output("[downloadall.py] "+fichero+" borrado")
			except:
				xbmc.output("[downloadall.py] ERROR EN DESCARGA DE "+fichero)
				origen = os.path.join( DOWNLOAD_PATH , fichero )
				destino = os.path.join( ERROR_PATH , fichero )
				shutil.move( origen , destino )

	# Label (top-right)...
	xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
	xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
	xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )
def downloadall(params,url,category):
    logger.info("[downloadall.py] downloadall")

    logger.info("[downloadall.py] DOWNLOAD_PATH=%s" % DOWNLOAD_PATH)

    if usingsamba:
        lista = samba.get_files(DOWNLOAD_PATH)
    else:
        lista = os.listdir(DOWNLOAD_PATH)
    lista.sort()

    logger.info("[downloadall.py] numero de ficheros=%d" % len(lista))

    # Crea un listado con las entradas de favoritos
    for fichero in lista:
        # El primer video de la lista
        logger.info("[downloadall.py] fichero="+fichero)

        if fichero!="error":
            # Descarga el vídeo
            try:
                # Lee el bookmark
                titulo,thumbnail,plot,server,url = readbookmark(fichero)
                logger.info("[downloadall.py] url="+url)

                # Averigua la URL del vídeo
                if (server=="Megavideo" or server=="Megaupload") and config.getSetting("megavideopremium")=="true":
                    if server=="Megaupload":
                        mediaurl = servertools.getmegauploadhigh(url)
                    else:
                        mediaurl = servertools.getmegavideohigh(url)
                else:
                    mediaurl = servertools.findurl(url,server)
                logger.info("[downloadall.py] mediaurl="+mediaurl)
                
                # Genera el NFO
                nfofilepath = downloadtools.getfilefromtitle("sample.nfo",titulo)
                outfile = open(nfofilepath,"w")
                outfile.write("<movie>\n")
                outfile.write("<title>"+titulo+")</title>\n")
                outfile.write("<originaltitle></originaltitle>\n")
                outfile.write("<rating>0.000000</rating>\n")
                outfile.write("<year>2009</year>\n")
                outfile.write("<top250>0</top250>\n")
                outfile.write("<votes>0</votes>\n")
                outfile.write("<outline></outline>\n")
                outfile.write("<plot>"+plot+"</plot>\n")
                outfile.write("<tagline></tagline>\n")
                outfile.write("<runtime></runtime>\n")
                outfile.write("<thumb></thumb>\n")
                outfile.write("<mpaa>Not available</mpaa>\n")
                outfile.write("<playcount>0</playcount>\n")
                outfile.write("<watched>false</watched>\n")
                outfile.write("<id>tt0432337</id>\n")
                outfile.write("<filenameandpath></filenameandpath>\n")
                outfile.write("<trailer></trailer>\n")
                outfile.write("<genre></genre>\n")
                outfile.write("<credits></credits>\n")
                outfile.write("<director></director>\n")
                outfile.write("<actor>\n")
                outfile.write("<name></name>\n")
                outfile.write("<role></role>\n")
                outfile.write("</actor>\n")
                outfile.write("</movie>")
                outfile.flush()
                outfile.close()
                logger.info("[downloadall.py] Creado fichero NFO")
                
                # Descarga el thumbnail
                logger.info("[downloadall.py] thumbnail="+thumbnail)
                thumbnailfile = downloadtools.getfilefromtitle(thumbnail,titulo)
                thumbnailfile = thumbnailfile[:-4] + ".tbn"
                logger.info("[downloadall.py] thumbnailfile="+thumbnailfile)
                try:
                    downloadtools.downloadfile(thumbnail,thumbnailfile)
                    logger.info("[downloadall.py] Thumbnail descargado")
                except:
                    logger.info("[downloadall.py] error al descargar thumbnail")
                    for line in sys.exc_info():
                        logger.error( "%s" % line )
                
                # Descarga el video
                dev = downloadtools.downloadtitle(mediaurl,titulo)
                if dev == -1:
                    # El usuario ha cancelado la descarga
                    logger.info("[downloadall.py] Descarga cancelada")
                    return
                elif dev == -2:
                    # Error en la descarga, lo mueve a ERROR y continua con el siguiente
                    logger.info("[downloadall.py] ERROR EN DESCARGA DE "+fichero)
                    origen = os.path.join( DOWNLOAD_PATH , fichero )
                    destino = os.path.join( ERROR_PATH , fichero )
                    
                    # TODO: Mover en ruta compartida
                    shutil.move( origen , destino )
                else:
                    logger.info("[downloadall.py] Video descargado")
                    # Borra el bookmark e itera para obtener el siguiente video
                    filepath = os.path.join( DOWNLOAD_PATH , fichero )
                    os.remove(filepath)
                    logger.info("[downloadall.py] "+fichero+" borrado")
            except:
                logger.info("[downloadall.py] ERROR EN DESCARGA DE "+fichero)
                origen = os.path.join( DOWNLOAD_PATH , fichero )
                destino = os.path.join( ERROR_PATH , fichero )
                shutil.move( origen , destino )

    # Label (top-right)...
    xbmcplugin.setPluginCategory( handle=int( sys.argv[ 1 ] ), category=category )
    xbmcplugin.addSortMethod( handle=int( sys.argv[ 1 ] ), sortMethod=xbmcplugin.SORT_METHOD_NONE )
    xbmcplugin.endOfDirectory( handle=int( sys.argv[ 1 ] ), succeeded=True )