#setlinebreak(on)
*GetAG.sh [#eac30d3e]
AGQRのflash player対応にともないrtmp化したため保存スクリプトを用意しました。
とりあえず、説明なしであげておきます。

最新のスクリプトは[[GitHub:https://github.com/sarami55/script]]にあります。

#sh("bash"){{
#!/bin/sh
export PATH=$PATH:/home/user/bin:/sbin:/bin:/usr/sbin:/usr/bin:/usr/games:/\usr/local/sbin:/usr/local/bin
export LD_LIBRARY_PATH=/home/user/lib
export PERL5LIB="/home/user/lib/perl5/lib/perl5:/home/user/lib/perl5/li\b/perl5/perl5/i386-freebsd-64int"

# args check
if [ $# -ne 8 ]; then
        echo "usage : $0 OUTFILE_SUFFIX  REC_TIME(s)  "\
             "STREAM(V/A)  UPLOAD(0/1) COMMENT  DL_PASS  RM_PASS  BIWEEK(0/1)"
        exit 1;
fi

SUFFIX=AG-$1
REC_TIME=$2
STREAM=$3
UPLOAD_F=$4
COMMENT=$5
DL_PASS=$6
RM_PASS=$7
BIWEEK_F=$8

ftpaccount_pass='user:pass':jh8tgv;
ftpurl="ftp://ftp.4shared.com";
working_dir=/home/user/REC
check_biweek_dir=/home/user/100

now=`date '+%Y-%m-%d-%H%M'`;
ftpdir=Public/Radio/`date '+%Y-%m'`;

check_date=`date -v -1w '+%Y-%m-%d-%H%M'`;
check_file=$check_date-$SUFFIX

if ( [ $BIWEEK_F -eq 9 ] ); then
        today=`date -v -6H '+%d'`;
        weekly=`date -v -6H '+%u'`;

        checkmonday=$(expr $today - $weekly  + 1);

        if ( [ $checkmonday -le 0 ] ); then
                exit 0;
        fi
        if ( [ $checkmonday -ge 8 ] && [ $checkmonday -le 14 ] ); then
                exit 0;
        fi
        if ( [ $checkmonday -ge 22 ] && [ $checkmonday -le 28 ] ); then
                exit 0;
        fi
fi

if ( [ $BIWEEK_F -eq 1 ] && [ -f $check_biweek_dir/$check_file ] ); then 
        rm -f $check_biweek_dir/$check_file;
        exit 0;
fi

cd $working_dir

outfile=$now-$SUFFIX;

[ $BIWEEK_F -eq 1 ] && touch "$check_biweek_dir/$outfile";



#
# rtmpdump
#
RETRYCOUNT=0
while :
do

        RANDOM=`od -vAn -N4 -tu4 < /dev/random`;
        index=$(expr $RANDOM % 2);
        index=$(expr $index + 1);
        tmpurl="rtmpe://fms${index}.uniqueradio.jp/";
        outfile=${outfile}-${index};    


        RANDOM=`od -vAn -N4 -tu4 < /dev/random`;
        index=$(expr $RANDOM % 2);
        index=$(expr $index + 1);
        tmppath="?rtmp://fms-base${index}.mitene.ad.jp/agqr/";
        outfile=${outfile}${index};

        RANDOM=`od -vAn -N4 -tu4 < /dev/random`;
        index=$(expr $RANDOM % 2);
        index=$(expr $index + 1);
        outfile=${outfile}${index};

#       echo $RANDOM;
#       echo $tmpurl
#       echo $tmppath

        rtmpdump -q -vr $tmpurl \
            -a $tmppath \
            -f "WIN 11,8,800,94" \
            -W "http://www.uniqueradio.jp/agplayerf/LIVEPlayer-HD0318.swf" \
            -p "http://www.uniqueradio.jp/agplayerf/newplayerf2-win.php" \
            -C B:0 -y "aandg${index}" \
            --stop ${REC_TIME} \
            --timeout 30 \
            -o $outfile

  if [ $? -ne 1 -o `wc -c $outfile | awk '{print $1}'` -ge 10240 ]; then
    break
  elif [ ${RETRYCOUNT} -ge 5 ]; then
    echo "failed rtmpdump"
    exit 1
  else
    RETRYCOUNT=`expr ${RETRYCOUNT} + 1`
  fi
done
####


####
if ( [ $STREAM = 'V' -o $STREAM = 'v' ] ); then
        mv $outfile $outfile.flv
        outfile=$outfile.flv
else
        ffmpeg -i $outfile -vn -acodec copy $outfile.m4a >/dev/null 2>/dev/null
        rm -f $outfile
        outfile=$outfile.m4a
fi

gpg --options /home/user/.gnupg/opt.txt $outfile

DB=/home/user/.gnupg/Sessionkeys.db
key=`gpg -o /dev/null --batch --show-session-key $outfile.gpg 2>&1|
        perl -ne 'print $1 if (/gpg: session key:\s+.(\w+:\w+)/)'`
sqlite3 $DB "insert into sKey values('$outfile.gpg', '$key');"  

Update-crk.sh $working_dir/$outfile.gpg



#curl -s \
#        -T "$upfile" \
#        -u "$ftpaccount_pass" \
#        --retry 20 \
#        --retry-delay 10 \
#        --connect-timeout 300 \
#       --retry-delay 10 \
#        --ftp-create-dirs \
#        $ftpurl/$ftpdir/ > /dev/null

curl -s \
        -T "$outfile.gpg" \
        -u "$ftpaccount_pass" \
        --retry 20 \
        --retry-delay 10 \
        --connect-timeout 300 \
        --ftp-create-dirs \
        $ftpurl/$ftpdir/  >/dev/null


curl -s \
        -T "$outfile.gpg" \
        -u user:pass \
        --retry 2 \
       --retry-delay 2 \
        --connect-timeout 30 \
        --ftp-create-dirs \
        ftp://a.agqr.tk/public_html/Radio/`date '+%Y-%m'`/ >/dev/null


curl -s \
        -T "$outfile.gpg" \
        -u 'user:pass' \
        --retry 10 \
        --retry-delay 10 \
        --connect-timeout 120 \
        --ftp-create-dirs \
        ftp://a.anispa.tk/public_html/Radio/`date '+%Y-%m'`/ >/dev/null


TW.pl "[$outfile.gpg] is uploaded." >/dev/null

rm -f $outfile.gpg

exit 0;
}}

トップ   差分 バックアップ リロード   一覧 単語検索 最終更新   ヘルプ   最終更新のRSS