Avoid command infinite loops, and make video downloading more robust (e.g. auto-restarting)

This includes https://github.com/learningequality/ka-lite/pull/431, and can be merged in instead of it. Additionally, includes code to auto-click the "restart download" button every 60 seconds, to allow for more fully unattended video downloads.