-
Notifications
You must be signed in to change notification settings - Fork 40
/
Copy path_download_subs.sh
executable file
·60 lines (54 loc) · 1.84 KB
/
_download_subs.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#!/bin/bash
#set -x
curl_options="--retry 5 --location --progress-bar"
curl_options_silent="--retry 5 --location --silent"
# download from bitbucket downloads
function download_bitbucket
# $1 is account name on bitbucket
# $2 is subdir on account bitbucket
# $3 is prefix of zip file name
# $4 is output file name (optional, otherwise uses remote name)
{
echo "downloading $3:"
curl $curl_options_silent --output /tmp/org.rehabman.download.txt https://bitbucket.org/$1/$2/downloads/
local scrape=`grep -o -m 1 "/RehabMan/$2/downloads/$3.*\.zip" /tmp/org.rehabman.download.txt|perl -ne 'print $1 if /(.*)\"/'`
local url=https://bitbucket.org$scrape
echo $url
if [ "$4" == "" ]; then
curl $curl_options --remote-name "$url"
else
curl $curl_options --output "$4" "$url"
fi
echo
}
# download typical release from RehabMan bitbucket downloads
function download_rehabman
# $1 is subdir on rehabman bitbucket
# $2 is prefix of zip file name
# $3 is output file name (optional, otherwise uses remote name)
{
download_bitbucket "RehabMan" "$1" "$2" "$3"
}
# download latest release from github (perhaps others)
function download_latest_notbitbucket
# $1 is main URL
# $2 is URL of release page
# $3 is partial file name to look for
# $4 is output file name (not optional)
{
echo "downloading $4:"
curl $curl_options_silent --output /tmp/org.rehabman.download.txt "$2"
local scrape=`grep -o -m 1 "/.*$3.*\.zip" /tmp/org.rehabman.download.txt`
local url=$1$scrape
echo $url
curl $curl_options --output "$4" "$url"
echo
}
# download from acidanthera project on github
function download_acidanthera
# $1 is name of acidanthera project on github
# $2 is basename of output zip
{
download_latest_notbitbucket "https://github.com" "https://github.com/acidanthera/$1/releases" "RELEASE" "$2.zip"
}
#EOF