Skip to main content

UnsplashRandDownloader

Python Unsplash Random Image Downloader.

This component periodically download and store random images based of specified topics from Unsplash platform and allows the user to request one of the downloaded images. It keeps control of the Unsplash API requests limits, and using some kind of "image files rotate" of the storage (removing and replacing older images with newer ones), it also control and limit the maximum number of images downloaded in the filesytem.

Installation

From Pypi:

python3 -m pip install unsplash_rand_downloader

From Sources:

git clone https://www.github.com/J-Rios/unsplash_rand_downloader
cd unsplash_rand_downloader
python3 -m pip install .

Usage

# Import the module
from unsplash_rand_downloader import UnsplashRandDownloader

# Set your Unsplash API access account identification parameters
# (Application Name, Client ID and Client Secret Key)
APP_NAME = "XXXXXXXXXXXXXXX"
CLIENT_ID = "XXXXXXXXXXX_XXXXX-XX-XXXXXXXXXXXXXXXXXXXXXX"
CLIENT_SECRET = "XXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX"

# Unsplash API mode to use (API_DEMO or API_PRODUCTION)
API_MODE = UnsplashRandDownloader.API_DEMO

# Limit the number of images to be downloaded (None, to use the maximum
# calculated number from Unsplash API request limits DEMO/PRODUCTION)
LIMIT_MAX_NUM_IMG = None

# Path of directory to store the downloaded images
IMAGES_DOWNLOAD_DIR = "./images"

# Size of images to download
IMG_WIDTH = 320
IMG_HEIGHT = 240

# Topics of images to download
TOPICS = ["bird", "halloween", "fire", "computer"]

# Setup the Downloader
unsplash = UnsplashRandDownloader(APP_NAME, CLIENT_ID, CLIENT_SECRET, API_MODE)
unsplash.setup(IMAGES_DOWNLOAD_DIR, TOPICS, IMG_WIDTH, IMG_HEIGHT,
               LIMIT_MAX_NUM_IMG)

# Launch the Downloader
unsplash.start()

# Wait some time to allow UnsplashRandDownloader download some images
# ...

# Request a random image from downloaded images
img = unsplash.get_random_image()
if img is not None:
    print("Image Topic: {}".format(img["topic"]))
    print("Image ID: {}".format(img["id"]))
    print("Image Attribution: {}".format(img["attribution"]))
    #print("Image Raw: {}".format(img["image"]))

# To exit your application, remember to stop the downloader before
unsplash.stop()

Metadata

Release files for unsplash-rand-downloader 1.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for unsplash-rand-downloader 1.0.0
File Size Uploaded
unsplash_rand_downloader-1.0.0.tar.gz 8.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for unsplash-rand-downloader 1.0.0
File Interpreter ABI Platform
unsplash_rand_downloader-1.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 17.0 kB

Release files / unsplash_rand_downloader-1.0.0.tar.gz

Download URL unsplash_rand_downloader-1.0.0.tar.gz
Size 8.3 kB
Tags Source
SHA-256 checksum
How to use checksums
2aa5baf37ac0a9a5518fc8630bc74ce8517b96bcaba13f0e68c9928454e3fc2b
BLAKE2b-256 checksum
How to use checksums
af400c762deb1395028b1432056b2a4b5deb72195cae0b3fcd55e8d004de0564
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.20.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release files / unsplash_rand_downloader-1.0.0-py3-none-any.whl

Download URL unsplash_rand_downloader-1.0.0-py3-none-any.whl
Size 8.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
81586103ff842a1440f3b39fd53ac4ed9c9f4a2080ca3582940499deae5c0b45
BLAKE2b-256 checksum
How to use checksums
bfe75112d3034955e413872f95ea96666c40e60b46dfe5199ff796fdd3002f0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.20.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.0.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page