Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mountaingod2/chaturbate_poller
Python package for fetching and processing events from the Chaturbate API.
https://github.com/mountaingod2/chaturbate_poller
api-client chaturbate chaturbate-api chaturbate-apps longpoll python3
Last synced: 23 days ago
JSON representation
Python package for fetching and processing events from the Chaturbate API.
- Host: GitHub
- URL: https://github.com/mountaingod2/chaturbate_poller
- Owner: MountainGod2
- License: mit
- Created: 2024-03-31T20:58:21.000Z (9 months ago)
- Default Branch: main
- Last Pushed: 2024-12-07T16:20:25.000Z (29 days ago)
- Last Synced: 2024-12-07T16:28:57.517Z (29 days ago)
- Topics: api-client, chaturbate, chaturbate-api, chaturbate-apps, longpoll, python3
- Language: Python
- Homepage: https://chaturbate-poller.readthedocs.io/
- Size: 7.89 MB
- Stars: 3
- Watchers: 0
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
- Security: SECURITY.md
Awesome Lists containing this project
README
# Chaturbate Poller
[![Read the Docs](https://img.shields.io/readthedocs/chaturbate-poller?link=https%3A%2F%2Fchaturbate-poller.readthedocs.io%2Fen%2Fstable%2F)](https://chaturbate-poller.readthedocs.io/en/stable/)
[![Codecov Coverage](https://img.shields.io/codecov/c/github/MountainGod2/chaturbate_poller/main?link=https%3A%2F%2Fapp.codecov.io%2Fgh%2FMountainGod2%2Fchaturbate_poller)](https://app.codecov.io/gh/MountainGod2/chaturbate_poller/)
[![CodeFactor Grade](https://img.shields.io/codefactor/grade/github/MountainGod2/chaturbate_poller?link=https%3A%2F%2Fwww.codefactor.io%2Frepository%2Fgithub%2Fmountaingod2%2Fchaturbate_poller)](https://www.codefactor.io/repository/github/mountaingod2/chaturbate_poller)
[![Workflow Status](https://img.shields.io/github/actions/workflow/status/MountainGod2/chaturbate_poller/docker-build.yml?branch=main&link=https%3A%2F%2Fgithub.com%2FMountainGod2%2Fchaturbate_poller%2Factions%2Fworkflows%2Fdocker-build.yml)](https://github.com/MountainGod2/chaturbate_poller/actions/workflows/docker-build.yml/)
[![License](https://img.shields.io/pypi/l/chaturbate-poller?link=https%3A%2F%2Fgithub.com%2FMountainGod2%2Fchaturbate_poller)](https://github.com/MountainGod2/chaturbate_poller?tab=MIT-1-ov-file)
[![Python Version](https://img.shields.io/pypi/pyversions/chaturbate-poller?link=https%3A%2F%2Fwww.python.org%2Fdownloads%2F)](https://www.python.org/downloads/)
[![Version](https://img.shields.io/pypi/v/chaturbate-poller?link=https%3A%2F%2Fpypi.org%2Fproject%2Fchaturbate-poller%2F)](https://pypi.org/project/chaturbate-poller/)**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:
```bash
pip install chaturbate-poller
```## Configuration
Create a `.env` file in your project’s root directory for API and InfluxDB credentials:
```text
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](https://chaturbate.com/statsapi/authtoken/) with the "Events API" permission enabled.## Usage
### CLI
Run the setup program:
```bash
python -m chaturbate_poller setup
```![image](https://github.com/user-attachments/assets/6060699d-022a-4526-b323-a140ee69e9c2)
Start the poller from the command line:
```bash
python -m chaturbate_poller start --username --token
```![image](https://github.com/user-attachments/assets/b80bf277-188d-4874-b52d-99f8cd6b1c3b)
For additional options:
```bash
python -m chaturbate_poller --help
```![image](https://github.com/user-attachments/assets/e564d698-a31f-4932-835e-44786a945747)
### Docker
Run Chaturbate Poller in Docker:
```bash
docker pull ghcr.io/mountaingod2/chaturbate_poller:latest
``````bash
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:
```python
import asyncio
from chaturbate_poller import ChaturbateClientasync 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
1. Clone the repository:
```bash
git clone https://github.com/MountainGod2/chaturbate_poller.git
cd chaturbate_poller
```2. Set up the environment and dependencies using [uv](https://docs.astral.sh/uv/):
```bash
uv venv
uv sync --all-extras
```## Contributing
Contributions are welcome! To contribute:
1. Fork the repository.
2. Create a feature branch.
3. Submit a pull request, ensuring tests and coding standards are met.## License
This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.