unsplash-rand-downloader


Nameunsplash-rand-downloader JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/J-Rios/unsplash_rand_downloader
SummaryPython Unsplash random image downloader manager.
upload_time2023-05-20 10:30:37
maintainer
docs_urlNone
authorJose Miguel Rios Rubio
requires_python
licenseMIT
keywords unsplash random image
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # 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:

```bash
python3 -m pip install unsplash_rand_downloader
```

From Sources:

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

## Usage

```py

# 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()
```



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/J-Rios/unsplash_rand_downloader",
    "name": "unsplash-rand-downloader",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "",
    "maintainer_email": "",
    "keywords": "unsplash,random,image",
    "author": "Jose Miguel Rios Rubio",
    "author_email": "jrios.github@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/af/40/0c762deb1395028b1432056b2a4b5deb72195cae0b3fcd55e8d004de0564/unsplash_rand_downloader-1.0.0.tar.gz",
    "platform": null,
    "description": "# UnsplashRandDownloader\n\nPython Unsplash Random Image Downloader.\n\nThis 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.\n\n## Installation\n\nFrom Pypi:\n\n```bash\npython3 -m pip install unsplash_rand_downloader\n```\n\nFrom Sources:\n\n```bash\ngit clone https://www.github.com/J-Rios/unsplash_rand_downloader\ncd unsplash_rand_downloader\npython3 -m pip install .\n```\n\n## Usage\n\n```py\n\n# Import the module\nfrom unsplash_rand_downloader import UnsplashRandDownloader\n\n# Set your Unsplash API access account identification parameters\n# (Application Name, Client ID and Client Secret Key)\nAPP_NAME = \"XXXXXXXXXXXXXXX\"\nCLIENT_ID = \"XXXXXXXXXXX_XXXXX-XX-XXXXXXXXXXXXXXXXXXXXXX\"\nCLIENT_SECRET = \"XXXXXX-XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX\"\n\n# Unsplash API mode to use (API_DEMO or API_PRODUCTION)\nAPI_MODE = UnsplashRandDownloader.API_DEMO\n\n# Limit the number of images to be downloaded (None, to use the maximum\n# calculated number from Unsplash API request limits DEMO/PRODUCTION)\nLIMIT_MAX_NUM_IMG = None\n\n# Path of directory to store the downloaded images\nIMAGES_DOWNLOAD_DIR = \"./images\"\n\n# Size of images to download\nIMG_WIDTH = 320\nIMG_HEIGHT = 240\n\n# Topics of images to download\nTOPICS = [\"bird\", \"halloween\", \"fire\", \"computer\"]\n\n# Setup the Downloader\nunsplash = UnsplashRandDownloader(APP_NAME, CLIENT_ID, CLIENT_SECRET, API_MODE)\nunsplash.setup(IMAGES_DOWNLOAD_DIR, TOPICS, IMG_WIDTH, IMG_HEIGHT,\n               LIMIT_MAX_NUM_IMG)\n\n# Launch the Downloader\nunsplash.start()\n\n# Wait some time to allow UnsplashRandDownloader download some images\n# ...\n\n# Request a random image from downloaded images\nimg = unsplash.get_random_image()\nif img is not None:\n    print(\"Image Topic: {}\".format(img[\"topic\"]))\n    print(\"Image ID: {}\".format(img[\"id\"]))\n    print(\"Image Attribution: {}\".format(img[\"attribution\"]))\n    #print(\"Image Raw: {}\".format(img[\"image\"]))\n\n# To exit your application, remember to stop the downloader before\nunsplash.stop()\n```\n\n\n",
    "bugtrack_url": null,
    "license": "MIT",
    "summary": "Python Unsplash random image downloader manager.",
    "version": "1.0.0",
    "project_urls": {
        "Homepage": "https://github.com/J-Rios/unsplash_rand_downloader"
    },
    "split_keywords": [
        "unsplash",
        "random",
        "image"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfe75112d3034955e413872f95ea96666c40e60b46dfe5199ff796fdd3002f0b",
                "md5": "2bf855a39603acd3c214c090945efcce",
                "sha256": "81586103ff842a1440f3b39fd53ac4ed9c9f4a2080ca3582940499deae5c0b45"
            },
            "downloads": -1,
            "filename": "unsplash_rand_downloader-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "2bf855a39603acd3c214c090945efcce",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": null,
            "size": 8668,
            "upload_time": "2023-05-20T10:30:29",
            "upload_time_iso_8601": "2023-05-20T10:30:29.138177Z",
            "url": "https://files.pythonhosted.org/packages/bf/e7/5112d3034955e413872f95ea96666c40e60b46dfe5199ff796fdd3002f0b/unsplash_rand_downloader-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "af400c762deb1395028b1432056b2a4b5deb72195cae0b3fcd55e8d004de0564",
                "md5": "174977d79ae0474221e7241e75219403",
                "sha256": "2aa5baf37ac0a9a5518fc8630bc74ce8517b96bcaba13f0e68c9928454e3fc2b"
            },
            "downloads": -1,
            "filename": "unsplash_rand_downloader-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "174977d79ae0474221e7241e75219403",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": null,
            "size": 8294,
            "upload_time": "2023-05-20T10:30:37",
            "upload_time_iso_8601": "2023-05-20T10:30:37.952118Z",
            "url": "https://files.pythonhosted.org/packages/af/40/0c762deb1395028b1432056b2a4b5deb72195cae0b3fcd55e8d004de0564/unsplash_rand_downloader-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-05-20 10:30:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "J-Rios",
    "github_project": "unsplash_rand_downloader",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "unsplash-rand-downloader"
}
        
Elapsed time: 0.06962s