Skip to content

Instantly share code, notes, and snippets.

@mashihua
Forked from yuzebin/open163_dl.sh
Created June 15, 2018 03:25
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mashihua/07a2019c895d3b0831cc8f119831a3fc to your computer and use it in GitHub Desktop.
Save mashihua/07a2019c895d3b0831cc8f119831a3fc to your computer and use it in GitHub Desktop.
网易公开课下载脚本 open.163.com
#!/usr/bin/env bash
# author: yuzebin AT gmail
# 20180614
main() {
mkdir -p $2
cd $2
curl $1 | grep -e "http://open.163.com/movie/" | enca -L zh -x UTF-8 | sed -e "s/\<a href=\"//g" -e "s/\>//g" -e "s/<\/a//g" | grep -v class> $2.lst
num=0
for i in `cat $2.lst`; do
let "num = $num + 1";
curl -A "Mozilla/5.0 (iPad; CPU iPhone OS 11_0 like Mac OS X) AppleWebKit/604.1.38 (KHTML, like Gecko) Version/11.0 Mobile/15A372 Safari/604.1" `echo $i | awk -F"\"" '{print $1}'` | grep -ohE "https?://[a-zA-Z0-9\.\/_&=@$?~#-]*" | grep m3u8 | xargs -I{} ffmpeg -i {} -bsf:a aac_adtstoasc -vcodec copy -c copy -crf 50 $2_${num}_`echo $i | awk -F"\"" '{print $2}'`.mp4;
done
cd ..
}
if [[ $# -ne 2 ]]; then
echo "Usage: $0 course_rul course_name"
echo "Example: $0 http://open.163.com/special/opencourse/bianchengdaolun.html 编程导论"
else
main $1 $2
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment