Tuesday, July 23, 2013

Offline YouTube videos on your Android mobile device

So you going somewhere with time to kill, but with slow internet, or no internet. There are many YouTube videos you'd like to watch.... but can't.

It's a common problem while travelling or on vacation. There are many solutions. Here is my solution. This is for Linux people with an Android mobile device who are running a Linux computer somewhere (home, office, in the cloud, or a Raspberry Pi).  I'll refer to this computer as the 'server'.

So the idea is I use Bit Torrent Sync to communicate between the mobile device and the server. BTSync is handy because it's peer-to-peer and doesn't require any firewall configuration.

  1. Install Bit Torrent Sync on the server and run it (you'll probably want to configure the server to start this automatically on boot).
  2. Create a directory and generate a shared key for the directory. 
  3. Install Bit Torrent Sync for Android on the mobile device
  4. Create a directory and assign the key created in step 2. You can do this using QR codes.
  5. Install a simple text editor app on the Android device if you don't already have one. I use Jota.
  6. Download and install youtube-dl tool on the server if you don't already have it.
  7. Download the youtube_fetch_daemon.sh script. Review it and satisfy yourself it does what you expect it to (it's less than a screen of code). Then run it and let it continue to run. Or set it up to start on boot.
So let's say you're in an airport waiting to board. You have access to moderate WiFi, but would like to download a few videos to watch on the flight. This is how to do it:

  • Navigate to the video in the YouTube app.
  • From the menu chose 'Copy URL'.
  • In the Android text editor paste the URL and save the file as a .txt file in the directory created in step 4. This file will now transfer to your server and will cause that YouTube video to download.
  • After allowing a suitable amount of time (depending on the quality of the connection on the server and the size of the video), use the BTSync app to view remote files. If you see the video there, touch that video and it will start to download to your device.
  • Use your video player to play off local storage.
28 July 2013: Link to youtube_fetch_daemon.sh script fixed.


Scott Miller said...


Something is seriously wrong with the link to youtube_fetch_daemon.sh script.

Joe Desbonnet said...

Sorry: fixed. Something odd with Blogger editor: took a few tries before it inserted the full URL. Thanks for letting me know.