Skip to content

Commit

Permalink
feat: Rewrite and add ZZZ support (#24)
Browse files Browse the repository at this point in the history
* Add character models

* test: Split model tests into games

* Add New model

* Add full CharacterDetail model

* Update client and stuff

* Add weapon models

* Fix model issues

* Rewrite client

* Update README

* Remove unused logger

* Add weapon models

* Add bangboo and discs

* Fix minor issue with the DriveDiscDetail model

* Add pytest workflow

* Configure ruff workflow

* Fix dependencies

* Fix pytest worklow

* Run ruff on PR
  • Loading branch information
seriaati authored Jul 24, 2024
1 parent 138a4b4 commit 462f0a5
Show file tree
Hide file tree
Showing 28 changed files with 1,699 additions and 507 deletions.
30 changes: 30 additions & 0 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
name: Run Pytest

on:
push:
branches: [ main ]
workflow_dispatch:
pull_request:
branches: [ main ]

jobs:
ruff:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.11"

- name: Install poetry
uses: Gr1N/setup-poetry@v8

- name: Install dependencies
run: poetry install --with test

- name: Run pytest
run: poetry run pytest
25 changes: 3 additions & 22 deletions .github/workflows/ruff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ on:
push:
branches: [ main ]
workflow_dispatch:
pull_request:
branches: [ main ]

jobs:
ruff:
Expand All @@ -22,27 +24,6 @@ jobs:
run: |
python -m pip install --upgrade pip
pip install ruff
- name: Set git user
run: |
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
- name: Run linter
run: ruff check --fix --output-format=github .

- name: Commit auto-fix changes
run: |
git add .
git diff-index --quiet HEAD || git commit -m "fix: Apply ruff auto-fixes"
- name: Run formatter
run: ruff format .

- name: Commit formatting changes
run: |
git add .
git diff-index --quiet HEAD || git commit -m "style: Apply ruff formatting"
- name: Push changes
run: git push origin main
run: ruff check --output-format=github .
17 changes: 11 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,22 @@ Developing something for Hoyoverse games? Here's a collection of Python async AP
- [enka.py](https://github.com/seriaati/enka-py) is an Enka Network API wrapper for fetching in-game showcase.
- [yatta.py](https://github.com/seriaati/yatta) is a Project Yatta API wrapper for fetching Honkai Star Rail game data.
- [ambr.py](https://github.com/seriaati/ambr) is a Project Ambr API wrapper for fetching Genshin Impact game data.
- [hakushin.py](https://github.com/seriaati/hakushin-py) is a Hakushin API wrapper for fetching Genshin Impact and Honkai Star Rail beta game data.
- [hakushin.py](https://github.com/seriaati/hakushin-py) is a Hakushin API wrapper for fetching Genshin Impact and Honkai Star Rail beta game data and ZZZ game data.

## Introduction

hakushin-py is an async API wrapper for [hakush.in](https://hakush.in/) written in Python.
Hakush.in is a website that displays beta game data for Genshin Impact and Honkai Star Rail.
hakush.in is a website that displays Genshin Impact, Honkai Star Rail, Zenless Zone Zero, and Wuthering Waves game data.

> Note: I am not the developer of hakush.in
## Important Note

This wrapper does not support all endpoints from hakush.in, it is mainly focused on fetching the beta game data.
This means I selectively chose the endpoints and API fields that I personally think are useful for theorycrafting.
If you want a more complete wrapper for game data, use [ambry.py](https://github.com/seriaati/ambr) and [yatta.py](https://github.com/seriaati/yatta) instead.
If you want a more complete wrapper for game data, use [ambry.py](https://github.com/seriaati/ambr) and [yatta.py](https://github.com/seriaati/yatta) instead.
However, **there is an exception for ZZZ**, since Project Ambr and Yatta has no equivalent for ZZZ, this wrapper supports all endpoints for the ZZZ Hakushin API.
Regarding Wuthering Waves support for this wrapper, it is currently not planned.

### Features

Expand All @@ -29,7 +31,6 @@ If you want a more complete wrapper for game data, use [ambry.py](https://github
- Provides direct icon URLs.
- Supports Python 3.11+.
- Supports all game languages.
- Supports both Genshin Impact and Honkai Star Rail.
- Supports persistent caching using SQLite.
- Supports [Pydantic V2](https://github.com/pydantic/pydantic), this also means full autocomplete support.

Expand All @@ -50,8 +51,12 @@ import hakushin
import asyncio

async def main() -> None:
async with hakushin.HakushinAPI(hakushin.Language.EN) as client:
await client.fetch_new(hakushin.Game.GI)
async with hakushin.HakushinAPI(hakushin.Game.GI, hakushin.Language.EN) as client:
await client.fetch_characters()
async with hakushin.HakushinAPI(hakushin.Game.HSR, hakushin.Language.JA) as client:
await client.fetch_light_cones()
async with hakushin.HakushinAPI(hakushin.Game.ZZZ, hakushin.Language.KO) as client:
await client.fetch_weapons()

asyncio.run(main())
```
Expand Down
Loading

0 comments on commit 462f0a5

Please sign in to comment.