create another bash script that uses an .env file that I can change the variables in

I've created a complete bash script setup with .env file configuration! Here's what you got:

Files included:

  1. download_anime.sh - Main script that reads from .env
  2. .env - Your configuration file (ready to edit)
  3. .env.example - Template/backup copy
  4. README.md - Usage instructions

To use:

  1. Edit the .env file with your preferred settings
  2. Run: ./download_anime.sh

Key features:

Just change the values in .env whenever you want to download different anime!


Here is the script:

#!/bin/bash

# Anime Download Script using ani-cli with .env configuration
# Make sure ani-cli is installed before running this script

# Script directory
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"

# Load .env file
ENV_FILE="$SCRIPT_DIR/.env"

if [ ! -f "$ENV_FILE" ]; then
    echo "Error: .env file not found at $ENV_FILE"
    echo "Please create a .env file in the same directory as this script."
    echo "You can copy .env.example to .env and modify it."
    exit 1
fi

# Source the .env file
set -a
source "$ENV_FILE"
set +a

# Expand variables in DOWNLOAD_DIR (for $HOME, etc.)
DOWNLOAD_DIR=$(eval echo "$DOWNLOAD_DIR")

# Validate required variables
if [ -z "$ANIME_NAME" ]; then
    echo "Error: ANIME_NAME is not set in .env file"
    exit 1
fi

if [ -z "$EPISODE_RANGE" ]; then
    echo "Error: EPISODE_RANGE is not set in .env file"
    exit 1
fi

# Create download directory if it doesn't exist
mkdir -p "$DOWNLOAD_DIR"

# Change to download directory
cd "$DOWNLOAD_DIR" || exit 1

echo "========================================="
echo "Anime Season Downloader using ani-cli"
echo "========================================="
echo "Anime: $ANIME_NAME"
echo "Episodes: $EPISODE_RANGE"
echo "Quality: ${QUALITY:-interactive}"
echo "Download Directory: $DOWNLOAD_DIR"
[ -n "$PROVIDER" ] && echo "Provider: $PROVIDER"
[ -n "$SUB_LANG" ] && echo "Subtitle Language: $SUB_LANG"
echo "========================================="
echo ""

# Build ani-cli command
CMD="ani-cli -d"

# Add episode range
CMD="$CMD -e $EPISODE_RANGE"

# Add quality if specified
if [ -n "$QUALITY" ]; then
    CMD="$CMD -q $QUALITY"
fi

# Add provider if specified
if [ -n "$PROVIDER" ]; then
    CMD="$CMD --provider $PROVIDER"
fi

# Add subtitle language if specified
if [ -n "$SUB_LANG" ]; then
    CMD="$CMD --sub-lang $SUB_LANG"
fi

# Add anime name at the end
CMD="$CMD \\\\"$ANIME_NAME\\\\""

echo "Executing: $CMD"
echo ""
echo "Starting download..."
echo ""

# Execute the command
eval $CMD

EXIT_CODE=$?

echo ""
echo "========================================="
if [ $EXIT_CODE -eq 0 ]; then
    echo "Download complete!"
    echo "Files saved to: $DOWNLOAD_DIR"
else
    echo "Download failed with exit code: $EXIT_CODE"
fi
echo "========================================="

exit $EXIT_CODE