Skip to content

Commit

Permalink
Squashed commit of the following:
Browse files Browse the repository at this point in the history
commit 9d20093
Author: JokelBaf <[email protected]>
Date:   Sat Jun 1 15:56:59 2024 +0300

    chore: Bump PyPi version

commit 462d6e7
Author: seria <[email protected]>
Date:   Sat Jun 1 13:25:30 2024 +0900

    Remove the use of cookies in GeetestError

commit a2b2755
Author: JokelBaf <[email protected]>
Date:   Sat Jun 1 02:03:12 2024 +0300

    fix: Update genshin gacha url

commit 76afc28
Author: JokelBaf <[email protected]>
Date:   Sat Jun 1 01:52:27 2024 +0300

    Add HoYoLab geetest handling (thesadru#188)

commit 69f82a0
Author: ashlen <[email protected]>
Date:   Thu May 30 13:05:04 2024 +0000

    Bump pypi version

commit 1a1c03b
Author: seria <[email protected]>
Date:   Thu May 23 19:43:43 2024 +0900

    Merge dev Branch Into master (thesadru#187)

    * Add geetest v4 support, refactor geetest server code

    * Don't use pipe for older python versions compatibility

    * feat: Add create geetest functionality

    * Use client cookies in `create_geetest` method

    * Refactor and modelify auth component

    * Don't use pipe for older python versions compatibility (2)

    * feat: Add CNWebLoginResult and MobileLoginResult

    * refactor: Rename methods for better clarity

    * Add geetest proxying to bypass referrer check

    * Add hmac hashing function

    * Implement game login

    * Add regions decorators

    * Add error handling to `create_mmt` method

    * Add HI3 support

    * Refactor qr code models

    * Use game-specific `app_id`

    * refactor: Remove unnecessary cn login headers

    * refactor: Remove unnecessary headers

    * style: Format imports

    * feat: Use client's game when requesting qr code

    * Don't use explicit defaults in overloads

    * Use proper RSA key for cn routes

    * Merge captcha-related HTML

    * Reformat and fix type errors

    * Fix QR code imports

    * Add ZZZ support in game login

    * fix: Fix mypy errors

    Fixes error: "type" expects no type arguments, but 1 given [type-arg]
    Fixes error: "dict" is not subscriptable, use "typing.Dict" instead  [misc]

    * Fix HI3 new battle suit type

    * Fix icon assertion in tests

    * Fix QR code login invalid cookies error

    * Fix test failing because icon URL changed

    * Fix Signora test icon URL causing test to fail

    * Remove AccountNotFound exception test

    * Add `archon_quest_progress` to genshin notes

    * Add missing models to __all__

    * Add value to ArchonQuestStatus enum

    * Fix daily check-in for Miyoushe Genshin not working

    * Bypass referer check without using proxy

    * Allow passing encrypted credentials to all auth funcs

    * Fix cn daily check-in and update salt

    * Auto-detect account server during daily check-in

    * Rename HSR character path field and use enum

    * Add merged `login_with_password` method

    * Add missing `encrypted` arg

    * Rename `encrypt_geetest_credentials` into `encrypt_credentials`

    * Remove usage of pydantic V2 stuff

    * Ensure Pydantic V1 compatibility

    * Add exceptions for auth component

    * Prevent type check from failing

    ---------

    Co-authored-by: JokelBaf <[email protected]>
    Co-authored-by: Lalatina <[email protected]>

commit c32ed4b
Author: seria <[email protected]>
Date:   Sun Apr 14 09:02:51 2024 +0900

    Revert qrcode dependency fix (thesadru#180)

commit 28d3c2e
Author: seria <[email protected]>
Date:   Sat Apr 13 12:54:00 2024 +0900

    Move import statement of qrcode constants into method

commit a28a675
Author: seria <[email protected]>
Date:   Sat Apr 13 12:32:02 2024 +0900

    fix: Move qrcode lib import statement into method (thesadru#179)

commit 47aa014
Author: seria <[email protected]>
Date:   Sat Apr 13 12:27:59 2024 +0900

    Improve reformat session in nox (thesadru#178)

    * chore(deps): Remove sort-all from requirements

    * chore(nox): Update reformat session

    * style: Format `__all__`

commit 524b51a
Author: ashlen <[email protected]>
Date:   Wed Apr 10 17:49:12 2024 +0000

    Bump pypi version

commit b83eeb6
Author: seria <[email protected]>
Date:   Wed Apr 3 09:45:25 2024 +0900

    Fix update_charactes_enka function (thesadru#176)

commit 6b30d30
Author: seria <[email protected]>
Date:   Mon Apr 1 08:36:08 2024 +0900

    Fix get_banner_details (thesadru#174)

    * fix: Fix routes

    * fix: Fix routes and add temp fix

commit 4553200
Author: seria <[email protected]>
Date:   Mon Apr 1 07:49:32 2024 +0900

    Fix UID utilities to work with new Genshin UID standard (thesadru#171)

    * fix: Fix uid utilities

    * fix: Fix logic

    * refactor: Use string slicing approach

    * refactor: Use in-member check

commit 16d7a7c
Author: seria <[email protected]>
Date:   Mon Apr 1 07:27:20 2024 +0900

    Add QR code login method for Miyoushe (thesadru#173)

    * chore(deps): Add dependencies

    * feat: Add cookie and qrcode models

    * feat: Add new routes

    * feat: Add new ds salt

    * feat: Add new qrcode-related methods to GeetestClient

    * feat: Add new game token related functions

    * feat: Add new ds utilities

    * Export miyoushe modules

    * refactor: Refactor passport ds utility func

    * chore: Run nox

    * chore(deps): Merge qrcode and pillow

    * fix: Change account_id type to int

    * feat: Add public method to client

    * feat: Set cookies to client after obtaining cookies

    * chore(deps): Add qrcode[pil] to geetest extras

    * docs: Add docstring for private methods

commit 803b94d
Author: seria <[email protected]>
Date:   Thu Mar 28 23:34:44 2024 +0900

    Migrate to ruff (thesadru#168)

commit f6f4c11
Author: ashlen <[email protected]>
Date:   Wed Mar 27 12:02:03 2024 +0100

    Add star-rail notes to cli (thesadru#170)

    resolves thesadru#169

commit b387360
Author: seria <[email protected]>
Date:   Tue Mar 26 06:55:35 2024 +0800

    Add Miyoushe login methods (thesadru#167)

    * feat: Add CN password login

    * refactor: Refactor parse cookie code

    * style: Run nox

    * feat: Add OTP-related methods

    * refactor: Refactor according to reviews

    * refactor: Refactor according to reviews

commit f23467a
Author: seria <[email protected]>
Date:   Fri Mar 15 23:19:29 2024 +0900

    Add missing skill attribute in StarRailDetailCharacter (thesadru#166)

    * fix: Add missing skills attribute in hsr chara

commit 7b0af4e
Author: seria <[email protected]>
Date:   Fri Mar 15 18:06:18 2024 +0900

    Change icon provider to Enka (thesadru#165)

    * fix: Use Enka as new icon provider

    * Run nox

    * feat: Add new gacha_art property

    Add deprecation notice to image property
    Change image property to return gacha_art instead

commit dcbe321
Author: Igor Tankov <[email protected]>
Date:   Wed Mar 13 19:54:57 2024 +0300

    Update MI18N bbs link (thesadru#164)

commit be18224
Merge: 26dc4a5 e50fc4c
Author: seria <[email protected]>
Date:   Tue Mar 12 11:04:05 2024 +0900

    Merge pull request thesadru#163 from seriaati/master

    Fix missed_rewards property in DailyRewardInfo model

commit e50fc4c
Author: seria <[email protected]>
Date:   Tue Mar 12 09:57:35 2024 +0800

    Run nox

commit c963822
Author: seria <[email protected]>
Date:   Tue Mar 12 09:15:52 2024 +0800

    fix: Fix missed_rewards property calc method

commit 873cfac
Author: seria <[email protected]>
Date:   Tue Mar 12 08:55:05 2024 +0800

    fix: Fix KeyError if account has never done check-in

commit 2c510f8
Author: seria <[email protected]>
Date:   Tue Mar 12 08:29:15 2024 +0800

    fix: Fix wrong missed_rewards count in DailyRewardInfo

commit 26dc4a5
Author: JokelBaf <[email protected]>
Date:   Wed Mar 6 16:30:32 2024 +0200

    Complete hsr characters endpoint support (thesadru#161)

commit ed91363
Merge: 5a4a840 1c2e41d
Author: Konard <[email protected]>
Date:   Tue Mar 5 17:35:43 2024 -0600

    Merge pull request thesadru#162 from seriaati/master

    Update StarRailExpedition model

commit 1c2e41d
Author: seria <[email protected]>
Date:   Tue Mar 5 14:42:54 2024 +0800

    feat: Add `item_url` to `StarRailExpedition`

commit 5a4a840
Merge: a424187 9b31827
Author: JokelBaf <[email protected]>
Date:   Mon Mar 4 17:16:15 2024 +0200

    Merge pull request thesadru#160 from JokelBaf/master

    Fixes and improvements in geetest module

commit 9b31827
Author: JokelBaf <[email protected]>
Date:   Mon Mar 4 17:08:28 2024 +0200

    Fixes and improvements in geetest module

commit a424187
Author: Zhi Heng <[email protected]>
Date:   Tue Feb 6 22:25:39 2024 +0800

    Make HSR Pure Fiction floor buff optional (thesadru#158)

commit 202dc9e
Author: KT <[email protected]>
Date:   Sat Feb 3 07:38:32 2024 +0800

    Add HSR pure fiction (thesadru#157)
  • Loading branch information
KT-Yeh committed Jun 3, 2024
1 parent a595de9 commit 59f93f1
Show file tree
Hide file tree
Showing 59 changed files with 2,731 additions and 655 deletions.
44 changes: 0 additions & 44 deletions .flake8

This file was deleted.

14 changes: 1 addition & 13 deletions genshin-dev/lint-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
flake8

flake8-annotations-complexity # complex annotation
flake8-black # runs black
flake8-builtins # builtin shadowing
flake8-docstrings # proper formatting and grammar in docstrings
flake8-isort # runs isort
flake8-mutable # mutable default argument detection
flake8-pep3101 # new-style format strings only
flake8-print # complain about print statements in code
flake8-pytest-style # pytest checks
flake8-raise # exception raising
flake8-requirements # requirements.txt check
ruff
3 changes: 1 addition & 2 deletions genshin-dev/reformat-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
black
isort
sort-all
ruff
35 changes: 32 additions & 3 deletions genshin/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,10 @@ async def accounts(client: genshin.Client) -> None:

genshin_group: click.Group = click.Group("genshin", help="Genshin-related commands.")
honkai_group: click.Group = click.Group("honkai", help="Honkai-related commands.")
starrail_group: click.Group = click.Group("starrail", help="StarRail-related commands.")
cli.add_command(genshin_group)
cli.add_command(honkai_group)
cli.add_command(starrail_group)


@honkai_group.command("stats")
Expand All @@ -86,7 +88,7 @@ async def honkai_stats(client: genshin.Client, uid: int) -> None:
for k, v in data.stats.as_dict(lang=client.lang).items():
if isinstance(v, dict):
click.echo(f"{k}:")
for nested_k, nested_v in typing.cast("dict[str, object]", v).items():
for nested_k, nested_v in typing.cast("typing.Dict[str, object]", v).items():
click.echo(f" {nested_k}: {click.style(str(nested_v), bold=True)}")
else:
click.echo(f"{k}: {click.style(str(v), bold=True)}")
Expand Down Expand Up @@ -199,6 +201,33 @@ async def genshin_notes(client: genshin.Client, uid: typing.Optional[int]) -> No
click.echo(f" - {expedition.status}")


@starrail_group.command("notes")
@click.argument("uid", type=int, default=None, required=False)
@client_command
async def starrail_notes(client: genshin.Client, uid: typing.Optional[int]) -> None:
"""Show real-Time starrail notes."""
click.echo("Real-Time notes.")

data = await client.get_starrail_notes(uid)

click.echo(f"{click.style('TB power:', bold=True)} {data.current_stamina}/{data.max_stamina}", nl=False)
click.echo(f" (Full in {data.stamina_recover_time})" if data.stamina_recover_time > datetime.timedelta(0) else "")
click.echo(f"{click.style('Reserved TB power:', bold=True)} {data.current_reserve_stamina}/2400")
click.echo(f"{click.style('Daily training:', bold=True)} {data.current_train_score}/{data.max_train_score}")
click.echo(f"{click.style('Simulated Universe:', bold=True)} {data.current_rogue_score}/{data.max_rogue_score}")
click.echo(
f"{click.style('Echo of War:', bold=True)} {data.remaining_weekly_discounts}/{data.max_weekly_discounts}"
)

click.echo(f"\n{click.style('Assignments:', bold=True)} {data.accepted_epedition_num}/{data.total_expedition_num}")
for expedition in data.expeditions:
if expedition.remaining_time > datetime.timedelta(0):
remaining = f"{expedition.remaining_time} remaining"
click.echo(f" - {expedition.name} | {remaining}")
else:
click.echo(f" - {expedition.name} | Finished")


@cli.command()
@click.option("--scenario", help="Scenario ID or name to use (eg '12-3').", type=str, default=None)
@client_command
Expand Down Expand Up @@ -309,8 +338,8 @@ def authkey() -> None:
async def login(account: str, password: str, port: int) -> None:
"""Login with a password."""
client = genshin.Client()
cookies = await client.login_with_password(account, password, port=port)
cookies = await genshin.complete_cookies(cookies)
result = await client.os_login_with_password(account, password, port=port)
cookies = await genshin.complete_cookies(result.dict())

base: http.cookies.BaseCookie[str] = http.cookies.BaseCookie(cookies)
click.echo(f"Your cookies are: {click.style(base.output(header='', sep=';'), bold=True)}")
Expand Down
4 changes: 2 additions & 2 deletions genshin/client/clients.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""A simple HTTP client for API endpoints."""

from .components import (
auth,
calculator,
chronicle,
daily,
diary,
gacha,
geetest,
hoyolab,
lineup,
teapot,
Expand All @@ -28,6 +28,6 @@ class Client(
wiki.WikiClient,
gacha.WishClient,
transaction.TransactionClient,
geetest.GeetestClient,
auth.AuthClient,
):
"""A simple HTTP client for API endpoints."""
10 changes: 10 additions & 0 deletions genshin/client/components/auth/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
"""Auth-related utility.
Credits to:
- JokelBaf - https://github.com/jokelbaf
- Seria - https://github.com/seriaati
- M-307 - https://github.com/mrwan200
- gsuid_core - https://github.com/Genshin-bots/gsuid_core
"""

from .client import *
Loading

0 comments on commit 59f93f1

Please sign in to comment.