码迷,mamicode.com
首页 > 其他好文 > 详细

数据流补全脚本

时间:2015-11-30 10:07:24      阅读:195      评论:0      收藏:0      [点我收藏+]

标签:english   channel   please   数据流   频道   

线上缓存流经常由于网络问题导致数据同步不完成,需要手动一条条下载,现在通过脚本来完成下载,但需要传入三个参数即:频道名,开始时间,结束时间。

#!/bin/bash
#传入参数
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`
endtime=`date --date="$Endtime" +%s`
echo $channel,$starttime,$endtime
Year=`date --date="$Starttime" +%Y`
Month=`date --date="$Starttime" +%m`
Date=`date --date="$Starttime" +%d`
basicDir=/opt/online01/stream
codetype=2500000

links -dump  "http://xxxx.live.tvmining.com/approve/vod?type=ipsd&channel=$channel&starttime=$starttime&endtime=$endtime" | grep http > stream.m3u8

for file in `cat stream.m3u8`
        do
                localfile=$basicDir/`echo $file | awk -F stream/ ‘{print $2}‘`
                if [ -e $localfile ];then
                        echo $localfile already exists
                else
                        if [ -e $basicDir/$codetype/$channel/$Year/$Month/$Date ];then
                                wget $file   -P $basicDir/$codetype/$channel/$Year/$Month/$Date &> /dev/null && echo "$file down sucessfully"
                        else
                                echo $basicDir/$codetype/$channel/$Year/$Month/$Date not exists && exit 12
                        fi
                fi
        done

仅作为自己学习参数

本文出自 “eagle” 博客,谢绝转载!

数据流补全脚本

标签:english   channel   please   数据流   频道   

原文地址:http://seneagle.blog.51cto.com/1319845/1718051

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!