Skip to main content

A CLI tool for indexing video files with programmatic access

Project description

Zapdos-Py

A CLI tool for indexing video files by extracting keyframes that can also be used programmatically.

Installation

To install zapdos-py, you can use pip:

pip install zapdos-py

Or if you're using uv:

uv pip install zapdos-py

Usage

Command Line Interface

After installation, you can use the zapdos-py command:

ZAPDOS_API_KEY=your_api_key_here zapdos-py <video_file_path> [--interval <seconds>]

This command will index the specified video file by extracting keyframes at regular intervals.

You can also set your API key as an environment variable:

export ZAPDOS_API_KEY=your_api_key_here
zapdos-py <video_file_path> [--interval <seconds>]

Programmatic Usage

You can also use zapdos-py programmatically in your Python code using the client-based approach:

from zapdos import Client

# Create a client with your API key
client = Client(api_key="your_api_key_here")

# Index a video file
try:
    result = client.index("path/to/your/video.mp4", interval_sec=30)
    print(f"Indexed {len(result['items'])} frames")
except FileNotFoundError as e:
    print(f"Error: {e}")
except ValueError as e:
    print(f"Error: {e}")

With Progress Callback

You can also provide a callback function to receive progress updates during the indexing process:

from zapdos import Client

def progress_callback(event_data):
    """Callback function to handle progress updates."""
    event_type = event_data.get("event")
    if event_type == "uploaded":
        print(f"Uploaded frame {event_data.get('file_id')}")
    elif event_type == "done-indexing":
        print("Indexing completed successfully!")
    elif event_type == "error":
        print(f"Error: {event_data.get('message')}")

# Create a client with your API key
client = Client(api_key="your_api_key_here")

# Index a video file with progress updates
try:
    result = client.index(
        "path/to/your/video.mp4", 
        interval_sec=30,
        progress_callback=progress_callback
    )
    print(f"Indexed {len(result['items'])} frames")
except FileNotFoundError as e:
    print(f"Error: {e}")
except ValueError as e:
    print(f"Error: {e}")

Example

CLI Usage

# Extract frames every 30 seconds (default)
export ZAPDOS_API_KEY=your_api_key_here
zapdos-py ./video.mp4

# Extract frames every 10 seconds
export ZAPDOS_API_KEY=your_api_key_here
zapdos-py ./video.mp4 --interval 10

Programmatic Usage

from zapdos import Client
from pathlib import Path

# Create a client with your API key
client = Client(api_key="your_api_key_here")

# Index a video file
video_path = Path("video.mp4")
try:
    result = client.index(video_path, interval_sec=30)
    print(f"Indexed {len(result['items'])} frames")
    for item in result['items']:
        print(f"  - {item}")
except FileNotFoundError as e:
    print(f"Error: {e}")
except ValueError as e:
    print(f"Error: {e}")

Supported Video Formats

Zapdos-Py supports the following video formats:

  • MP4 (.mp4)
  • AVI (.avi)
  • MOV (.mov)
  • MKV (.mkv)
  • WMV (.wmv)
  • FLV (.flv)
  • WEBM (.webm)
  • M4V (.m4v)
  • 3GP (.3gp, .3g2)
  • MPG/MPEG (.mpg, .mpeg, .m2v)

Development

To set up the project for development:

  1. Clone the repository
  2. Install uv if you haven't already: pip install uv
  3. Install the package in development mode:
    uv pip install --editable .
    
  4. Run the CLI tool:
    zapdos-py <video_file_path>
    

Testing

There are several ways to run the tests:

Using pytest (recommended):

pytest tests/

Using unittest directly:

python -m unittest tests.test_cli

Running the video indexer test:

python tests/test_video_indexer.py

License

This project is licensed under the MIT License.

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

zapdos_py-0.2.4.tar.gz (12.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

zapdos_py-0.2.4-py3-none-any.whl (13.0 kB view details)

Uploaded Python 3

File details

Details for the file zapdos_py-0.2.4.tar.gz.

File metadata

  • Download URL: zapdos_py-0.2.4.tar.gz
  • Upload date:
  • Size: 12.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for zapdos_py-0.2.4.tar.gz
Algorithm Hash digest
SHA256 b202d01f016b48454d9b0416fc7a26794702dd58921bc1925cf2d44fa52b236b
MD5 2532134bba9f1ada501a530e400a07f2
BLAKE2b-256 4c9991e729ac136df9858d483320050bb20d3faa59140a0c92e35b5f2bf5ebb5

See more details on using hashes here.

File details

Details for the file zapdos_py-0.2.4-py3-none-any.whl.

File metadata

  • Download URL: zapdos_py-0.2.4-py3-none-any.whl
  • Upload date:
  • Size: 13.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.8.13

File hashes

Hashes for zapdos_py-0.2.4-py3-none-any.whl
Algorithm Hash digest
SHA256 4ea25b55e580dcd76e4ac0d048427b32ba8c6768c8be4789ff3a6bd1d547bb8f
MD5 91c45f533e24df1ee7c481c3f5d0d071
BLAKE2b-256 0c5abbac5644885d701c911f03aad0693c9ff667f0a15ce28f8b833d6c73e655

See more details on using hashes here.

Supported by

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