https://xuexi-courses.firesbox.com/?utm_source=share#/7000102069/courses/
curl -u clientId:clientSecret -X POST -d "username=test&password=test&grant_type=password&scope=read" http://www.example.com/oauth/token
curl -s -H "Authorization: ${TOKEN}" https://xuexi-courses-api.firesbox.com/v1/courses?offset=0&limit=100&sort=oldest-first
cat courses.json jq '.courses|.[] |.id' > id-0-200.url
TOKEN="Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJhdWQiOiIxNTkwNzciLCJleHAiOjE2NjUxMjU2MzgsImp0aSI6Ijk5NmRhOTE0LWI0ZjAtNDVkMC04ZDAxLTJjZWE0YzE4NjJlZSIsImlhdCI6MTY2NDUyMDgzOCwiaXNzIjoiMzAwMjIiLCJzdWIiOiI3MDAwMTAyMDY5IiwidWlkIjoiM2IyNGQ3ZWQtOTliOS00ODA2LTlhZWItZTY3YWVjYzEyOGJlIiwibW9kZSI6ImNsaWVudCIsInR5cCI6ImFwcHVzZXIiLCJvYXAiOiJtaXhpbiIsInNpZCI6ImY5ODEwODM0ZmNkODRiZTk4NzQyYTM3YmY4MTYxMzkwIn0.wXhhf0yHB_8z9lTlkNos9NOZfZg2xcxl3rUtEvm2tTk"
curl -s -H "Authorization: ${TOKEN}" https://xuexi-courses-api.firesbox.com/v1/courses/ |jq '.courses | .[] | .id ' >IDS.txt
mkdir output
for ID in `cat IDS.txt`
do
echo $ID
TITLE=`curl -s -H "Authorization: ${TOKEN}" https://xuexi-courses-api.firesbox.com/v1/courses/$ID |jq '.title'| sed 's/\"//g'`
if [ ! -f "output/$TITLE.mp3" ]; then
if [[ $TITLE == * ]];
then
echo $TITLE
curl -s -H "Authorization: ${TOKEN}" https://xuexi-courses-api.firesbox.com/v1/courses/$ID/messages |jq '.[] | .attachment | .url'| sed 's/\"//g' |grep -v null|grep mp3> url.txt
cat url.txt
rm -rf *.mp3
cat -n url.txt | awk '{print "wget -c " $2 " -O " $1 ".mp3"}' > rename.sh
sh rename.sh
ALL=`cat -n url.txt | awk '{print $1 ".mp3"}'|tr '\n' '|'|sed s'/.$//'`
ffmpeg -y -i "concat:$ALL" -acodec copy output/$TITLE.mp3
ll output/$TITLE.mp3
rm -rf *.mp3
fi
fi
done
rm -rf url.txt rename.sh IDS.txt