Skip to content

Instantly share code, notes, and snippets.

@etaf
Last active July 19, 2016 05:39
Show Gist options
  • Save etaf/f9329ea1e97318409085 to your computer and use it in GitHub Desktop.
Save etaf/f9329ea1e97318409085 to your computer and use it in GitHub Desktop.
download the easy fm more to learn mp3 from start day to now
#!/bin/bash
#usage:
#download the easy fm more to learn mp3 from start day to now
trap ctrl_c INT
function ctrl_c(){
echo "\n catched interput signal, exiting..."
[ ! -e $current_process_file ] || rm $current_process_file
echo "bye!"
exit
}
start_time="20150101"
now=`date +%Y%m%d`
end_time=$now
#end_time="20131231"
it=$start_time
current_process_file=${it}".mp3"
while [ "$it" -le "$end_time" ]
do
src_url="http://mod.cri.cn/eng/ez/mtl/${it:0:4}/atw${it:2:6}.mp3"
echo "processing ${it:0:4}/${it:4:2}/${it:6:2}"
echo "Downloading from $src_url ..."
current_process_file=${it}".mp3"
res=$( curl -s -o $current_process_file -w '%{http_code}\n' $src_url )
if ((res != 200));then
echo "http return: $res"
rm ${it}".mp3"
else
echo "${it}.mp3 downloaded success."
fi
it=$(date -d "$it + 1 day" +%Y%m%d)
done
@unstppbl
Copy link

Thank you pengyou!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment