Skip to content

Instantly share code, notes, and snippets.

@4ft35t
Last active August 4, 2017 04:35
Show Gist options
  • Save 4ft35t/7d2b13c9dafabaa4ab3defa9cafa68d6 to your computer and use it in GitHub Desktop.
Save 4ft35t/7d2b13c9dafabaa4ab3defa9cafa68d6 to your computer and use it in GitHub Desktop.
Download file use ISP's cache server for more speed.
#!/bin/bash
[ $# -eq 0 ] && echo "see aria2c -h" && exit
url=""
cdn='
120.52.73.2
120.52.73.4
120.52.73.6
120.52.73.7
120.52.73.10
120.52.73.9
120.52.73.1
120.52.73.91
120.52.73.93
120.52.73.88
120.52.73.12
120.52.73.82
120.52.73.79
120.52.73.49
120.52.73.90
120.52.73.83
120.52.73.3
120.52.73.42
120.52.73.14
120.52.73.45
'
cdn="221.176.14.72 $cdn"
while [ $# -ne 0 ]
do
[ $url ] || url=$(echo $1|grep '^http')
args="$args $(echo -e $1|grep -v '^http')"
shift
done
# mod for baidu
# https://v2ex.com/t/282827
# https://stackoverflow.com/questions/9591744/add-to-the-end-of-a-line-containing-a-pattern-with-sed-or-awk
url=$(echo $url|sed -e 's#http://d.pcs.baidu.com#http://bj.baidupcs.com#' -e '/bj.baidupcs.com/ s/$/\&redirect=0/')
uri=${url##http:/}
uri=${uri##https:/}
for i in $cdn
do
u="$u http://$i$uri"
done
aria2c --min-split-size=1M -c -s 10 -x 4 $u $args
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment