summaryrefslogtreecommitdiff
path: root/pull-images
blob: 944228a30a258fc6cb3850d90513f3ecbb1a6ae5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#!/bin/sh

usage="Usage: $0 filename [urlroot]"

test $# -eq 0 && echo "$usage" && exit 1
test $# -gt 2 && echo "$usage" && exit 1

proto=`echo "$2" | awk -F : '{print $1}'`

imgurls=`cat "$1" \
| awk -F \( '/!\[[^\]]*\]\([^\)]*\)/ {print $2}' \
| sed 's/).*//' \
| awk '{print $1}' \
| sed "s/^\/\//${proto}:\/\//g" \
| sort | uniq`

for i in $imgurls; do
	echo "$i" | grep -q '//'
	test $? -ne 0 && i="${2}${i}"
	echo "Downloading $i"
	wget -q "$i"
done