Created
May 22, 2017 07:47
-
-
Save inlinechan/cf83078bdaa013f534fd8d0f2b96462f to your computer and use it in GitHub Desktop.
save mms to mp3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# for crontab | |
export PATH=$HOME/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin | |
URL=mms://211.181.136.136/livefm | |
DESTDIR=$HOME/Music/chulsoo | |
RECIPIENT='foo@bar.com' | |
WAVFILE=$(date +\%Y\%m\%d\%H).wav | |
DURATION=3600 | |
ARTIST="배철수" | |
TITLE="${ARTIST}의 음악캠프 `date +%Y/%m/%d`" | |
YEAR=$(date +%Y) | |
if [ -n $1 ]; then | |
DURATION=$1 | |
fi | |
mkdir $DESTDIR -p | |
timeout $DURATION mplayer $URL -slave -vo null -vc dummy -ao pcm:fast:file=$DESTDIR/$WAVFILE | |
if [ -f $DESTDIR/$WAVFILE ]; then | |
MP3=${WAVFILE%.wav}.mp3 | |
# echo Succesfully record to $WAVFILE | mail -s "Succesfully record to $WAVFILE" $RECIPIENT | |
lame $DESTDIR/$WAVFILE $DESTDIR/$MP3 --tt "$TITLE" --ta $ARTIST --ty $YEAR | |
if [ -f $DESTDIR/$MP3 ]; then | |
# echo "Converted $WAVFILE to mp3($MP3)" | mail -s "Converted to mp3($MP3)" $RECIPIENT | |
rm $DESTDIR/$WAVFILE | |
fi | |
else | |
echo "Fail to record to $WAVFILE" | mail -s "Fail to record to $WAVFILE" $RECIPIENT | |
fi | |
find $DESTDIR -type f -ctime +7 -exec rm -f {} \; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment