summaryrefslogtreecommitdiffstats
path: root/.local/bin/imgsrc
blob: ad1921556c774a8e4714628d3329f43a1b3b628d (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/bin/bash

if [ "$#" -eq 0 ]
then
	echo "No URI argument supplied, using clipboard"
	uri="$(wl-paste | awk -F'?' '{print $1}')"
else
	uri="$(echo "$1" | awk -F'?' '{print $1}')"
fi

folder="$(curl -s "$uri" | grep \<title\> | tr -d "\(\)'" | sed -e 's/<[^>]*>//g' | awk -F'/' '{print $1}' | xargs)"

mkdir -p "$folder" || exit
cd "$folder" || exit
printf "Downloading %s... " "$folder"
python3 "$HOME/.local/bin/imgs.py" "$uri"
printf "done\\n"

printf "Downloaded %s files... " "$(find . -type f | wc -l)"
printf "done \\n"