Skip to content

Instantly share code, notes, and snippets.

@adeonhy
Last active June 27, 2016 09:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save adeonhy/cd190bb815b80a65df926f552b92e7c1 to your computer and use it in GitHub Desktop.
Save adeonhy/cd190bb815b80a65df926f552b92e7c1 to your computer and use it in GitHub Desktop.
http://www.nichibi-chinese.com/web-lesson の無料講座をダウンロード
#!/bin/bash
BASE_URL='http://www.nichibi-chinese.com'
LIST_URL='http://www.nichibi-chinese.com/web-lesson'
LIST=$(curl ${LIST_URL} \
| egrep '<li class=\"page_item page-item-\d*\">' \
| gsed 's/.*<a href=\"\(.*\)\">\(.*\)<\/a><\/li>.*/\1,\2/' \
| gsed 's/\s\+/_/g' \
| grep -v '%' \
| egrep -v '<|>' \
| awk '{printf "%03d,%s\n", NR, $0}' \
| sed 's/\&\#8230;/…/g'
)
for i in $LIST
do
IFS=','
set -- $i # $1: num, $2: url, $3: title
# echo $1 $2 $3
MOVIE_PATH=$(
curl $2 \
| grep video |grep mp4 \
| sed 's/.*src=\"\(.*mp4\)\".*/\1/' \
)
MOVIE_URL=${BASE_URL}${MOVIE_PATH}
echo $MOVIE_URL
curl $MOVIE_URL -o ${1}_${3//\//-}.mp4
done
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment