function crack_ep_html {
declare -a TO=("\\\u0020" "\\\u0021" "\\\u0022" "\\\u0023" "\\\u0024" "\\\u0025" "\\\u0026" "\\\u0027"
"\\\u0028" "\\\u0029" "\\\u002a" "\\\u002b" "\\\u002c" "\\\u002d" "\\\u002e" "\\\u002f"
"\\\u0030" "\\\u0031" "\\\u0032" "\\\u0033" "\\\u0034" "\\\u0035" "\\\u0036" "\\\u0037"
"\\\u0038" "\\\u0039" "\\\u003a" "\\\u003b" "\\\u003c" "\\\u003d" "\\\u003e" "\\\u003f"
"http" "\.f4v")
declare -a BY=(" " "!" "\"" "#" "$" "%" "&" "\'"
"(" ")" "*" "+" "," "-" "\." "\/"
"0" "1" "2" "3" "4" "5" "6" "7"
"8" "9" ":" ";" "<" "=" ">" "?"
"\nhttp" "\.f4v\n")
declare -i I=0
grep "f4v" $EP.html > ${EP}.txt
while [ $I -lt 34 ];do
sed "s/${TO[$I]}/${BY[$I]}/g" $EP.txt > $EP.tmp
cp $EP.tmp $EP.txt
rm $EP.tmp
I=I+1
done
grep "http://main.gslb.ku6.com/" $EP.txt > $EP.tmp
cp $EP.tmp $EP.txt
rm $EP.tmp
}
function download_ep {
EPURL=$1
EP=$2
echo "download_ep $EPURL $EP=========>"
wget $EPURL -O ${EP}.html
crack_ep_html
declare -i PARTNO=1
declare -i PARTCNT=`wc -l $EP.txt | awk '{print $1}'`
ALL_PARTS=
while [ $PARTNO -le $PARTCNT ]; do
PARTURL=`sed -n ${PARTNO}p $EP.txt`
if [ -z $PARTURL ]; then
break
fi
if [ ! -f $EP.$PARTNO.f4v ]; then
wget $PARTURL -O $EP.$PARTNO.f4v
if [ $? != "0" ]; then
rm -f $EP.$PARTNO.f4v
fi
fi
if [ -f $EP.$PARTNO.f4v ]; then
ALL_PARTS+="$EP.$PARTNO.f4v "
fi
PARTNO+=1
done
#Join all parts to a single mkv file
if [ ! -f $EP.mkv ]; then
mencoder -oac pcm -ovc copy -of lavf -o $EP.mkv $ALL_PARTS
fi
}
download_ep $1 $2
###########################################
参数1为: 酷6网视频所在网址
参数2为:视频文件名称
例如将脚本存为 get_ku6:
./get_ku6 di_renjie