omansak / libvideo

A lightweight .NET library to download YouTube videos.
BSD 2-Clause "Simplified" License
553 stars 163 forks source link

Erro resolution, the resolution not exist in video #187

Closed AndreZila01 closed 3 years ago

AndreZila01 commented 3 years ago

Hey everyone,

I have one problem in my project and i cann't "jump" this step. If i try download one video, for example and the project give my 'Object reference not set to an instance of an object.'.

At the moment i have this code:

```using (var cli = Client.For(YouTube.Default)){
    try
    {
        link = txt.Text;
        var videoInfos = await cli.GetAllVideosAsync(link);
        try
        {

            var downloadInfo = videoInfos.Where(i => i.Format == VideoFormat.Mp4 && (i.Resolution ==    int.Parse(cboResolucao.Text))).FirstOrDefault();//cboResolucao=720;
            downloadUri = downloadInfo.Uri;//<-Error there 

            File.WriteAllBytes(textBox1.Text + @"\" + downloadInfo.FullName, downloadInfo.GetBytes());//paths where i save file.
        }catch{}
    }catch{}
}´´´

Thanks very much

omansak commented 3 years ago

Hi; Thank you for issue. your related video have {144,240,360,480}p resolutions. what is the int.Parse(cboResolucao.Text) code's result ?

AndreZila01 commented 3 years ago

image

omansak commented 3 years ago

your resulution is hard coded values ?

AndreZila01 commented 3 years ago

148