summaryrefslogtreecommitdiff
path: root/get-wallpapers
blob: 40eef785d57313137ec1c390d1696a6485dbd03d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env bash

# Download wallpapers via the wallhaven API
# Reads search term, start page and end page

read -p "Enter search term: " search_term
read -p "Enter start page: " start_page
read -p "Enter end page: " end_page

current_page=$start_page

while [ $current_page -le $end_page ]; do
    curl -s "https://wallhaven.cc/api/v1/search?q=$search_term&page=$current_page" |
    jq '.data[].path' |
    xargs -I{} curl -O {};
    current_page=$(( current_page+1 ));
done