線上緩存流經常由於網絡問題導致數據同步不完成,需要手動一條條下載,現在通過腳本來完成下載,但需要傳入三個參數即:頻道名,開始時間,結束時間。
#!/bin/bash #Author: hudaohng #Date: #Version:1.2 read -p "please input English Channel Name:" channel read -p "please input startTime:'1970-01-01 00:00:00' " Starttime read -p "please input endTime:'1970-01-01 00:00:00' " Endtime starttime=`date --date="$Starttime" +%s 2> /dev/null` endtime=`date --date="$Endtime" +%s 2>/dev/null` echo $channel,$starttime,$endtime Year=`date --date="$Starttime" +%Y 2> /dev/null` Month=`date --date="$Starttime" +%m 2> /dev/null` Date=`date --date="$Starttime" +%d 2> /dev/null` basicDir=/opt/online01/stream codetype250=2500000 codetype150=1500000 #codetype256=256000 codetype512=512000 #codetype800=800000 TmpM3u8File=/tmp/stream.m3u8 links -dump "http://xxx.lives.lonining.com/approve/vod?type=ipsd&channel=$channel&starttime=$starttime&endtime=$endtime" | grep http > $TmpM3u8File || { echo "please check Channel:$channel,Check Time:$Starttime and $Endtime" exit 3 } stream () { for file in `cat $TmpM3u8File` do localfile=$basicDir/`echo $file | awk -F stream/ '{print $2}'` if [ -e $localfile ];then echo $localfile already exists else if [ -e $basicDir/$1/$channel/$Year/$Month/$Date ];then wget $file -P $basicDir/$1/$channel/$Year/$Month/$Date &> /dev/null && echo "$file down sucessfully" else echo $basicDir/$1/$channel/$Year/$Month/$Date not exists && exit 12 fi fi done } RETVAL=`expr $channel : .*HD\$` if [ $RETVAL -ne 0 ];then stream $codetype250 else stream $codetype150 fi
僅作爲自己學習參數