From 8a6cc8d2f2175242f7d09328fb5f3879a63d1093 Mon Sep 17 00:00:00 2001 From: sneedgroup-holder Date: Tue, 31 Dec 2024 22:13:47 -0600 Subject: [PATCH] Upload the source, license will follow --- massinspiro-xmas.zsh | 39 +++++++++++++++++++++++++++++++++++++++ massinspiro.zsh | 40 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 massinspiro-xmas.zsh create mode 100644 massinspiro.zsh diff --git a/massinspiro-xmas.zsh b/massinspiro-xmas.zsh new file mode 100644 index 0000000..565e92b --- /dev/null +++ b/massinspiro-xmas.zsh @@ -0,0 +1,39 @@ +#!/bin/zsh + +if [[ -z "$1" ]]; then + echo "Please define how many images you wish to download" + exit 1 +fi + +# Define the output directory for the images +output_dir="./xmas_massinspiro_id_$RANDOM$RANDOM$RANDOM" + +# Create the directory if it doesn't exist +mkdir -p "$output_dir" + +# Loop to get and download the image 4 times +for i in {1..$1}; do + # Get the URL from the API + image_url=$(curl -s "https://inspirobot.me/api?generate=true&season=xmas") + + # Check if the URL was retrieved + if [[ -z "$image_url" ]]; then + echo "Failed to get image URL for iteration $i" + continue + fi + + # Define the image filename + image_filename="image_$i.jpg" + + # Download the image to the specified output directory + echo "Downloading image $i from $image_url" + curl -s -o "$output_dir/$(basename $image_url)" "$image_url" + + # Check if the download was successful + if [[ $? -eq 0 ]]; then + echo "Image $i downloaded successfully." + else + echo "Failed to download image $i." + fi +done + diff --git a/massinspiro.zsh b/massinspiro.zsh new file mode 100644 index 0000000..2871756 --- /dev/null +++ b/massinspiro.zsh @@ -0,0 +1,40 @@ +#!/bin/zsh + +if [[ -z "$1" ]]; then + echo "Please define how many images you wish to download" + exit 1 +fi + + +# Define the output directory for the images +output_dir="./massinspiro_id_$RANDOM$RANDOM$RANDOM" + +# Create the directory if it doesn't exist +mkdir -p "$output_dir" + +# Loop to get and download the image 4 times +for i in {1..$1}; do + # Get the URL from the API + image_url=$(curl -s "https://inspirobot.me/api?generate=true") + + # Check if the URL was retrieved + if [[ -z "$image_url" ]]; then + echo "Failed to get image URL for iteration $i" + continue + fi + + # Define the image filename + image_filename="image_$i.jpg" + + # Download the image to the specified output directory + echo "Downloading image $i from $image_url" + curl -s -o "$output_dir/$(basename $image_url)" "$image_url" + + # Check if the download was successful + if [[ $? -eq 0 ]]; then + echo "Image $i downloaded successfully." + else + echo "Failed to download image $i." + fi +done +