omansak / libvideo

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

Is VideoLibrary compatible with .NET MAUI? #261

Closed tjvxh closed 1 year ago

tjvxh commented 1 year ago

I see that it should be compatible with Xamarin, but would it also be compatible with .NET MAUI? I was attempting to implement a video downloader, but I received this exception.

Exception thrown: 'VideoLibrary.Exceptions.UnavailableStreamException' in System.Private.CoreLib.dll

I'm unsure if it's an issue with my implementation (I'm still new to MAUI and Xamarin) or if the library isn't compatible.

hondek commented 1 year ago

Can you show some part of your code?

hondek commented 1 year ago

Or Message from throwed UnavailableStreamException.

omansak commented 1 year ago

please share us Exception.

tjvxh commented 1 year ago

Here's the exception, sorry for the delay

VideoLibrary.Exceptions.UnavailableStreamException: Video has unavailable stream. at VideoLibrary.YouTube.ParseVideos(String source)+MoveNext() at System.Linq.Enumerable.TryGetFirst[TSource(IEnumerable1 source, Boolean& found) at System.Linq.Enumerable.First[TSource](IEnumerable1 source) at VideoLibrary.ServiceBase 1.GetVideoAsync(String videoUri, Func`2 sourceFactory) at SampleDownloader.DownloadAsVideo.DownloadVideo(String link, String saveTo)

Again, I'm not entirely sure if this is an issue with the library or with my code specifically. Here's what I'm using to download it, in my page DownloadAsVideo.xaml.cs

using (var service = Client.For(YouTube.Default))
            {
                var video = await service.GetVideoAsync(link);
            }
            if (saveTo.Length > 0)
            {
                ResultLink = Directory.GetParent(saveTo).ToString();
            }
tjvxh commented 1 year ago

I believe I have resolved the issue and it seems to work now