This project is a Python script that enables you to download tagged images from Imgur.
This script supports two download modes: sequential and threaded.
-
Sequential: In this mode, images are downloaded one after another using only the main thread of the process. -
Threaded: This mode creates multiple threads to download images concurrently.
The script measures and logs the time taken to download the images in both modes. This enables you to see the effect of using the different modes and different numbers of threads on the script’s performance.
The project’s only dependency is the requests module, which can be installed using pip:
pip install requestsThe script also requires an Imgur client ID which should be set in your environment variables as imgur_client_id. To obtain an Imgur client ID, create an account on Imgur and follow the instructions on registering an application.
To run the script, you need to use the command line. Navigate to the directory containing the script, then run the command with the following format:
python download.py --tag <tag> --mode <mode> [--threads <threads>]Where:
<script name>is the name of the python file.<tag>is the tag of the images you want to download. For example,astronomyorcats.<mode>is the download mode which can be eitherthreadedorsequential.<threads>(optional) is the number of threads to use inthreadedmode. Default is10. Only valid when--mode=threaded.
An example command to download images tagged with astronomy using 10 threads is:
python download.py --tag astronomy --mode threaded --threads 12Examples of Imgur tags you can use include: astronomy, cats, cars, nature, earth.
The downloaded images will be saved in an images directory in the same location as the script. Each run will save its images in a new directory with the current time stamp. For tags with multiple images, each image will be saved in a separate directory within this top-level directory.
Leave a Reply