omansak / libvideo

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

Obtaining the URL for a specific video and resolution #276

Closed RubenGarcia closed 10 months ago

RubenGarcia commented 1 year ago

Can you add an example in the documentation about querying the specific URL which will be downloaded when using video.GetBytes()? This would allow users to pass this url to a Unity VideoPlayer component, which would then allow downloading-as-you-view.

RubenGarcia commented 1 year ago

video.Uri gives the default URL.

I could not find documentation about the second (optional) parameter Func<string, Task> sourceFactory, which I guess is used to select the resolution and bitrate.

omansak commented 10 months ago

Can u see this https://github.com/omansak/libvideo/blob/master/docs/README.md ?

RubenGarcia commented 10 months ago

I can see the README file, but I still don't know how to get the uris of the different videos. Can they be accessed inside videoInfos somewhere?

omansak commented 10 months ago

All var videoInfos = Client.For(YouTube.Default).GetAllVideosAsync(uri).GetAwaiter().GetResult();

Specific var maxResolution = videoInfos.First(i => i.Resolution == videoInfos.Max(j => j.Resolution));

PS: https://github.com/omansak/libvideo/issues/198

RubenGarcia commented 10 months ago

Ah, so maxResolution is not the maximum resolution, but the information about the specific video, where the url can be accessed? So maxResolution.Uri is what I want. I'll test it tomorrow.

omansak commented 10 months ago

i will close that @RubenGarcia , if you ok ?

RubenGarcia commented 10 months ago

I did not have time to test, but you can close and I'll reopen if I still have issues.

RubenGarcia commented 9 months ago

I confirm I can chose the desired resolution now. Next step: find the audio stream for videos with no audio.