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 error when calling GetManifestAsync on suicide-restricted videos #795

Closed
4 of 6 tasks
wasd52030 opened this issue Jun 15, 2024 · 8 comments · Fixed by #820
Closed
4 of 6 tasks

403 error when calling GetManifestAsync on suicide-restricted videos #795

wasd52030 opened this issue Jun 15, 2024 · 8 comments · Fixed by #820

Comments

@wasd52030
Copy link

wasd52030 commented Jun 15, 2024

Version

6.3.16

Platform

.NET 6.0.423/Windows 11

Steps to reproduce

using YoutubeExplode;
using YoutubeExplode.Videos.Streams;

var yt=new YoutubeClient();
var url="https://www.youtube.com/watch?v=4QXCPuwBz2E";

var videotManifest=await yt.Videos.Streams.GetManifestAsync(url);

Details

Expected Behavior: Returns valid StreamManifest
Actual Behavior: HttpRequestException thrown

Complete error repor

System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at YoutubeExplode.Videos.Streams.StreamClient.TryGetContentLengthAsync(IStreamData streamData, String url, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/Streams/StreamClient.cs:line 63
   at YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(IEnumerable`1 streamDatas, CancellationToken cancellationToken)+MoveNext() in /_/YoutubeExplode/Videos/Streams/StreamClient.cs:line 114
   at YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(IEnumerable`1 streamDatas, CancellationToken cancellationToken)+System.Threading.Tasks.Sources.IValueTaskSource<System.Boolean>.GetResult()
   at YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync[T](IAsyncEnumerable`1 source) in /_/YoutubeExplode/Utils/Extensions/AsyncCollectionExtensions.cs:line 49
   at YoutubeExplode.Utils.Extensions.AsyncCollectionExtensions.ToListAsync[T](IAsyncEnumerable`1 source) in /_/YoutubeExplode/Utils/Extensions/AsyncCollectionExtensions.cs:line 49
   at YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(VideoId videoId, PlayerResponse playerResponse, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/Streams/StreamClient.cs:line 218
   at YoutubeExplode.Videos.Streams.StreamClient.GetStreamInfosAsync(VideoId videoId, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/Streams/StreamClient.cs:line 276
   at YoutubeExplode.Videos.Streams.StreamClient.GetManifestAsync(VideoId videoId, CancellationToken cancellationToken) in /_/YoutubeExplode/Videos/Streams/StreamClient.cs:line 292

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
@wasd52030
Copy link
Author

When I perform a large number of downloads at once, there is a higher probability of occurrences exceeding a certain threshold (greater than 50).

@Tyrrrz
Copy link
Owner

Tyrrrz commented Jun 16, 2024

I can definitely see it happening on CI, but I don't have the time to investigate. Any help is welcome.

@dylansunny
Copy link

I think these Youtube videos need age confirmation. That's why the downloads are not accessible.

@wasd52030
Copy link
Author

I think these Youtube videos need age confirmation. That's why the downloads are not accessible.

It displays a similar page
I knew from the start that this video was about suicide, but I just want to listen to the music
image

@Tyrrrz Tyrrrz changed the title 403 error when calling GetManifestAsync 403 error when calling GetManifestAsync on age-restricted videos Jun 28, 2024
@Tyrrrz
Copy link
Owner

Tyrrrz commented Jun 28, 2024

I had some time to investigate this issue, but unfortunately didn't come up with a solution. However, it seems that the deciphering process did not change and YoutubeExplode still performs that part correctly. My guess is that YouTube added a new form of verification for the TVHTML5 client (that we use for age-restricted videos), but I have not been able to reverse-engineer it yet.

@vadmium
Copy link

vadmium commented Jun 28, 2024

FYI I recently found that if stream URLs have an “n=. . .” query parameter, I have to transform the values or I get 403 responses. The transform function is in the player Java Script. To find the function, look where it is called, just after the .get("n") method call. For instance it is the yma function in the following.

yma = function(a) {
    var b = a.split("")
    /* . . . */
    return b.join("")
};
/* . . . */
(b = a.get("n"))
    && (b = yRa[0](b),
        a.set("n", b),
        yRa.length || yma(""))
/* . . . */
var yRa = [yma];

[Edit: discussion of the function from 2021: ytdl-org/youtube-dl#29326 (comment)]

@Tyrrrz
Copy link
Owner

Tyrrrz commented Jun 28, 2024

Thanks @vadmium.

I remember previously the n parameter was only responsible for whether the downloads are throttled or not. Is it now required to access the stream altogether?

@wasd52030 wasd52030 changed the title 403 error when calling GetManifestAsync on age-restricted videos 403 error when calling GetManifestAsync on suicide-restricted videos Jun 28, 2024
@Tyrrrz
Copy link
Owner

Tyrrrz commented Aug 7, 2024

Another video test case: https://www.youtube.com/watch?v=vcw5THyM7Jo

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants