Skip to content

Commit

Permalink
Add HSR pure fiction (thesadru#157)
Browse files Browse the repository at this point in the history
  • Loading branch information
KT-Yeh authored Feb 2, 2024
1 parent 374abd8 commit 202dc9e
Show file tree
Hide file tree
Showing 78 changed files with 179 additions and 21 deletions.
4 changes: 3 additions & 1 deletion .flake8
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ exclude = tests, test.py
# D105: Missing docstring in magic method
# D106: Missing docstring Model.Config
# D419: Docstring is empty
# E704: Multiple statements on one line (def)
# S101: Use of assert for type checking
# S303: Use of md5
# S311: Use of pseudo-random generators
Expand All @@ -14,7 +15,8 @@ exclude = tests, test.py
ignore =
A001, A002, A003,
C408,
D105, D106, D419
D105, D106, D419,
E704,
S101, S303, S311, S324,
W503,

Expand Down
1 change: 1 addition & 0 deletions genshin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
Source Code: https://github.com/thesadru/genshin.py
"""

from . import models, utility
from .client import *
from .constants import *
Expand Down
1 change: 1 addition & 0 deletions genshin/__main__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""CLI tools."""

import asyncio
import datetime
import functools
Expand Down
1 change: 1 addition & 0 deletions genshin/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Default client implementation."""

from . import components
from .cache import *
from .clients import *
Expand Down
1 change: 1 addition & 0 deletions genshin/client/cache.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Cache for client."""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions genshin/client/clients.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""A simple HTTP client for API endpoints."""

from .components import (
calculator,
chronicle,
Expand Down
1 change: 1 addition & 0 deletions genshin/client/compatibility.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Reverse-compatibility layer for previous versions."""

from __future__ import annotations

import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/base.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Base ABC Client."""

import abc
import asyncio
import base64
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/calculator/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Calculator client."""

from .client import *
1 change: 1 addition & 0 deletions genshin/client/components/calculator/calculator.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Over-engineered for the sake of extendability and maintainability.
"""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/calculator/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Calculator client."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/chronicle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
"""Battle chronicle client components."""

from .client import *
1 change: 1 addition & 0 deletions genshin/client/components/chronicle/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Battle chronicle component."""

from . import genshin, honkai, starrail

__all__ = ["BattleChronicleClient"]
Expand Down
13 changes: 13 additions & 0 deletions genshin/client/components/chronicle/starrail.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""StarRail battle chronicle component."""

import asyncio
import typing

Expand Down Expand Up @@ -126,3 +127,15 @@ async def get_starrail_rogue(
payload = dict(schedule_type=schedule_type, need_detail="true")
data = await self._request_starrail_record("rogue", uid, lang=lang, payload=payload)
return models.StarRailRogue(**data)

async def get_starrail_pure_fiction(
self,
uid: typing.Optional[int] = None,
*,
previous: bool = False,
lang: typing.Optional[str] = None,
) -> models.StarRailPureFiction:
"""Get starrail pure fiction runs."""
payload = dict(schedule_type=2 if previous else 1, need_all="true")
data = await self._request_starrail_record("challenge_story", uid, lang=lang, payload=payload)
return models.StarRailPureFiction(**data)
7 changes: 3 additions & 4 deletions genshin/client/components/daily.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Daily reward component."""

import asyncio
import datetime
import functools
Expand Down Expand Up @@ -150,8 +151,7 @@ async def claim_daily_reward( # noqa: D102 missing docstring in overload?
lang: typing.Optional[str] = None,
reward: typing.Literal[True] = ...,
challenge: typing.Optional[typing.Mapping[str, str]] = None,
) -> models.DailyReward:
...
) -> models.DailyReward: ...

@typing.overload
async def claim_daily_reward( # noqa: D102 missing docstring in overload?
Expand All @@ -161,8 +161,7 @@ async def claim_daily_reward( # noqa: D102 missing docstring in overload?
lang: typing.Optional[str] = None,
reward: typing.Literal[False],
challenge: typing.Optional[typing.Mapping[str, str]] = None,
) -> None:
...
) -> None: ...

async def claim_daily_reward(
self,
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/diary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Diary component."""

import datetime
import functools
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/gacha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wish component."""

import asyncio
import functools
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/geetest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
Credits to M-307 - https://github.com/mrwan200
"""

from .client import *
1 change: 1 addition & 0 deletions genshin/client/components/geetest/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Geetest client component."""

import json
import typing

Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/geetest/server.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Aiohttp webserver used for captcha solving and email verification."""

from __future__ import annotations

import asyncio
Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/hoyolab.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Hoyolab component."""

import asyncio
import typing

Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/lineup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Lineup component."""

import functools
import typing

Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/teapot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Teapot component."""

import functools
import typing

Expand Down
1 change: 1 addition & 0 deletions genshin/client/components/transaction.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Transaction client."""

import functools
import typing
import urllib.parse
Expand Down
16 changes: 6 additions & 10 deletions genshin/client/components/wiki.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Wiki component."""

import typing

from genshin import types
Expand Down Expand Up @@ -34,44 +35,39 @@ async def get_wiki_previews( # noqa: D102 missing docstring in overload?
menu: typing.Literal[models.WikiPageType.CHARACTER],
*,
lang: typing.Optional[str] = None,
) -> typing.Sequence[models.CharacterPreview]:
...
) -> typing.Sequence[models.CharacterPreview]: ...

@typing.overload
async def get_wiki_previews( # noqa: D102 missing docstring in overload?
self,
menu: typing.Literal[models.WikiPageType.WEAPON],
*,
lang: typing.Optional[str] = None,
) -> typing.Sequence[models.WeaponPreview]:
...
) -> typing.Sequence[models.WeaponPreview]: ...

@typing.overload
async def get_wiki_previews( # noqa: D102 missing docstring in overload?
self,
menu: typing.Literal[models.WikiPageType.ARTIFACT],
*,
lang: typing.Optional[str] = None,
) -> typing.Sequence[models.ArtifactPreview]:
...
) -> typing.Sequence[models.ArtifactPreview]: ...

@typing.overload
async def get_wiki_previews( # noqa: D102 missing docstring in overload?
self,
menu: typing.Literal[models.WikiPageType.ENEMY],
*,
lang: typing.Optional[str] = None,
) -> typing.Sequence[models.EnemyPreview]:
...
) -> typing.Sequence[models.EnemyPreview]: ...

@typing.overload
async def get_wiki_previews( # noqa: D102 missing docstring in overload?
self,
menu: int,
*,
lang: typing.Optional[str] = None,
) -> typing.Sequence[models.BaseWikiPreview]:
...
) -> typing.Sequence[models.BaseWikiPreview]: ...

async def get_wiki_previews(
self,
Expand Down
1 change: 1 addition & 0 deletions genshin/client/manager/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
"""Cookie managers."""

from .cookie import *
from .managers import *
1 change: 1 addition & 0 deletions genshin/client/manager/cookie.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
- stoken (v2) + mid -> ltoken_v2 (token_type=2)
- stoken (v2) + mid -> cookie_token_v2 (token_type=4)
"""

from __future__ import annotations

import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/client/manager/managers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Cookie managers for making authenticated requests."""

from __future__ import annotations

import abc
Expand Down
1 change: 1 addition & 0 deletions genshin/client/ratelimit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Ratelimit handlers."""

import asyncio
import functools
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/client/routes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""API routes."""

import abc
import typing

Expand Down
1 change: 1 addition & 0 deletions genshin/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Constants hardcoded for optimizations."""

from . import types

__all__ = ["LANGS"]
Expand Down
1 change: 1 addition & 0 deletions genshin/errors.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Errors received from the API."""

import typing

__all__ = [
Expand Down
1 change: 1 addition & 0 deletions genshin/models/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""API models."""

from .genshin import *
from .honkai import *
from .hoyolab import *
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin models."""

from .calculator import *
from .character import *
from .chronicle import *
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/calculator.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin calculator models."""

from __future__ import annotations

import collections
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/chronicle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Battle chronicle models."""

from .abyss import *
from .activities import *
from .characters import *
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/chronicle/activities.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Chronicle activities models."""

import datetime
import re
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/chronicle/notes.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin chronicle notes."""

import datetime
import enum
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/chronicle/tcg.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin serenitea pot replica display models."""

from __future__ import annotations

import enum
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/constants.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin model constants."""

import typing

__all__ = ["CHARACTER_NAMES", "DBChar"]
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/daily.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Daily reward models."""

import calendar
import datetime
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/diary.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin diary models."""

import datetime
import enum
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/gacha.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin wish models."""

import datetime
import enum
import re
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/lineup.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin lineup models."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/teapot.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin serenitea pot replica display models."""

from __future__ import annotations

import datetime
Expand Down
1 change: 1 addition & 0 deletions genshin/models/genshin/wiki.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Genshin wish models."""

import enum
import json
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/models/honkai/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Honkai models."""

from .battlesuit import *
from .chronicle import *
from .constants import *
1 change: 1 addition & 0 deletions genshin/models/honkai/battlesuit.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Honkai battlesuit model."""

import logging
import re
import typing
Expand Down
1 change: 1 addition & 0 deletions genshin/models/honkai/chronicle/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Battle chronicle models."""

from .battlesuits import *
from .modes import *
from .stats import *
1 change: 1 addition & 0 deletions genshin/models/honkai/chronicle/battlesuits.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""Honkai chronicle battlesuits."""

import re
import typing

Expand Down
Loading

0 comments on commit 202dc9e

Please sign in to comment.