Youtubeexplode: Forbidden on some videos

Created on 17 Mar 2020  路  40Comments  路  Source: Tyrrrz/YoutubeExplode

Some videos throws 403 Forbidden http exception,
I tried to pass by constructor a new HttpClient with the right cookies to be loggedin.

Random video from logs: LanCLS_hIo4, 9ssRfVj92OA,

Any workaround?

Thanks

System.Net.Http.HttpRequestException: Response status code does not indicate success: 403 (Forbidden).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at YoutubeExplode.Internal.HttpClientEx.GetStreamAsync(HttpClient client, String requestUri, Nullable`1 from, Nullable`1 to, Boolean ensureSuccess)
   at YoutubeExplode.Internal.SegmentedHttpStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken)
   at YoutubeExplode.Internal.Extensions.CopyToAsync(Stream source, Stream destination, IProgress`1 progress, CancellationToken cancellationToken, Int32 bufferSize)
   at YoutubeExplode.YoutubeClient.DownloadMediaStreamAsync(MediaStreamInfo info, Stream output, IProgress`1 progress, CancellationToken cancellationToken)
   at YoutubeExplode.YoutubeClient.DownloadMediaStreamAsync(MediaStreamInfo info, String filePath, IProgress`1 progress, CancellationToken cancellationToken)
   at YoutubeExplode.Converter.YoutubeConverter.DownloadAndProcessMediaStreamsAsync(IReadOnlyList`1 mediaStreamInfos, String filePath, String format, IProgress`1 progress, CancellationToken cancellationToken)

image

bug caused by youtube help wanted

Most helpful comment

Thanks @MeteorBurn

I've looked into it, I think I have an idea how to solve this. The issue is that to accommodate the changes, I have to rework some parts in the library. I have already started working on it, will hopefully finish it next week if I will have the time.

All 40 comments

Which version of YTE are you using?

YoutubeExplode: 4.7.16
YoutubeExplode.Converter: 1.4.3

YoutubeExplode: 4.7.16
YoutubeExplode.Converter: 1.4.3

You can download the second Video with the Version 4.7.15 of YoutubeExplode
@TheTrigger

It seems Youtube has made changes that makes the old way of using embed to bypass age check not work any more. When using embed, the video now returns 403 error. There are similar issues with other programs, like youtube-dl.

As such, i think the whole method that uses embed is no longer working, and indeed, if you remove this line, all videos except age restricted videos work again.

I'm not sure if there is a solution atm for age restricted videos, apart from logging in.

Yeah, I know. Currently, v4.7.15 should work because it doesn't use embed page. I will invest some time into this issue later next week.

v4.7.15 not works in all videos. It worsk in most videos but i found many examples where it also returns 403 - check those for example: z0NfI2NeDHI or d_k5DUi_FqE

I've also noticed that in some videos it not returns any video and audio streams:
m3I2maZOCfs, 64e9-y9gphE

XD3M5JN1uhg - this video returns message: Video [XD3M5JN1uhg] is unplayable beacuse it requires purchase, but i am not sure if you are able to fix this.

But the most important is 403 on many videos. I hope you will have some time son to fix it :)

Cheers!

Yeah, it doesn't work on age restricted videos. Not 100% sure the fix will help with that. I know the youtube-dl project decided not to work around age restrictions and just not support them in general.

Do you mean two first videos with 403 ? or you mean videos where no streams are returned ?

I think a lot of people are waiting for his recovery. I am also a victim of this current youtube-dl

The first two videos @booonzo.
Not sure what causes empty streams.

@Tyrrrz hmmm but this video (https://www.youtube.com/watch?v=d_k5DUi_FqE) require age restriction ?

Indeed it appears not. Only the first one is age restricted.

Hey
I found a couple of next videos with some errors. Maybe you could check this in next updates
.

  1. I found some videos where no streams are returned but it throws exception with messages:
    _OTpbqtW5cY - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 64182
    FJYcURdWtMo - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 52815., lang: AR
    TWo3bkPNhuo - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 66670
    8OpY1fh8PmI - Unexpected end of content while loading JObject. Path 'args', line 1, position 71512
    cEltMkG6auQ - Unexpected end of content while loading JObject. Path 'args', line 1, position 74353
    VJy8qZ77bpE - Unexpected end of content while loading JObject. Path 'args', line 1, position 102055
    hjGrY4dKofI - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 47346
    huF4FWbAioY - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 85960
  1. In some videos there are also no streams and there is no age restriction:
    7Gzc-qQaB8g, AdCWZ7Z2hek, dAwP9Yk0Kv0, Q2vR21RrtbU

  2. Some Videos returns 403. YT Explode returns streams but can't download them (and also there is no age restriction)

There isn't much videos from 1st and 2nd point, but i am letting you to know. I am not sure how much videos returns 403 and dont want download.

I am also getting this 403 on bunch of videos, do let me know if anyone needs more example urls.

Hey
I found a couple of next videos with some errors. Maybe you could check this in next updates
.

  1. I found some videos where no streams are returned but it throws exception with messages:
    _OTpbqtW5cY - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 64182
    FJYcURdWtMo - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 52815., lang: AR
    TWo3bkPNhuo - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 66670
    8OpY1fh8PmI - Unexpected end of content while loading JObject. Path 'args', line 1, position 71512
    cEltMkG6auQ - Unexpected end of content while loading JObject. Path 'args', line 1, position 74353
    VJy8qZ77bpE - Unexpected end of content while loading JObject. Path 'args', line 1, position 102055
    hjGrY4dKofI - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 47346
    huF4FWbAioY - Unterminated string. Expected delimiter: ". Path 'args.player_response', line 1, position 85960
  2. In some videos there are also no streams and there is no age restriction:
    7Gzc-qQaB8g, AdCWZ7Z2hek, dAwP9Yk0Kv0, Q2vR21RrtbU
  3. Some Videos returns 403. YT Explode returns streams but can't download them (and also there is no age restriction)

There isn't much videos from 1st and 2nd point, but i am letting you to know. I am not sure how much videos returns 403 and dont want download.

cEltMkG6auQ - 403
VJy8qZ77bpE - 403
hjGrY4dKofI - 403
Q2vR21RrtbU - 403
The rest of the videos are OK!

I think this is a problem with parameter parsing.
Because with SaveFrom.net these videos can be downloaded, it link returns video page

How is your health @Tyrrrz ? I hope you don't have coronavirus...
Will you find some time this week ?

I am also getting this 403 on bunch of videos, do let me know if anyone needs more example urls.

@ac-lap send some examples

zO6UMuLr7t8

can't download (403), but 5 minutes later download ok

???

need list with 403? i have 80+

@HelgeStiemerling Hej, i've also noticed that some videos which were undowloadable because of 403, later when i've checked i to was ok... hmm so sometimes it is 403 and sometimes is not on the same video ? Send please some examples of videos... i will also check.

@booonzo
Hi, i have 2 zip-files: url_list_error_403.zip, here are a list of files with 403 error, in the file logging.zip is a logging file, here are in the top area 3 files with error 403, 17 minutes later the files are downloaded with no 403-error in the bottom area!
nobody know why

logging.zip
url_list_error_403.zip

since this morning (3.4.2020) downloads works again

@HelgeStiemerling not for me unfortunately.
But all of my downloads fail and they don't suddenly succeed after a few min.

@mirushas OK, have you links for me?

@HelgeStiemerling Yes, sure

34FFj_60q1U
b2DDrgm-9LE
LdU_Do8wDgA

Do you need more?

@mirushas I can all 3 files download, but i download only the audiotrack with a combination with my own software and save it as mp3

@HelgeStiemerling Thx for trying.

I also try to download only the audio using
var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
var streamInfo = streamInfoSet.Audio.OrderByDescending(s => s.Bitrate).First();

@mirushas the code is identical

@HelgeStiemerling
But when I use DownloadMediaStreamAsync(streamInfo, path) it just takes forever without doing anything or it instantly returnes 403. Do you have any suggestions? I'm using the newest version.

@mirushas without the complete code its difficult to say where is the error

It's likely that whether or not someone gets 401 is dependent on their geolocation.

@HelgeStiemerling it's literally just the following:

var client = new YoutubeClient();
var id = YoutubeClient.ParseVideoId(url);
var streamInfoSet = await client.GetVideoMediaStreamInfosAsync(id);
var streamInfo = streamInfoSet.Audio .OrderByDescending(s => s.Bitrate) .First();
await client.DownloadMediaStreamAsync(streamInfo, path + fileName);

@Tyrrrz I'm from Germany and I can watch these videos on youtube or download them using other tools.

@mirushas I have see 1 difference:
var streamInfo = streamInfoSet.Audio.WithHighestBitrate();

@HelgeStiemerling
Oh, didn't know that this existed, but it's doing the same just with FirstOrDefault.

But I don't seem too get 403 anymore just endlessly stuck downloads.
But before this 403 problem everything worked fine and I didn't change anything.

Soo @Tyrrrz will you try to fix this ?

Will try on the weekend.

Will try on the weekend.

We look forward to hearing from you.

Will try on the weekend.

We look forward to hearing from you.

Don't annoy! Expect with patience. Nobody owes anything to anyone here.

Thanks @MeteorBurn

I've looked into it, I think I have an idea how to solve this. The issue is that to accommodate the changes, I have to rework some parts in the library. I have already started working on it, will hopefully finish it next week if I will have the time.

yesterday and today works, no 403! No changes!

Yeah no 403, but sadly my downloads are still stuck endlessly

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Tyrrrz picture Tyrrrz  路  3Comments

D0vid picture D0vid  路  5Comments

severino65 picture severino65  路  3Comments

ac-lap picture ac-lap  路  7Comments

nk34player picture nk34player  路  4Comments