-
Ubuntu Image Fetcher (title & intro)
-
Features
-
📂 Project Files
-
Installation
-
Usage
-
Examples
-
Ubuntu Principles
-
Closing Note / License
This project is inspired by the Ubuntu philosophy:
"I am because we are."
The script connects to the wider web community by fetching images from the internet, saving them into an organized directory, and respecting community principles through safety checks, duplicate prevention, and graceful error handling.
- ✅ Fetch images from one or multiple URLs (comma-separated input or
@urls.txtfile) - ✅ Creates a
Fetched_Imagesdirectory if it doesn’t exist - ✅ Checks HTTP headers (
Content-Type,Content-Length,Content-Disposition) before saving - ✅ Prevents duplicate downloads by storing SHA-256 hashes in
manifest.json - ✅ Safety precautions:
- Only saves files with
image/*Content-Type - Skips downloads larger than 10 MB (configurable in code)
- Gracefully handles network and file errors
- Only saves files with
- ✅ Organized & reusable — all metadata saved in
manifest.json
📂 Project Files
- fetcher.py → Advanced version with:
Multiple URL support
HTTP header checks (Content-Type, Content-Length, Content-Disposition)
Duplicate detection using SHA-256 manifest (manifest.json)
Safe filenames & size limits
Clear error handling and console messages
- fetcher_backup.py → Minimal version that still meets assignment requirements:
Fetches images using requests
Handles HTTP errors with try/except
Creates Fetched_Images directory if missing
Extracts filename from URL or generates fallback
Saves image in binary mode
Skips duplicates if filename already exists
📝 Why Two Versions?
fetcher_backup.py proves I understood and implemented the core assignment requirements.
fetcher.py demonstrates going beyond the basics by adding robustness, safety, and Ubuntu principles in practice.
- Python 3.10+
- Libraries:
requests
Install dependencies (inside a virtual environment recommended):
pip install requests
Setup & Usage
1. Clone or download this repository:
git clone https://github.com/yourusername/Ubuntu_Requests.git
cd Ubuntu_Requests
2. (Optional) Create and activate a virtual environment:
python -m venv venv
# Windows PowerShell
.\venv\Scripts\Activate.ps1
3. Install dependencies:
pip install -r requirements.txt
4. Run the script:
python fetcher.py
5. Enter one of the following when prompted:
A single URL
Multiple URLs separated by commas
@urls.txt to load URLs from a text file
Example (urls.txt content):
https://images.pexels.com/photos/414171/pexels-photo-414171.jpeg
https://picsum.photos/400/300
Example terminal output:
Welcome to the Ubuntu Image Fetcher (upgraded)
A tool for mindfully collecting images from the web
Enter image URLs (comma-separated) or '@urls.txt' to load from a file:
> @urls.txt
Fetching: https://images.pexels.com/photos/414171/pexels-photo-414171.jpeg
- Content-Type: image/jpeg
- Content-Length: 123456 bytes
✓ Successfully fetched: pexels-photo-414171.jpeg
✓ Image saved to Fetched_Images/pexels-photo-414171.jpeg
Fetching: https://picsum.photos/400/300
- Content-Type: image/jpeg
✓ Successfully fetched: 400_300.jpg
✓ Image saved to Fetched_Images/400_300.jpg
Connection strengthened. Community enriched.
Ubuntu Principles Reflected
Community: Connects to global resources by fetching shared images
Respect: Gracefully handles errors and avoids unsafe downloads
Sharing: Organizes fetched images and metadata for later use
Practicality: Provides a simple, safe, reusable tool
Evaluation Criteria Checklist
✅ Proper use of the requests library
✅ Effective error handling for network issues
✅ Appropriate file management and directory creation
✅ Duplicate prevention implemented
✅ Clean, readable code with comments
✅ Faithfulness to Ubuntu principles
License
This project is for educational purposes under the PLP Academy assignment.