Youtubeexplode: The response ended prematurely

Created on 25 Nov 2020  Â·  8Comments  Â·  Source: Tyrrrz/YoutubeExplode

This video is not downloadable with your client: https://www.youtube.com/watch?v=rFCE6XpC2cw

Enter YouTube video ID or URL: rFCE6XpC2cw
Downloading stream: 720p / mp4... Completed √
Unhandled exception. System.IO.IOException: The response ended prematurely, with at least 88354044 additional bytes expected.
   at System.Net.Http.HttpConnection.ContentLengthReadStream.ReadAsync(Memory`1 buffer, CancellationToken cancellationToken)
   at YoutubeExplode.ReverseEngineering.YoutubeMediaStream.ReadAsync(Byte[] buffer, Int32 offset, Int32 count, CancellationToken cancellationToken) in YoutubeExplode\YoutubeExplode\ReverseEngineering\YoutubeMediaStream.cs:line 88
   at YoutubeExplode.Internal.Extensions.StreamExtensions.CopyBufferedToAsync(Stream source, Stream destination, Byte[] buffer, CancellationToken cancellationToken) in YoutubeExplode\YoutubeExplode\Internal\Extensions\StreamExtensions.cs:line 13
   at YoutubeExplode.Internal.Extensions.StreamExtensions.CopyToAsync(Stream source, Stream destination, IProgress`1 progress, CancellationToken cancellationToken) in YoutubeExplode\YoutubeExplode\Internal\Extensions\StreamExtensions.cs:line 28
   at YoutubeExplode.Videos.Streams.StreamClient.CopyToAsync(IStreamInfo streamInfo, Stream destination, IProgress`1 progress, CancellationToken cancellationToken) in YoutubeExplode\YoutubeExplode\Videos\Streams\StreamClient.cs:line 310
   at YoutubeExplode.Videos.Streams.StreamClient.DownloadAsync(IStreamInfo streamInfo, String filePath, IProgress`1 progress, CancellationToken cancellationToken) in YoutubeExplode\YoutubeExplode\Videos\Streams\StreamClient.cs:line 320
   at YoutubeExplode.DemoConsole.Program.Main() in YoutubeExplode\YoutubeExplode.DemoConsole\Program.cs:line 40
   at YoutubeExplode.DemoConsole.Program.<Main>()
bug caused by youtube

Most helpful comment

No idea. The problem is that YouTube returns a response, but ends it prematurely. We can't tell YouTube to make a proper response. In fact, YouTube's frontend is known to be filled with lots of bugs which are mostly worked around with try/catches and retries.

All 8 comments

What target framework are you running on and which version of YoutubeExplode?

I'm running your latest source code of YoutubeExplode.DemoConsole (cloned from GitHub) which is based on .net5.0.

Checked and can reproduce. The error is on YouTube's end, there is nothing we can do.

Responding because I have the same issue!

"Nothing we can do", does this mean other similar libraries run into the same issue?

No idea. The problem is that YouTube returns a response, but ends it prematurely. We can't tell YouTube to make a proper response. In fact, YouTube's frontend is known to be filled with lots of bugs which are mostly worked around with try/catches and retries.

I'm running your latest source code of YoutubeExplode.DemoConsole (cloned from GitHub) which is based on .net5.0.

How can one use YoutubeExplode.DemoConsole to test functionality? It appears that something changed today and get video stopped working.

@qtlin
First install the .NET Core SDK 5x, and then open the command line and navigate to the root folder of the app. Now run dotnet run command to build and run the application from its source code.

Thank you, @VahidN , I was able to run YoutubeExplode.DemoConsole on both, Windows and Linux.

Was this page helpful?
0 / 5 - 0 ratings