mercoledì 9 marzo 2011

Life without flash: tube script improved

An improved version of my tube script.
With this edit URLs is not needed.
It extracts the VIDEO_ID and generates the URL.
It works with youtbe and vimeo only.


Call it in this way:
tube "http://vimeo/or/youtube/url"

#!/bin/bash
if [ `echo "$1" | grep vimeo` ]
  then
    VIDEO_ID=`echo "$1" | tr "=" "\n" | grep "&server" | tr -d [:alpha:] | tr -d "&"`
    VIDEO_URL="http://vimeo.com/$VIDEO_ID"
elif [ `echo "$1" | grep youtube` ]
  then
    if [ ! `echo "$1" | grep watch` ]
      then
        VIDEO_ID=`echo "$1" | awk -F "?" '{print $1}' | awk -F "/" '{print $5}'`
    else
        VIDEO_ID=`echo "$1" | awk -F "&" '{print $1}' | awk -F "=" '{print $2}'`
    fi
    VIDEO_URL="http://www.youtube.com/watch?v=$VIDEO_ID"
fi
clive --stream-exec="mplayer -really-quiet %i" -s $VIDEO_URL

Nessun commento:

Posta un commento