YoutubeExplode
YoutubeExplode copied to clipboard
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
- [X] I have looked through existing issues to make sure that this bug has not been reported before
- [X] I have provided a descriptive title for this issue
- [X] I have made sure that this bug is reproducible on the latest version of the package
- [X] 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
What video URL were you using?
I was trying any random video
On Thu, 26 Dec 2024, 01:58 Oleksii Holub, @.***> wrote:
What video URL were you using?
— Reply to this email directly, view it on GitHub https://github.com/Tyrrrz/YoutubeExplode/issues/853#issuecomment-2562071516, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLRUEXVCDZ7CWBCMMJ57T2HNPFJAVCNFSM6AAAAABUBRCWISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNRSGA3TCNJRGY . You are receiving this because you authored the thread.Message ID: @.***>
I get now also the 403 Firbidden error when calling var streamManifest = await youtube.Videos.Streams.GetManifestAsync(video.Id); on all the videos I try. I use also version 6.5.0. A few days ago it still worked.
hi there
been trying this now, and getting "forbidden" on any video...
Same here...
Is this happening for every1 or is just my IP blocked? Because with a browser, I can watch videos when logged-in. In Incognito mode however, videos not playing... is this a block sign?
Well, it was a temporary block. I tried again after a few days and everything worked just fine. Maybe my IP was renewed by the ISP.
Please take a look at the downloader variant I have coded: https://www.youtube.com/watch?v=cuSokN7jVCk
Still not working for me tried with a vpn aswell still no luck
On Sun, 5 Jan 2025, 21:05 udi12, @.***> wrote:
Well, it was a temporary block. I tried again after a few days and everything worked just fine. Maybe my IP was renewed by the ISP.
Please take a look of the downloader variant I have coded: https://www.youtube.com/watch?v=cuSokN7jVCk
— Reply to this email directly, view it on GitHub https://github.com/Tyrrrz/YoutubeExplode/issues/853#issuecomment-2571750614, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACOLRUFKFETDEYN3EL67A2L2JGNB7AVCNFSM6AAAAABUBRCWISVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDKNZRG42TANRRGQ . You are receiving this because you authored the thread.Message ID: @.***>
Same here...
same here
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:
response.EnsureSuccessStatusCode();
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:
[Exception] YoutubeExplode.dll!YoutubeExplode.Videos.Streams.StreamClient.TryGetContentLengthAsync(YoutubeExplode.Bridge.IStreamData streamData, string url, System.Threading.CancellationToken cancellationToken) Line 82 C# [Exception] YoutubeExplode.dll!YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(System.Collections.Generic.IEnumerable<YoutubeExplode.Bridge.IStreamData> streamDatas, System.Threading.CancellationToken cancellationToken) Line 115 C# [Exception] Microsoft.Bcl.AsyncInterfaces.dll!System.Threading.Tasks.Sources.ManualResetValueTaskSourceCore<TResult>.GetResult(short token) Unknown [Exception] YoutubeExplode.dll!YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync<T>(System.Collections.Generic.IAsyncEnumerable<T> source) Line 49 C# [Exception] YoutubeExplode.dll!YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync<T>(System.Collections.Generic.IAsyncEnumerable<T> source) Line 49 C# [Exception] YoutubeExplode.dll!YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(YoutubeExplode.Videos.VideoId videoId, YoutubeExplode.Bridge.PlayerResponse playerResponse, System.Threading.CancellationToken cancellationToken) Line 230 C# [Exception] YoutubeExplode.dll!YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(YoutubeExplode.Videos.VideoId videoId, System.Threading.CancellationToken cancellationToken) Line 275 C# [Exception] YoutubeExplode.dll!YoutubeExplode.Videos.Streams.StreamClient.GetManifestAsync(YoutubeExplode.Videos.VideoId videoId, System.Threading.CancellationToken cancellationToken) Line 304 C#
Same here
Same issue for me :(
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.
Those who experience this issue, please confirm whether you're making authenticated (with cookies) or non-authenticated (no cookies) requests.
Those who experience this issue, please confirm whether you're making authenticated (with cookies) or non-authenticated (no cookies) requests.
it doesn't work in both cases...
Getting an error with streamManifest.GetAudioOnlyStreams().GetWithHighestBitrate();
{"Video 'NzZbyv0LaJw' is unplayable. Reason: 'Please sign in'."}
Looks like they want to force logging in now.
Getting an error with streamManifest.GetAudioOnlyStreams().GetWithHighestBitrate();
{"Video 'NzZbyv0LaJw' is unplayable. Reason: 'Please sign in'."}Looks like they want to force logging in now.
Same for me, it seems a new YouTube anti-bot system. Notice that:
- Normally I can play, on YouTube website, all the videos I tried without being logged in.
- Using YouTubeExplode previous versions nothing changes
What about adding cookies? is there a setting in YoutubeExplode to add cookies?
What about adding cookies? is there a setting in YoutubeExplode to add cookies?
Yes you can add cookies. Its a System.Net.Cookiecollection https://github.com/Tyrrrz/youtubeexplode?tab=readme-ov-file#authentication
You can use WebView2 to prompt the user to login to extract the cookies. Look at how it is done in https://github.com/Tyrrrz/YoutubeDownloader
Unfortunately, there will be no way other then mimic browser behavior by the byte. Right now, youtube explode uses some kind of an iPhone hack to download whole streams., while normal browser behavior uses periodcall POST calls to download streams in chunks.
I have written a few bots in my life and the only 100% way to get the entire data is to mimic the browser 100% as if that is an actual user. Each request in the sequence of requests must be made as if a true user is using is browser.
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.
"Error: Video '1xDVbu-WaFo' is not available."
"Error: Video '1xDVbu-WaFo' is unplayable. Reason: 'Please sign in'."
@salar-dev you have to update YoutubeExplode version to 6.5.2, when you deploy make sure to build using any cpu. you also have to update some packages that YoutubeExplode needs. make sure to use netframework 4.6.2. my YoutubeExplode CLI application runs perfectly on various computers.
@LunarCreative I’m using YoutubeExplode 6.5.2 And it’s working perfectly on localhost but on the server I get
"Error: Video '1xDVbu-WaFo' is not available." Or "Error: Video '1xDVbu-WaFo' is unplayable. Reason: 'Please sign in'."
Any solution?
@salar-dev
As end solution What I did is doing the worst idea is to make a simple app in python using yt-dl and it worked perfectly NOTE: Make sure u give it cookies.txt expored by google extension named cookies to txt
same here.
var url = "https://www.youtube.com/watch?v=6v2L2UGZJAM";
var client = new YoutubeClient();
var video = await client.Videos.GetAsync(url);
VideoId videoId = video.Id;
var manifest = await client.Videos.ClosedCaptions.GetManifestAsync(videoId);
and boom ... 🫣
YoutubeExplode.Exceptions.VideoUnavailableException: 'Video '6v2L2UGZJAM' is not available.'
any idea how to capture captions ?
issue resolved after bumping package to version 6.5.2 🫣 💪
Last fix worked just a few days.. Today morning same problem here
Please post comments on issues that are actually related to the problem you're having. This issue is dedicated to the 403 Forbidden error.
- For
400 Bad Requestsee #852 - For
401 Unauthorizedsee #781
Previously there was also the please sign in error that was fixed, see #794. If you started getting that error again, leave a comment on that issue.
@Tyrrrz iOS now require PoToken