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.
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
Prerequisites
-
Ensure Python 3.8 or higher is installed on your system.
-
Install the necessary dependencies:
pip install chaturbate-poller
Environment Configuration
Create a .env
file in the root directory with the following content:
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"
INFLUXDB_INIT_MODE="setup"
INFLUXDB_INIT_USERNAME="admin"
INFLUXDB_INIT_PASSWORD="changeme"
INFLUXDB_INIT_ORG="chaturbate-poller"
INFLUXDB_INIT_BUCKET="my-bucket"
Replace the placeholder values with your actual credentials and configuration details.
Usage Examples
Basic Example
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.
Command-Line Interface (CLI)
Chaturbate Poller provides a CLI for ease of use. Below are the available commands and options.
Usage
python -m chaturbate_poller [OPTIONS]
Options
--version
: Show the version of Chaturbate Poller and exit.--testbed
: Use the testbed environment.--timeout
: Timeout for the API requests (default: 10 seconds).--username
: Chaturbate username (default: from environment variable).--token
: Chaturbate token (default: from environment variable).--verbose
: Enable verbose logging.
Example
python -m chaturbate_poller --username your_username --token your_token --verbose
This command will start the poller using the provided username and token, with verbose logging enabled.
Docker
Pull the Latest Image
docker pull ghcr.io/mountaingod2/chaturbate_poller:latest
Run the Container
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_INFLUX_TOKEN" \
-e INFLUXDB_ORG="chaturbate-poller" \
-e INFLUXDB_BUCKET="my-bucket" \
-v /$HOME/chaturbate_poller:/app \
ghcr.io/mountaingod2/chaturbate_poller:latest --testbed
Development
Setting Up a Development Environment
-
Create a virtual environment and activate it:
python -m venv .venv source .venv/bin/activate # On Windows, use `.venv\Scripts\Activate`
-
Install the development dependencies:
pip install -r requirements-dev.txt
-
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.
- Fork the repository.
- Create a new feature branch.
- Commit your changes.
- Push the branch to your fork.
- Open a pull request.
Please ensure your code adheres to the project's coding standards and includes appropriate tests.
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
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for chaturbate_poller-0.6.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | e0f73f5f63d18df56bc161b27dabe93e941e71896f69e3ff7aa6a37a16207ce0 |
|
MD5 | 28d17af064492eeb167f90b826dcc293 |
|
BLAKE2b-256 | 0659abb4d212fd87a8b9d7cf89b2f796e231a1e28f832e36cd5b50062229d996 |