Skip to content

MountainGod2/chaturbate_poller

Repository files navigation

Chaturbate Poller

Chaturbate Poller is an asynchronous Python library designed to interface with the Chaturbate API.

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

Key Features

  • Error Management: Implements error handling and retry logic to manage network inconsistencies.
  • Configurable Logging: Detailed logging mechanisms for debugging and monitoring the poller's operations.
  • Data Persistence: Integrates with InfluxDB for storing event data, enabling further analysis and monitoring.

Installation

Ensure Python 3.8+ is installed, then run:

pip install chaturbate-poller

Configuration

Create a .env file at the root with the necessary environment variables:

CB_USERNAME="your_chaturbate_username"
CB_TOKEN="your_chaturbate_token"
USE_DATABASE="true"
INFLUXDB_URL="http://influxdb:8086"
INFLUXDB_TOKEN="your_influxdb_token"
INFLUXDB_ORG="chaturbate-poller"
INFLUXDB_BUCKET="your_bucket"
INFLUXDB_INIT_MODE="setup"
INFLUXDB_INIT_USERNAME="admin"
INFLUXDB_INIT_PASSWORD="changeme"
INFLUXDB_INIT_ORG="chaturbate-poller"
INFLUXDB_INIT_BUCKET="my-bucket"

Usage

The Chaturbate Poller can be used both as a library and a CLI tool. Below is an example of how to use it as a library to fetch events:

import asyncio
from chaturbate_poller.chaturbate_client import ChaturbateClient

async def main():
    async with ChaturbateClient('your_username', 'your_token') as client:
        events = await client.fetch_events()
        for event in events:
            print(event)

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

CLI Usage

python -m chaturbate_poller --username <your_username> --token <your_token>

Docker Usage

To run using Docker, pull the latest Docker image and run:

docker pull ghcr.io/mountaingod2/chaturbate_poller:latest
docker run \
  -e CB_USERNAME="your_chaturbate_username" \
  -e CB_TOKEN="your_chaturbate_api_token" \
  -e INFLUXDB_URL="http://influxdb:8086" \
  -e INFLUXDB_TOKEN="your_influxdb_token" \
  -e INFLUXDB_ORG="chaturbate-poller" \
  -e INFLUXDB_BUCKET="my-bucket" \
  -v /opt/chaturbate_poller:/app \ # Log storage only
  ghcr.io/mountaingod2/chaturbate_poller:latest --testbed

Development

Set up a virtual environment and install dependencies for development:

python -m venv .venv
source .venv/bin/activate
pip install poetry
poetry install

Contributing

Contributions are welcome! Please fork the repository, create a feature branch, and submit a pull request.

License

Distributed under the MIT License. See LICENSE for more information.

Acknowledgments

  • Chaturbate API
  • Python Asyncio Library
  • HTTPX for HTTP client capabilities
  • InfluxDB for data storage

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