Skip to content

Instantly share code, notes, and snippets.

@motebaya
Created November 21, 2023 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save motebaya/d91eb37c88724401034a9940374b91da to your computer and use it in GitHub Desktop.
Save motebaya/d91eb37c88724401034a9940374b91da to your computer and use it in GitHub Desktop.
PGR wallpaper auto downloader shell script. site: https://pgr.kurogame.net/wallpapers
#!/usr/bin/bash
# @gist.github.com/motebaya at 21.11.2023 - 8.57PM
extract() { outputWp="Pgr_Wallpaper";if [[ ! -d "$outputWp" ]];then mkdir -p "$outputWp";echo -e " [*] Output: $(realpath $outputWp)";fi;i=1;pictureList=$(curl -s -H "User-Agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/119.0.0.0 Safari/537.36" -L "https://media-cdn-zspms.kurogame.net/pnswebsite/website2.0/json/G167/MainMenu.json" | jq '.picture' | jq '[.[] | select(.imgUrl)]' | jq -c '.[]');while IFS="\n" read -r url; do target=$(jq -r '.imgUrl' <<<$url);echo -e " [*] Downloading [\x1b[32m$target\x1b[0m] Wallpaper: $i of $(wc -l <<<\"$pictureList\")";wget -qnc --show-progress "$target" -P "$outputWp";((++i));trap 'echo " [*] Remove Uncompleted: $outputWp/$(basename $target)"; rm -rf "$outputWp/$(basename $target)"; exit 1;' SIGINT ;done <<<"$pictureList";};extract
@motebaya
Copy link
Author

tldr:

  • wget can skip existing download
  • after research, i found out the aria2c are more faster download between wget/curl. but aria2c doesn't have progress bar download, it's annoying me when i don't know how far along the download process is.
  • using trap to handle signint (CTRL+C) , if stopped while wget still downloading it will be delete uncompleted download.
  • the most wallpaper size are big, but it's posible to stop and continue it anytime.
    log:
 [*] Downloading [https://media-cdn-zspms.kurogame.net/pnswebsite/website2.0/images/1699459200000/1awsmstp0vsp6or4ve-1699533663739邦比kv.jpg] Wallpaper: 1 of 297
 [*] Downloading [https://media-cdn-zspms.kurogame.net/pnswebsite/website2.0/images/1698249600000/tvc5nfdhnvs07u3mgn-1698314417700雨过天晴.jpg] Wallpaper: 2 of 297
tvc5nfdhnvs07u3mgn-16983144 100%[========================================>]  18,19M  2,61MB/s    in 7,6s    
 [*] Downloading [https://media-cdn-zspms.kurogame.net/pnswebsite/website2.0/images/1698249600000/bb6rqyg02pbb9mgybi-1698314379899提灯探索.jpg] Wallpaper: 3 of 297
bb6rqyg02pbb9mgybi-16983143 100%[========================================>]   4,65M  2,88MB/s    in 1,6s    
 [*] Downloading [https://media-cdn-zspms.kurogame.net/pnswebsite/website2.0/images/1698249600000/0w0cgskt0ek50308ay-1698314345999她的痕迹.jpg] Wallpaper: 4 of 297
0w0cgskt0ek50308ay-16983143 100%[========================================>]   5,14M  2,66MB/s    in 1,9s    
 [*] Downloading [https://media-cdn-zspms.kurogame.net/pnswebsite/website2.0/images/1698249600000/dh3bpxkti7v7t323q7-1698314307686自由引导人民.jpg] Wallpaper: 5 of 297
           dh3bpxkti7v7t323  75%[=============================>           ]   2,20M  2,99MB/s               
^C [*] Remove Uncompleted: Pgr_Wallpaper/dh3bpxkti7v7t323q7-1698314307686自由引导人民.jpg

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment