YoutubeExplode icon indicating copy to clipboard operation
YoutubeExplode copied to clipboard

403 (Forbidden) on any video

Open worbarry opened this issue 10 months ago • 34 comments
trafficstars

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

worbarry avatar Dec 22 '24 10:12 worbarry

What video URL were you using?

Tyrrrz avatar Dec 26 '24 01:12 Tyrrrz

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: @.***>

worbarry avatar Dec 26 '24 02:12 worbarry

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.

dsimonubb avatar Dec 26 '24 12:12 dsimonubb

Screenshot 2024-12-29 215051 hi there been trying this now, and getting "forbidden" on any video...

udi12 avatar Dec 29 '24 19:12 udi12

Same here...

mohanadshaban avatar Dec 30 '24 09:12 mohanadshaban

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?

udi12 avatar Dec 30 '24 19:12 udi12

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

udi12 avatar Jan 05 '25 21:01 udi12

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: @.***>

worbarry avatar Jan 05 '25 21:01 worbarry

Same here...

wasd52030 avatar Jan 10 '25 16:01 wasd52030

same here

logeshpalani33 avatar Jan 11 '25 10:01 logeshpalani33

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#

flowhl avatar Jan 12 '25 20:01 flowhl

Same here

wisamidris77 avatar Jan 14 '25 21:01 wisamidris77

Same issue for me :(

vincetota avatar Jan 16 '25 09:01 vincetota

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.

flowhl avatar Jan 16 '25 09:01 flowhl

Those who experience this issue, please confirm whether you're making authenticated (with cookies) or non-authenticated (no cookies) requests.

Tyrrrz avatar Jan 19 '25 00:01 Tyrrrz

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...

vincetota avatar Jan 19 '25 14:01 vincetota

Getting an error with streamManifest.GetAudioOnlyStreams().GetWithHighestBitrate(); {"Video 'NzZbyv0LaJw' is unplayable. Reason: 'Please sign in'."}

Looks like they want to force logging in now.

rkrehn avatar Jan 22 '25 19:01 rkrehn

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:

  1. Normally I can play, on YouTube website, all the videos I tried without being logged in.
  2. Using YouTubeExplode previous versions nothing changes

hans-voralberg avatar Jan 24 '25 10:01 hans-voralberg

What about adding cookies? is there a setting in YoutubeExplode to add cookies?

LunarCreative avatar Jan 24 '25 15:01 LunarCreative

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

flowhl avatar Jan 24 '25 16:01 flowhl

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.

udi12 avatar Jan 24 '25 16:01 udi12

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.

salar-dev avatar Jan 27 '25 14:01 salar-dev

"Error: Video '1xDVbu-WaFo' is not available." "Error: Video '1xDVbu-WaFo' is unplayable. Reason: 'Please sign in'."

salar-dev avatar Jan 27 '25 14:01 salar-dev

@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 avatar Jan 27 '25 17:01 LunarCreative

@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 avatar Jan 27 '25 23:01 salar-dev

@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

wisamidris77 avatar Jan 28 '25 13:01 wisamidris77

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 🫣 💪

cichy3000 avatar Jan 30 '25 17:01 cichy3000

Last fix worked just a few days.. Today morning same problem here

ArtemRuticker avatar Jan 31 '25 09:01 ArtemRuticker

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 Request see #852
  • For 401 Unauthorized see #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 avatar Feb 03 '25 00:02 Tyrrrz

@Tyrrrz iOS now require PoToken

YT-Advanced avatar Feb 16 '25 10:02 YT-Advanced