Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: YoutubeExplode.Exceptions.VideoUnavailableException #808

Closed
6 tasks done
Dopamax opened this issue Sep 1, 2024 · 6 comments
Closed
6 tasks done

Error: YoutubeExplode.Exceptions.VideoUnavailableException #808

Dopamax opened this issue Sep 1, 2024 · 6 comments

Comments

@Dopamax
Copy link

Dopamax commented Sep 1, 2024

Version

v6.4.0

Platform

.NET 8 / windows 10

Steps to reproduce

My blazor app work fine in local machine, but when I deployed it on azure app service, I got this error below

Details

[2024-09-01T15:34:42.052Z] Error: YoutubeExplode.Exceptions.VideoUnavailableException: Video 'CZr3pKM44wk' is not available.
at YoutubeExplode.Videos.VideoController.GetVideoWatchPageAsync(VideoId videoId, CancellationToken cancellationToken) in //YoutubeExplode/Videos/VideoController.cs:line 39
at YoutubeExplode.Videos.VideoClient.GetAsync(VideoId videoId, CancellationToken cancellationToken) in /
/YoutubeExplode/Videos/VideoClient.cs:line 37
at YoutaBlazorWebApp.Application.YoutubeDownloader.GetYoutaQuality720pFileStream(String videoUrl) in C:\Users\clock\source\repos\YoutaBlazorWebApp\Application\YoutubeDownloader.cs:line 165
at YoutaBlazorWebApp.Components.Pages.Home.DownloadVideoFileQuality720p() in C:\Users\clock\source\repos\YoutaBlazorWebApp\Components\Pages\Home.razor:line 77
at Microsoft.AspNetCore.Components.ComponentBase.CallStateHasChangedOnAsyncCompletion(Task task)
at Microsoft.AspNetCore.Components.RenderTree.Renderer.GetErrorHandledTask(Task taskToHandle, ComponentState owningComponentState)

Checklist

  • I have looked through existing issues to make sure that this bug has not been reported before
  • I have provided a descriptive title for this issue
  • I have made sure that this bug is reproducible on the latest version of the package
  • I have provided all the information needed to reproduce this bug as efficiently as possible
  • I have sponsored this project
  • I have not read any of the above and just checked all the boxes to submit the issue
@Dopamax Dopamax added the bug label Sep 1, 2024
@Dopamax
Copy link
Author

Dopamax commented Sep 3, 2024

@Tyrrrz what's the cause of the problem, and what's the solution ?

@lukaszfiszer96
Copy link

lukaszfiszer96 commented Sep 5, 2024

same here. Locally works fine, but on azure server got VideoUnavailableException. Any ideas ?

@okansarica
Copy link

In my case this is happening when the page content doesn't contain of:URL meta tag. This happens most probably because the page is not accessible when banned from youtube but still there is json data in the content which might be used

@socaciumugurel
Copy link

socaciumugurel commented Sep 11, 2024

My assumption, this is a duplicate of: #794

I managed to reproduce this locally, and digging dipper in the library, GetVideoWatchPageAsync from VideoController throws an exception with the message: Sign in to confirm you’re not a bot (Would be useful if this message is thrown to the client)
This message indicates that YouTube is flagging the request as potentially coming from an automated source, which could be tied to the IP address used by the machine. This could explain why it's working on some machines and not on others—YouTube may impose stricter checks based on the IP reputation or the traffic pattern.

Key Takeaways:

  • Bot Detection: YouTube is recognizing the request as coming from a bot, likely due to certain heuristics like the request frequency, user agent, or IP address.
  • IP Sensitivity: Some machines (or networks) may be flagged more easily due to IP reputation or rate-limiting.
  • Geographical/Network Factors: Machines in different locations or behind different IPs may trigger bot detection differently.

Potential Solutions:

  • Throttle Requests: Slow down the number of requests to avoid hitting YouTube's bot detection limits.
  • Use Proxies/VPN: Rotate IP addresses or use proxies to reduce the likelihood of being flagged.
  • Simulate Human-Like Behavior: Modify the request headers (e.g., user-agent, referrer) to better mimic a browser.
  • Handling Sign-In: Unfortunately, YoutubeExplode does not support authenticated sessions, so bypassing CAPTCHA or signing in programmatically is not straightforward.

@okansarica
Copy link

As I checked the source the library checks for meta tags to decide if the video is available or not but there is still json data in the response. Maybe using that json data instead of parsing HTML might be a better solution

@Tyrrrz
Copy link
Owner

Tyrrrz commented Sep 18, 2024

As @socaciumugurel said, this is a duplicate of #794.

This check seems to work based on IP ranges and it does not depend on how many requests you've made or how often you've made them. If your code is executing on a public platform (e.g. a hosted cloud provider like Azure, AWS, GCP, etc.) then it's probably going to be instantly flagged as suspicious. The same thing is happening with this project's CI workflow runs: https://github.com/Tyrrrz/YoutubeExplode/actions/runs/10926592976.

Immediate solutions are:

  • Create an authenticated session by supplying the corresponding cookies
  • Use a proxy server to mask the origin of your requests
  • Host your application elsewhere

None of these are easy, but that's kind of the point.

@Tyrrrz Tyrrrz added duplicate and removed bug labels Sep 18, 2024
@Tyrrrz Tyrrrz closed this as completed Sep 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants