Created
January 13, 2024 16:50
-
-
Save rigwild/4b0559d53b4a5fe63f3e2fc5d8c19250 to your computer and use it in GitHub Desktop.
Download all Cool Cats NFT metadata and images
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
set -e | |
set -x | |
# Directory to save the JSON files and images | |
mkdir -p coolcats | |
cd coolcats | |
# Loop from 1 to 9999 | |
for i in {1..9999} | |
do | |
# Define file names | |
json_file="$i.json" | |
image_file="$i.png" | |
# Skip iteration if JSON and image file already exists | |
if [ -f "$image_file" ] && [ -f "$json_file" ]; then | |
echo "Skipping $i as it already exists." | |
continue | |
fi | |
echo "Downloading $i..." | |
# Fetch the JSON data | |
json_data=$(curl -s "https://api.coolcatsnft.com/cat/$i") | |
# Save pretty-printed JSON data to a file | |
echo "$json_data" | jq '.' > "$json_file" | |
# Extract the IPFS image URL | |
ipfs_image_url=$(echo "$json_data" | jq -r '.ipfs_image') | |
# Check if the image URL is not null and download the image | |
if [ "$ipfs_image_url" != "null" ]; then | |
wget -O "$image_file" "$ipfs_image_url" | |
fi | |
done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment