Chaturbate Poller is a Python library and CLI for polling events from the Chaturbate API. It provides asynchronous event handling, logging, and optional integration with InfluxDB to store event data for analysis.
Features
- Event Polling: Efficiently poll events from Chaturbate’s API.
- Error Handling: Includes backoff and retry mechanisms.
- Logging: Console and JSON file logging for structured insights.
- Optional InfluxDB Storage: Store events in InfluxDB for analysis or monitoring.
Installation
Ensure Python 3.11 or later is installed, then install via pip:
pip install chaturbate-poller
Configuration
Create a .env
file in your project’s root directory for API and InfluxDB credentials:
CB_USERNAME="your_chaturbate_username"
CB_TOKEN="your_chaturbate_token"
INFLUXDB_URL="http://influxdb:8086"
INFLUXDB_TOKEN="your_influxdb_token"
INFLUXDB_ORG="chaturbate-poller"
INFLUXDB_BUCKET="your_bucket"
USE_DATABASE="false" # Set to `true` if InfluxDB is used
[!NOTE]
Generate an API token here with the "Events API" permission enabled.
Usage
CLI
Run the setup program:
python -m chaturbate_poller setup
Start the poller from the command line:
python -m chaturbate_poller start --username <your_username> --token <your_token>
For additional options:
python -m chaturbate_poller --help
Docker
Run Chaturbate Poller in Docker:
docker pull ghcr.io/mountaingod2/chaturbate_poller:latest
docker run \
-e CB_USERNAME="your_chaturbate_username" \
-e CB_TOKEN="your_chaturbate_token" \
ghcr.io/mountaingod2/chaturbate_poller:latest --verbose --testbed
Library Usage
To use Chaturbate Poller as a library, here's a sample script to fetch events in a loop:
import asyncio
from chaturbate_poller import ChaturbateClient
async def main():
async with ChaturbateClient("your_username", "your_token", testbed=False) as client:
url = None
while True:
response = await client.fetch_events(url)
for event in response.events:
print(event.model_dump())
url = response.next_url
if __name__ == "__main__":
asyncio.run(main())
Development
-
Clone the repository:
git clone https://github.com/MountainGod2/chaturbate_poller.git
cd chaturbate_poller
-
Set up the environment and dependencies using uv:
uv venv
uv sync --all-extras
Contributing
Contributions are welcome! To contribute:
- Fork the repository.
- Create a feature branch.
- Submit a pull request, ensuring tests and coding standards are met.
License
This project is licensed under the MIT License. See the LICENSE file for more details.