Skip to content
This repository has been archived by the owner on Dec 3, 2023. It is now read-only.

always add range header on data request #285

Merged

Conversation

fredericgermain
Copy link
Contributor

Hi !

I notice the download was very slow for audio, so I compared with python youtube-dl.
I find out that the youtube server is really slow if the Range: header is missing.
This commit always adds a Range: header

Fixes #251

@Kikobeats
Copy link
Collaborator

Awesome, thanks for that!

is this a thing that is related with an specific provider (e.g., YouTube) or potentially could speed up any download?

@fredericgermain
Copy link
Contributor Author

It's really related to youtube, and maybe only audio downloads? I was only interested in audio and didn't check on video that much, but I don't see any problem on the tests.

This header makes a huge difference on how fast the youtube server send data. But I have no idea why, it shouldn't be necessary from HTTP spec.
It looks like the server makes pauses every ~130672 bytes when no range, so I added 3:20 music video for test. Without the range hack, npm run test takes around 2mins. Sometimes more the 3mins and then the transfer timeout and the test fails. With range header, it's around 40s (the audio download is < 1s).

I also made a commit to fix test on node 12 (and 10). It seems there are still some failures with node 8...

@Kikobeats Kikobeats merged commit 413a9e4 into przemyslawpluta:master Jan 13, 2020
@Kikobeats
Copy link
Collaborator

Kikobeats commented Jan 13, 2020

Thanks for the explanation! I want to drop node8 in the next version, stay tuned!

@mayeaux
Copy link

mayeaux commented Jan 13, 2020

Nice work @fredericgermain !

@fredericgermain
Copy link
Contributor Author

Thanks for the new already available version 3.0.0 ! :)

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

Successfully merging this pull request may close these issues.

Downloading audio very slow when calling node-youtube-dl whereas calling the binary directly is quick
3 participants