Skip to main content

CLI Program for downloading images. Maybe by location too...

Project description

Overview

This is a command line tool used for retrieving images from various image search backends (e.g. Unsplash, Google). This tool is primarily developed for educational purposes to show people how to develop plugin friendly Python applications. Furthermore, it is an example project that shows how to effectively pair a handful of popular Python libraries to write command line applications.

To facilitate our plugin architecture, the pluggy library is used. Other libraries used include the following:

  • click: used for structuring the command line application 🖱 💻
  • pydantic: used for handling configuration file validation 🗃
  • rich: used for UX/UI elements and generally making the application more pretty 🌈

Why "latz"

"latz" is short and easy to type! This is super important when writing CLI programs. I also might add a geolocation search feature, so it is a reference to the word "latitude".

Quick Start

Installation

latz is available for install either on PyPI:

# Run from a new virtual environment
$ pip install latz

or my own anaconda.org channel:

$ conda create -n latz 'thath::latz'

If you are interested in tinkering around with the code yourself, you can also run it locally:

$ git clone git@github.com:/travishathaway/latz.git
$ cd latz
# Create a virtual environment however you like..
$ pip install -e .

Usage

Latz comes initially configured with the "unsplash" image search backend. To use this, you will need to create an Unsplash account and create a test application. After getting your "access_key", you can set this value by running this command:

$ latz config set search_backend_settings.unsplash.access_key=<YOUR_ACCESS_KEY>

Once this is configured, you can search Unsplash for bunny pictures:

$ latz search "bunny"
[
    ImageSearchResultSet(
        results=(
            ImageSearchResult(
                url='https://unsplash.com/photos/u_kMWN-BWyU/download?ixid=MnwzOTMwOTR8MHwxfHNlYXJjaHwxfHxidW5ueXxlbnwwfHx8fDE2Nzk0MTA2NzQ',
                width=3456,
                height=5184
            ),
            # ... results truncated
        ),
        total_number_results=10,
        search_backend='unsplash'
    )
]

Configuring

The configuration for latz is stored in your home direct and is in the JSON format. Below is a what a default version of this configuration looks like:

{
  "search_backends": [
    "unsplash"
  ],
  "search_backend_settings": {
    "placeholder": {
      "type": "kitten"
    },
    "unsplash": {
      "access_key": "your-access-key"
    }
  }
}

Latz will also search in your current working directory for a .latz.json file and use this in your configuration. Files in the current working directory will be prioritized over your home directory location.

To see other available image search backends, see Available image search backends below.

Available image search backends

Here are a list of the available search backends:

Built-in

  • "unsplash"
  • "placeholder"

Third-party

How to extend and write your own image search backend

Please see the creating plugins guide in the documentation.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

latz-0.2.0.tar.gz (28.0 kB view details)

Uploaded Source

Built Distribution

latz-0.2.0-py3-none-any.whl (32.1 kB view details)

Uploaded Python 3

File details

Details for the file latz-0.2.0.tar.gz.

File metadata

  • Download URL: latz-0.2.0.tar.gz
  • Upload date:
  • Size: 28.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.0 Darwin/21.3.0

File hashes

Hashes for latz-0.2.0.tar.gz
Algorithm Hash digest
SHA256 927154b5fa0312dc7c013bf8e15bdbff6e70e09c0c8dbe26aea87dcb5e9f94b2
MD5 756b53164278b19a340b052f671d6073
BLAKE2b-256 4a85efcdb366c28786122a38c6dfdbb3d349c0fac3cf4cc9ce5d5892988eb58b

See more details on using hashes here.

File details

Details for the file latz-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: latz-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 32.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.3.1 CPython/3.11.0 Darwin/21.3.0

File hashes

Hashes for latz-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 a983d8b402e2cda522545ba8207ab6b9b10c1b3fe70962d4f7c051e1c610e204
MD5 ef5002e4c1ecbf6916098e1b7eea1186
BLAKE2b-256 7f2a27eeb8c3185a4c0519bf6c3ac1038772c47b0bc533f906ccdba5168bdb98

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page