omansak / libvideo

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

403 (Forbidden) #288

Closed fchb1239 closed 1 month ago

fchb1239 commented 1 month ago

When I run the code on an Android device, it returns 403 (Forbidden). The code snippet works fine on Windows.

omansak commented 1 month ago

Which development framework for the Android platform do you use: MAUI, Xamarin, or Blazor?

fchb1239 commented 1 month ago

It's for Meta Quest, which yes, uses Android as its base operating system. I am attempting to have a small video viewer in my Unity game where I can feature YouTube videos of different creators. Any assistance would be of great value to me 🙂

Aequitas00 commented 1 month ago

YoutubeExplode has the same issue. Check out https://github.com/Tyrrrz/YoutubeExplode/issues/817.

They are working on a fix over there if someone wants to work on this to also do the same.

Likely culprit was discovered in this comment: https://github.com/Tyrrrz/YoutubeExplode/issues/817#issuecomment-2374617842

Aequitas00 commented 1 month ago

I could try to make the changes myself. It seems that using this fix no longer returns muxed streams so it may break a lot of code. So it's either video OR audio. Not both. Could combine them possibly before returning.

Aequitas00 commented 1 month ago

Made the PR, feel free to check out. I verified that I can still open and use the files once downloaded.

Just know that with this fix, muxed content is no longer included with the IOS client. So you when you download it, it is either the video or the audio. Muxing will have to be done manually. It seems Youtube is going away from muxed content so if there are other clients that work they most likely will lose mux support in the future.

fchb1239 commented 1 month ago

I tested your PR, sadly I am having the same issue.

omansak commented 1 month ago

Thanks to @Aequitas00 for helping us and him PR. Youtube sometimes changes some security thing, Normally Youtube need Descramble 'n' signature but we could not resolve the signature without any JS engine so we decided to use Android agent and It was working perfectly untill this week. Youtube changed again some things and Android agent no longer work. However IOS agent works perfectly (no longer muxed streams SAD 😞).

291 works perfectly. New version will drop out on Nuget

Related: #289 #291

crazybmanp commented 1 month ago

So after this update, this library only fetches the video content and not audio? Is that the new intended behavior?

Aequitas00 commented 1 month ago

They will still both be available. You just need to get them from two different streams. GetAllVideosAsync() will return all the streams related to the video. You can find both the video and the audio from this then combine them later if you need to. I think you can use the AdaptiveKind enum on the YoutubeVideo class to tell the difference. If that's not it, then you can check if it has a resolution or audiobitrate to tell them apart.