Wednesday, September 26, 2012

How to download Hulu videos on Linux

UPDATE:

2013-08-29
The instructions on this page no longer seem to work properly with some or all videos. I'm leaving it posted for reference purposes. The php Huleech project may work for you, if you have a server setup.


 Intro

Downloading Hulu, bbc, pbs, and other videos on Linux is remarkably simple- once you know how. It took me quite a bit of digging to figure it out though.

These websites use a type of video transmission called rtmp, and this prevents them from being downloaded more easily, like good and trust worthy youtube videos.

Install

To download rtmp videos, you will first need to have installed the latest version of rtmpdump. (As of the time of this writing the latest version is rtmpdump 2.4) You may be able to easily install this package using your distributions software center.

After installing rtmpdump you should have access to 3 commandline programs: rtmpdump, rtmpsrv, and rtmpsuck.

Local Script

Create a folder named "rtmp" (or whatever you like) to download your videos to.

In that folder, save this as a file named "riprtmp.sh"
#!/bin/bash
# riprtmp.sh

# Redirect rtmp internet signals locally.
sudo iptables -t nat -A OUTPUT -p tcp --dport 1935 -j REDIRECT

# load video into browser and run rtmpsrv
exec 2> /dev/null # Comment out this line if having problems.
rtmpsrv | grep "rtmpdump" | tee ripinfo.txt &
echo "Press enter after trying to load video"
read i
killall rtmpsrv
echo "Output sent to ripinfo.txt"

# Undo previous redirect for rtmp signals.
sudo iptables -t nat -D OUTPUT -p tcp --dport 1935 -j REDIRECT


After saving the file, be sure to set executable permissions so that you can run it as a script: chmod +x riprtmp.sh. This script will be used to collect the info we need for rtmpdump to download the video locally.

How To Run It

At this point everything should be ready! Here are the steps to get the video you want to download.
  • Open a commandline and navigate to your "rtmp" directory.
  • Begin running the script ./riprtmp.sh. It will prompt for administrator access, and you need to enter your password.
  • Try to load the video in Firefox (the video should fail to load because it is being redirected to rtmpsrv in the script).
  • After the video fails to load, go back to the script and press Enter.
  • A new file now exists called "ripinfo.txt". Open this file.
  • Inside the "ripinfo.txt" there should be a long line that starts with "rtmpdump".
  • Copy and paste that long "rtmpdump" line into the commandline and press Enter.
  • Your video should now be downloading.


Happy offline video watching.
Comment or leave feedback sepero 111 @ gmx . com