Problem with Youtube Extractor with C #

0

Good morning

I'm trying to make an application with WindowsForm in C # to download YouTube audios . I use a Nuget package called YoutubeExtractor .

The code is as follows:

private bool DescargarAudio()
        {
            bool vf = false;
            try
            {
                VideoInfo video = videoInfos.Where(info => info.CanExtractAudio).FirstOrDefault();//OrderByDescending(info => info.AudioBitrate)
                if (video.RequiresDecryption)
                {
                    DownloadUrlResolver.DecryptDownloadUrl(video);
                }
                var audioDownloader = new AudioDownloader(video, Application.StartupPath+video.Title + video.AudioExtension,320);
                audioDownloader.Execute();
                vf = true;
            }
            catch (Exception ex)
            {
                exception = ex.Message;
            }
            return vf;
        }

The problem is that this line returns null :

VideoInfo video = videoInfos.Where(info => info.CanExtractAudio).FirstOrDefault();//OrderByDescending(info => info.AudioBitrate)

And I should return an item from the list. I tried several links and it always gives me the same. I do not know if it could be a problem with the dll or I'm doing something wrong.

Do you have a solution or is there some other package to do the same?

Greetings to all.

Happy Holidays.

    
asked by Nahuel Picca 23.12.2017 в 16:05
source

1 answer

1

Reviewing the project repository a bit, I see people reporting errors similar to yours: link

Considering that the project activity is quite inconstant , it is possible that the library has errors. I would suggest using another project such as YoutubeExplode .

EDIT: Another option is to use a combination of libraries. For example, you can use MediaToolkit to extract audio from a video that you already have. See this answer .

EDITO2: This can also help: link

    
answered by 23.12.2017 / 16:34
source