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

4 comments:

  1. Great! You saved my greying grey matter a lot of stress with this blog. Clear, concise and simple to use with the script. Thank you very much, I managed to get the job done with this :)

    ReplyDelete
  2. K writes:
    Thank you for your September instruction on downloading Hulu videos.
    Everything went along great until the video loaded and the ripinfo.txt
    file is 0 bytes. However the advertizement before the actual video
    didnt load. I am going to try and wait for the add to load first, and
    then "enter"
    ...any thoughts or suggestions.
    Thanks again. Good instructions, I am sure I am just missing some small aspect.
    K

    ================================================

    Hi K,
    This is generally how I do it-

    1) Load the page, and let the movie/video start playing
    2) Start the script
    3) Reload the page
    4) Let it go until it fails to load the movie
    5) Stop running the script

    Cheers

    ReplyDelete
  3. This script works great with PBS videos but when I try it with HULU i get this error:
    WARNING: HandShake: Type mismatch: client sent 6, server answered 9
    WARNING: HandShake: Server not genuine Adobe!
    ERROR: RTMP_Connect1, handshake failed.

    I'm on Mint 12 with FF and Chromium

    ReplyDelete
    Replies
    1. some more searching i have rtmpdump 2.3 which everything points to as not working 2.1 was fine. I will update to 2.4 then try again

      Delete