Files
astrbot_plugin_bangumi/src/services/__init__.py
chenxiangtong a05ce6e07e fork
2026-03-26 17:38:47 +08:00

75 lines
1.8 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
from typing import TYPE_CHECKING, Any
import aiohttp
from .calendar import CalendarService
from .contracts import (
CalendarDay,
CalendarWeekday,
EpisodeItem,
MessageResult,
RenderData,
)
from .exceptions import (
BangumiApiError,
BangumiRateLimitError,
DatabaseError,
NoSubjectFound,
SubscriptionError,
)
from .schemas import Episode
from .subjects import SubjectsService
from .types import ImageSize, SubjectType
if TYPE_CHECKING:
from .search import SearchService
from .subscription import SubscriptionService
# 聚合类继承所有子Service的功能
class BangumiService(SubjectsService, CalendarService):
def __init__(
self,
access_token: str,
user_agent: str,
proxy: str | None = None,
session: aiohttp.ClientSession | None = None,
) -> None:
# 初始化最基础的父类 (BaseBangumiService)
# 因为所有Service都继承自BaseBangumiServicesuper会自动处理MRO链
super().__init__(access_token, user_agent, proxy, session=session)
def __getattr__(name: str) -> Any:
if name == "SearchService":
from .search import SearchService
return SearchService
if name == "SubscriptionService":
from .subscription import SubscriptionService
return SubscriptionService
raise AttributeError(f"module {__name__!r} has no attribute {name!r}")
__all__ = [
"BangumiApiError",
"BangumiRateLimitError",
"BangumiService",
"CalendarDay",
"CalendarService",
"CalendarWeekday",
"DatabaseError",
"Episode",
"EpisodeItem",
"ImageSize",
"MessageResult",
"NoSubjectFound",
"RenderData",
"SearchService",
"SubjectType",
"SubjectsService",
"SubscriptionError",
"SubscriptionService",
]