Skip to content

Instantly share code, notes, and snippets.

@kang000feng
Forked from 4ft35t/xdown.sh
Last active June 3, 2016 02:51
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 kang000feng/db72f47986883ef1ca9c7d555527e088 to your computer and use it in GitHub Desktop.
Save kang000feng/db72f47986883ef1ca9c7d555527e088 to your computer and use it in GitHub Desktop.
用 aria2 多源下载 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