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

403 (Forbidden) on any video #853

Open
4 of 6 tasks
worbarry opened this issue Dec 22, 2024 · 29 comments
Open
4 of 6 tasks

403 (Forbidden) on any video #853

worbarry opened this issue Dec 22, 2024 · 29 comments

Comments

@worbarry
Copy link

worbarry commented Dec 22, 2024

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
@worbarry worbarry added the bug label Dec 22, 2024
@Tyrrrz
Copy link
Owner

Tyrrrz commented Dec 26, 2024

What video URL were you using?

@worbarry
Copy link
Author

worbarry commented Dec 26, 2024 via email

@dsimonubb
Copy link

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.

@udi12
Copy link

udi12 commented Dec 29, 2024

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

@mohanadshaban
Copy link

Same here...

@udi12
Copy link

udi12 commented Dec 30, 2024

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
Copy link

udi12 commented Jan 5, 2025

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

@worbarry
Copy link
Author

worbarry commented Jan 5, 2025 via email

@wasd52030
Copy link

Same here...

@logeshpalani33
Copy link

same here

@flowhl
Copy link

flowhl commented Jan 12, 2025

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.GetResult(short token) Unknown
[Exception] YoutubeExplode.dll!YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync(System.Collections.Generic.IAsyncEnumerable source) Line 49 C#
[Exception] YoutubeExplode.dll!YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync(System.Collections.Generic.IAsyncEnumerable 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#

@wisamidris77
Copy link

Same here

@vincetota
Copy link

Same issue for me :(

@flowhl
Copy link

flowhl commented Jan 16, 2025

After getting a new IP from my ISP the issues have not appeared again. As currently discussed in the yt-dlp thread:
yt-dlp/yt-dlp#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.

@Tyrrrz
Copy link
Owner

Tyrrrz commented Jan 19, 2025

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

@vincetota
Copy link

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

@rkrehn
Copy link

rkrehn commented Jan 22, 2025

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

Looks like they want to force logging in now.

@hans-voralberg
Copy link

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

@LunarCreative
Copy link

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

@flowhl
Copy link

flowhl commented Jan 24, 2025

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

@udi12
Copy link

udi12 commented Jan 24, 2025

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.

@salar-dev
Copy link

salar-dev commented Jan 27, 2025

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
Copy link

salar-dev commented Jan 27, 2025

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

@LunarCreative
Copy link

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

@salar-dev
Copy link

@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?

@wisamidris77
Copy link

@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

@cichy3000
Copy link

cichy3000 commented Jan 30, 2025

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

@ArtemRuticker
Copy link

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

@Tyrrrz
Copy link
Owner

Tyrrrz commented Feb 3, 2025

Please post comments on issues that are actually related to the problem you're having. This issue is dedicated to the 403 Forbidden error.

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.

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