summaryrefslogtreecommitdiffstats
path: root/.local/bin/rechin
blob: 0d3811d95369b0f421c44bbfd606357f9c39f9f7 (plain) (blame)
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
#!/bin/sh

application="gallery-dl"
site="boards.4chan.org"
site_domain="$(echo $site | cut -f2 -d.)"

if [ ! -d "$PWD/$application" ] && [ ! -d "$PWD/$application/$site_domain" ]; then
    echo "Directories to read from are missing, exiting."
    exit 0
fi

size_previous="$(du "$application" -s | awk '{print $1}')"
for board in $(ls "$application/$site_domain/")
do
	loop_count=1
	total_count=$(find "$application/$site_domain/$board" -mindepth 1 -maxdepth 1 -type d | wc -l)
	for thread in $(ls "$application/$site_domain/$board" | cut -f1 -d" " | tac)
	do
		$application "https://$site/$board/thread/$thread"
		printf "Loop count: %s/%s\n" "$loop_count" "$total_count"
		loop_count=$(( loop_count + 1 ))
	done
done
size_after="$(du "$application" -s | awk '{print $1}')"
printf "Size increase: %s\n" "$((size_after - size_previous))"