elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado:


+  Foro de elhacker.net
|-+  Programación
| |-+  Programación General
| | |-+  .NET (C#, VB.NET, ASP) (Moderador: kub0x)
| | | |-+  Ayuda con Nuget Descarga Video
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: Ayuda con Nuget Descarga Video  (Leído 1,871 veces)
rigorvzla

Desconectado Desconectado

Mensajes: 213


Ver Perfil
Ayuda con Nuget Descarga Video
« en: 31 Enero 2018, 01:02 am »

Hola nuevamente , estoy usando un codigo capaz de bajar videos de youtube y funciona de manera espectacular mi problema es que no se como direccionar el archivo descargado a una carpeta que yo le asigne.
Tyrrrz/YoutubeExplode

Es ese el codigo que uso, y tome de prueba el codigo que tiene de ejemplo llamado "ConsoleDemo"

este se utiliza pegando la direccion del video de youtube pero lo crea en el mismo directorio raiz, si alguien lo ha usado que me pueda ayudar le estare muy agradecido.

Aqui el codigo que plantea

Código
  1. using System;
  2. using System.IO;
  3. using System.Threading.Tasks;
  4. using Tyrrrz.Extensions;
  5. using YoutubeExplode;
  6. using YoutubeExplode.Models.MediaStreams;
  7.  
  8. namespace DemoConsole
  9. {
  10.    public static class Program
  11.    {
  12.        /// <summary>
  13.        /// If given a YouTube URL, parses video id from it.
  14.        /// Otherwise returns the same string.
  15.        /// </summary>
  16.        private static string NormalizeId(string input)
  17.        {
  18.            if (!YoutubeClient.TryParseVideoId(input, out var id))
  19.                id = input;
  20.            return id;
  21.        }
  22.  
  23.        /// <summary>
  24.        /// Turns file size in bytes into human-readable string
  25.        /// </summary>
  26.        private static string NormalizeFileSize(long fileSize)
  27.        {
  28.            string[] units = { "B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB" };
  29.            double size = fileSize;
  30.            var unit = 0;
  31.  
  32.            while (size >= 1024)
  33.            {
  34.                size /= 1024;
  35.                ++unit;
  36.            }
  37.  
  38.            return $"{size:0.#} {units[unit]}";
  39.        }
  40.  
  41.        private static async Task MainAsync()
  42.        {
  43.            // Client
  44.            var client = new YoutubeClient();
  45.  
  46.            // Get the video ID
  47.            Console.Write("YouTube URL: ");
  48.            var id = Console.ReadLine();
  49.            id = NormalizeId(id);
  50.  
  51.            // Get the video info
  52.            Console.WriteLine("Cargando...");
  53.            var video = await client.GetVideoAsync(id);
  54.            Console.WriteLine('-'.Repeat(100));
  55.  
  56.            // Print metadata
  57.            Console.WriteLine($"Id: {video.Id} | Title: {video.Title} | Author: {video.Author}");
  58.  
  59.            // Get media stream info set
  60.            var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
  61.  
  62.            // Get the most preferable stream
  63.            Console.WriteLine("Buscando la mejor calidad de video...");
  64.            var streamInfo = streamInfoSet.Muxed.WithHighestVideoQuality();
  65.            var normalizedFileSize = NormalizeFileSize(streamInfo.Size);
  66.            Console.WriteLine($"Quality: {streamInfo.VideoQualityLabel} | Container: {streamInfo.Container} | Size: {normalizedFileSize}");
  67.  
  68.            // Compose file name, based on metadata
  69.            var fileExtension = streamInfo.Container.GetFileExtension();
  70.            var fileName = $"{video.Title}.{fileExtension}";
  71.  
  72.            // Replace illegal characters in file name
  73.            fileName = fileName.Replace(Path.GetInvalidFileNameChars(), '_');
  74.  
  75.            // Download video
  76.            Console.WriteLine($"Descargando [{fileName}]...");
  77.            Console.WriteLine('-'.Repeat(100));
  78.  
  79.            var progress = new Progress<double>(p => Console.Title = $"Gestor de Descarga YouTube [{p:P0}]");
  80.            await client.DownloadMediaStreamAsync(streamInfo, fileName, progress);
  81.  
  82.            Console.WriteLine("Descarga completa!");
  83.            Console.ReadKey();
  84.        }
  85.  
  86.        public static void Main(string[] args)
  87.        {
  88.            // This demo prompts for video ID, gets video info and downloads one media stream
  89.            // It's intended to be very simple and straight to the point
  90.            // For a more complicated example - check out the WPF demo
  91.  
  92.            Console.Title = "Gestor de Descarga YouTube";
  93.  
  94.            // Main method in consoles cannot be asynchronous so we run everything synchronously
  95.            MainAsync().GetAwaiter().GetResult();
  96.        }
  97.    }
  98. }


« Última modificación: 1 Febrero 2018, 04:16 am por Eleкtro » En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Descarga de un video en flash
Multimedia
abelsfc 1 2,451 Último mensaje 7 Diciembre 2009, 13:24 pm
por Songoku
[VB.NET] Descarga video YouTube
.NET (C#, VB.NET, ASP)
syntax 4 6,487 Último mensaje 22 Mayo 2011, 19:53 pm
por [D4N93R]
Descarga de un video.
Software
JBenito 1 1,369 Último mensaje 19 Marzo 2012, 18:14 pm
por Eleкtro
Es posible obtener el código de un paquete de NuGet?
.NET (C#, VB.NET, ASP)
z3nth10n 2 1,989 Último mensaje 22 Febrero 2017, 10:32 am
por z3nth10n
Ayuda con Nuget Descarga Mp3
.NET (C#, VB.NET, ASP)
rigorvzla 7 3,636 Último mensaje 30 Enero 2018, 16:50 pm
por rigorvzla
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines