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

Feature Request: improve youtube-dl for connections with packet-loss #11161

Closed
rofl0r opened this issue Nov 10, 2016 · 6 comments
Closed

Feature Request: improve youtube-dl for connections with packet-loss #11161

rofl0r opened this issue Nov 10, 2016 · 6 comments

Comments

@rofl0r
Copy link

@rofl0r rofl0r commented Nov 10, 2016

  • I've verified and I assure that I'm running youtube-dl 2016.11.08.1
  • No, i'm using 2016.10.21.1 since i couldnt reproduce the specific weather-dependent conditions since then, and this is a general issue most unlikely to have been implemented in the last week.

Before submitting an issue make sure you have:

  • At least skimmed through README and most notably FAQ and BUGS sections
  • Searched the bugtracker for similar issues including closed ones

What is the purpose of your issue?

  • Bug report (encountered problems with youtube-dl)
  • Site support request (request for adding support for a new site)
  • Feature request (request for a new functionality)
  • Question
  • Other

Description of your issue, suggested solution and other information

Sometimes when there is very bad weather, my 3G link has a lot of packet loss - up to 50%.
This is not a huge problem per se - for example regular HTTP stuff etc works well because of retransmission of lost packets. HOWEVER since these days everything is httpS, under these conditions the initial connection handshake to make a new TLS connection is very unlikely to succeed. Even less unlikely is that all of the up-to-five HTTPS requests made by youtube-dl to gather information about a youtube video succeed.
So it takes up to 10 minutes to have the good luck that all 5 downloads (youtube webpage, information webpage, player webpage, metadata webpage, etc) succeed in a row so that youtube-dl can start downloading. ONCE IT DOWNLOADS, EVERYTHING IS FINE (almost). because really the only problematic thing is the handshake. if the connection once is open, retransmission of lost packets will make sure that even under these bad conditions i can download with over 1 MBit/s. What then eventually happens, is that the connection gets interrupted completely for a moment - and youtube-dl hangs until it finally hits its read-timeout (which seems to be rather huge - in the order of several minutes).
Then the Fun begins again (after hitting CTRL-C and restarting the job).
Even worse when downloading several videos from a playlist, because youtube-dl will always start with the first video from the list, download all 5 informational pages, just to see then that the file is already there, then to the next... so if you're stuck on the 5th video, there are zero percent changes of getting so far that the download can resume.

My proposal now would be that, until a job is 100% complete (so if downloading a playlist, until all videos are downloaded) that youtube-dl caches all of the information it downloads previous to downloading the actual videos, and finally when everything is complete all the files in the cache can be removed.
so in the case of downloading a playlist that was previously interrupted at the 5th video, youtube-dl would read the cached playlist file, then read all the cached information about the first video, see that it is already completely, then read all of the cached information of the second etc until the fifth, and then here would actually for the first time make a connection to the internet.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Nov 10, 2016

Use --download-archive.

@dstftw dstftw closed this Nov 10, 2016
@rofl0r
Copy link
Author

@rofl0r rofl0r commented Nov 10, 2016

i've seen this here when searching for similar issues:
#8486
but it says this is only for playlists, but my issue is not playlist-specific.

@rofl0r
Copy link
Author

@rofl0r rofl0r commented Nov 10, 2016

also, if --download-archive fixes this, which according to #8486 it doesnt, it should be enabled by default, and not require the user to read through the wall of text from youtube-dl --help output to have this sane behavior.

@dstftw
Copy link
Collaborator

@dstftw dstftw commented Nov 10, 2016

Caching won't work in general since data may be bound to concrete session, IP, expire after some period of time and so on.
--download-archive is not supposed to fix flaky connections, it allows skipping already downloaded videos having only it's id. It can't be default since it accepts a mandatory argument and it does not make sense for those who don't care about download archive.

@rofl0r
Copy link
Author

@rofl0r rofl0r commented Nov 11, 2016

so can we maybe reopen this and see if someone else has an interesting suggestion or idea, @dstftw ?

@yan12125
Copy link
Collaborator

@yan12125 yan12125 commented Nov 11, 2016

because really the only problematic thing is the handshake

From this sentence, I guess what you need is a new SSL feature called client-side SSL session management, which will be included in CPython 3.6. See http://bugs.python.org/issue19500

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

Successfully merging a pull request may close this issue.

None yet
3 participants
You can’t perform that action at this time.