#!/bin/sh

urldecode(){
  echo -e "$(sed 'y/+/ /; s/%/\\x/g')"
}

URL="http://www.sport5.co.il/Articles/Article.401.9865.html"

wget -O tmp.1 $URL
wget -O tmp.2 `grep -n castup tmp.1 | grep cunet | cut -d= -f 5 | cut -d\& -f 1 | urldecode`

wget -O tmp.3 `grep castup tmp.2  | cut -d'"' -f 2 | head -1`

mencoder -oac copy -ovc copy -o t1.avi `grep -i ^ref1 tmp.3 | cut -d= -f2- `

rm tmp.[123]
