Skip to content

hbrawnak/image-downloader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Image Downloader Project

This project contains two image downloading applications that use environment variables for configuration:

Files

  • pixels.py - Downloads nature images from Pexels API
  • app.py - Downloads cat images from The Cat API

Setup

  1. Install dependencies:

    pip install -r requirements.txt
  2. Configure environment variables:

    cp .env.example .env

    Then edit .env with your actual API keys.

Environment Variables

Pexels API Configuration

  • PEXELS_API_KEY - Your Pexels API key (required)
  • PEXELS_BASE_URL - Pexels API endpoint (default: https://api.pexels.com/v1/curated)
  • PEXELS_MAX_IMAGE - Number of images to download (default: 10)
  • PEXELS_SAVE_DIR - Directory to save images (default: natures)

Cat API Configuration

  • CAT_API_KEY - Your Cat API key (required)
  • CAT_BASE_URL - Cat API endpoint (default: https://api.thecatapi.com/v1/images/search)
  • CAT_MAX_IMAGE - Number of images to download (default: 10)
  • CAT_SAVE_DIR - Directory to save images (default: cats)
  • CAT_SEMAPHORE_LIMIT - Concurrent request limit (default: 10)

Usage

Download nature images:

python pixels.py

Download cat images:

python app.py

Features

  • Environment-based configuration - All settings managed through .env file
  • Async/await support - Concurrent downloads for better performance
  • Error handling - Retry logic with exponential backoff
  • Flexible file naming - Supports multiple image formats
  • Directory management - Automatically creates output directories

Security

  • API keys are stored in environment variables
  • .env file is gitignored to prevent accidental commits
  • Use .env.example as a template for required variables

About

Image download using asyncio in Python

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages