Skip to main content

Poller for the Chaturbate events API.

Project description

Chaturbate Poller

Chaturbate Poller is a Python application designed to periodically fetch and process events from the Chaturbate API. It utilizes asynchronous HTTP requests and parses the received events for further processing or storage.

Read the Docs Codecov Coverage CodeFactor Grade Workflow Status License Python Version Version

Features

  • Asynchronous event fetching from the Chaturbate API.
  • Error handling and retry logic for network requests.
  • Logging of fetched events and error conditions for audit and debugging.
  • Environment variable-based configuration for API credentials.

Requirements

  • Python 3.8+
  • httpx
  • pydantic
  • asyncio
  • python-dotenv

Setup

To set up the Chaturbate Poller, follow these steps:

  1. Ensure Python 3.8 or higher is installed on your system.

  2. Install the Python package:

    pip install chaturbate-poller
    
  3. Set up your environment variables by creating a .env file in the root directory with the following content:

    CB_USERNAME="your_chaturbate_username"
    CB_TOKEN="your_api_token"
    

    Replace your_chaturbate_username and your_api_token with your actual Chaturbate username and API token.

Usage Examples

Here's a basic example to get you started with fetching events from the Chaturbate API:

import asyncio
import logging
import os

from chaturbate_poller import ChaturbateClient
from dotenv import load_dotenv

load_dotenv()

username = os.getenv("CB_USERNAME", "")
token = os.getenv("CB_TOKEN", "")

async def main() -> None:
    async with ChaturbateClient(username, token, 20) as client:
        response = await client.fetch_events()
        for event in response.events:
            logging.info(event.dict())  # Log the event as a dictionary

if __name__ == "__main__":
    asyncio.run(main())

The application will start and begin fetching and printing events from the Chaturbate API using the credentials provided in the .env file.

For more detailed usage examples, including handling specific event types and using the included Pydantic models, see the examples/ directory.

Development

To set up a development environment, especially to run tests or develop additional features, consider setting up a virtual environment and installing the development dependencies:

  1. Create a virtual environment and activate it:

    python -m venv .venv
    source .venv/bin/activate  # On Windows, use `.venv\Scripts\Activate`
    
  2. Install the development dependencies:

    pip install -r requirements-dev.txt
    
  3. To run tests:

    pytest
    

Contributing

Contributions to the Chaturbate Poller are welcome! Please follow the standard fork-and-pull request workflow on GitHub to submit your changes.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Credits

chaturbate_poller was created with cookiecutter and the py-pkgs-cookiecutter template.

Project details


Release history Release notifications | RSS feed

This version

0.5.7

Download files

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

Source Distribution

chaturbate_poller-0.5.7.tar.gz (11.9 kB view hashes)

Uploaded Source

Built Distribution

chaturbate_poller-0.5.7-py3-none-any.whl (12.6 kB view hashes)

Uploaded Python 3

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