I have created a little YouTube script that downloads all the video’s in certain YouTube channels to the hard-disk. This way I can easily watch the movies with my favourite media-player (mplayer controlled with a remote control) full-screen on my TV.

The script is ugly, but it works. I run it every hour in a cron job.

The script:

 pts/4  jan ~/youtube_script$ cat youtube
#!/bin/sh
LOG=/home/jan/youtube_script/youtube.log/
LIST=/home/jan/youtube_script/youtube.list
DOWNLOADDIR=/home/jan/youtube_downloads/

for URL in `cat $LIST` 
do 
  echo ----[start]
  echo $URL

  # change DIR to DOWNLOADDIR
  cd $DOWNLOADDIR

  # check URL
  for VIDEO in `lynx -dump "$URL" | grep watch?v | sed 's# ##g' | cut -d"." -f2-`
  do
    echo $VIDEO
    X=`echo $VIDEO | cut -d "=" -f2-`
    X=$LOG$X
    echo $X

    # Only download video when it was not downloaded before
    if [ -e $X ]
    then
      touch $X
      echo Already downloaded --skip
    else
      touch $X
      echo Downloading $X
      timelimit -t 7200 -T 360 clive $VIDEO --format=best
    fi
  done
  echo ----[end]
done

# CLEAN $LOG
find $LOG -mtime +30 -delete
 pts/4  jan ~/youtube_script$

The channels to check are in the file youtube.list, for example:

 pts/4  jan ~/youtube_script$ cat youtube.list
http://www.youtube.com/user/jan0wagemakers#p/a
http://www.youtube.com/user/RudyWumpscut#p/a
 pts/4  jan ~/youtube_script$ 

And this is what it looks like: Movie YouTube Script in action