YoutubeExplode: 403 (Forbidden) on any video
Version
6.5.0
Platform
.NET 8
Steps to reproduce
static class Program
{
static async Task Main(string[] args)
{
Console.WriteLine("Youtube VideoDownloader");
Console.WriteLine("");
Console.Write("Enter URL: ");
var videoUrl = Console.ReadLine();
if (videoUrl != null)
{
await Download(videoUrl);
}
}
private static async Task Download(string videoUrl)
{
var youtube = new YoutubeClient();
var video = await youtube.Videos.GetAsync(videoUrl);
var streamManifest = await youtube.Videos.Streams.GetManifestAsync(videoUrl);
var streamInfo = streamManifest
.GetVideoOnlyStreams()
.Where(s => s.Container == Container.Mp4)
.GetWithHighestVideoQuality();
IProgress<double> progress = new Progress<double>(p => Console.Write($"Progress updated: {p}"));
await youtube.Videos.Streams.DownloadAsync(streamInfo, $"video.{streamInfo.Container}", progress);
}
}
Details
Download video file
result Unhandled exception. System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
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
About this issue
- Original URL
- State: open
- Created 2 years ago
- Reactions: 2
- Comments: 34 (3 by maintainers)
it doesn’t work in both cases…
Last fix worked just a few days… Today morning same problem here
It’s work In local but not on server! Foe example I host my dotnet app on monsterasp.net I get “Error: Video ‘1xDVbu-WaFo’ is not available.” for metadata and for streams I get “Error: Video ‘1xDVbu-WaFo’ is unplayable. Reason: ‘Please sign in’.” but on local when I debug my dotnet code or run it with “dotnet run” its work.
Same for me, it seems a new YouTube anti-bot system. Notice that:
Getting an error with streamManifest.GetAudioOnlyStreams().GetWithHighestBitrate();
{"Video 'NzZbyv0LaJw' is unplayable. Reason: 'Please sign in'."}Looks like they want to force logging in now.
After getting a new IP from my ISP the issues have not appeared again. As currently discussed in the yt-dlp thread: https://github.com/yt-dlp/yt-dlp/issues/11868 I assume the 403 is part of youtubes anti-bot changes. As they are probably rolling this out step by step, only some users experience the issue. Also youtube might be doing some A/B testing which also causes only some users to have issues. Providing cookies might help to either get a session where the change is not rolled out yet or being logged in makes the session more trusted by youtube.
Same issue here on version 6.4.2 and 6.5.1: System.Net.Http.HttpRequestException: ‘Response status code does not indicate success: 403 (Forbidden).’ at last line of TryGetContentLengthAsync:
Same issue with all videos I have tested. Location is Germany, if that matters. Same result on VPN. Using youtube in incognito mode works without problems. I can provide further information and help debugging if wanted.
Callstack: