Yay Dash C

(2011)

I think our internet is rate-limited. That's annoying because I don't do any of the stuff that maybe deserves it (looking at you BitTorrent!). I haven't exactly quantified the problem yet, but the main symptom is a very reasonable rate of 300K or so dropping to 3K-5K after the first 1-2 Mb. Since many webpages are in the 1-2Mb range (or substantially smaller), it isn't a big deal for regular browsing, but video becomes basically unwatchable. I'm not sure if the rate-limiting is on specific types of files (video) or everything.. or maybe I'm just imagining the whole thing.

Either way - Dialup is so 1999. Right?!

Thankfully, there's youtube-dl, which downloads youtube videos for offline viewing. Unfortunately, the rate-limiting is still problematic. After a couple of MB, the rate drops and the download effectively stops (and doesn't appear to recover if you leave it running for awhile). Youtube-dl has a "-c" option (just like wget) which tries to continue your previous download instead of starting over.

A totally garbage solution that works: just restart the download every 10 seconds until it's done. You get the good rate for a few seconds and restart every time the rate drops. This works.. but doing it by hand is annoying (or unfeasible for a big file). A better solution is to have a script that runs youtube-dl automatically for 10 seconds, kills it, restarts it, and repeats until the file is completely downloaded.

So it would be nice to have a way to run a program for a certain number of seconds. People much smarter than me have already figured this out in the form of a bash script:

http://www.bashcookbook.com/bashinfo/source/bash-4.0/examples/scripts/timeout3

You can use it like this:

timeout 10 youtubedl -c "url_of_youtube_video"

So that works, now just wrap it up in a loop. 10 tries is probably enough to get a video. I know there are smarter ways to check for completion, but I'm pretty lazy and this is good enough:

for i in {1..10}
do
timeout 10 youtubedl -c "url_of_youtube_video"
done

Not exactly as good as just watching videos in the browser, but it resolves my frustration anyway.