Tyrrrz / YoutubeExplode

Abstraction layer over YouTube's internal API
MIT License
2.98k stars 497 forks source link

The response ended prematurely #483

Closed VahidN closed 3 years ago

VahidN commented 4 years ago

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>()
Tyrrrz commented 4 years ago

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

VahidN commented 4 years ago

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

Tyrrrz commented 4 years ago

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

HannahKiekens commented 4 years ago

Responding because I have the same issue!

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

Tyrrrz commented 4 years ago

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.

qtlin commented 3 years ago

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.

VahidN commented 3 years ago

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

qtlin commented 3 years ago

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