-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #69 from yupix/develop
Develop
- Loading branch information
Showing
47 changed files
with
1,393 additions
and
453 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
from __future__ import annotations | ||
|
||
from typing import TYPE_CHECKING, Literal, overload | ||
|
||
from mipac.abstract.action import AbstractAction | ||
from mipac.http import HTTPClient, Route | ||
from mipac.models.channel import Channel | ||
from mipac.models.lite.channel import ChannelLite | ||
from mipac.types.channel import IChannel, IChannelLite | ||
|
||
if TYPE_CHECKING: | ||
from mipac.client import ClientManager | ||
|
||
|
||
class ClientChannelActions(AbstractAction): | ||
def __init__( | ||
self, channel_id: str | None = None, *, session: HTTPClient, client: ClientManager | ||
): | ||
self._channel_id: str | None = channel_id | ||
self._session: HTTPClient = session | ||
self._client: ClientManager = client | ||
|
||
async def favorite(self, channel_id: str | None = None): | ||
if self._client._config.use_version < 13: | ||
raise Exception() | ||
|
||
channel_id = self._channel_id or channel_id | ||
if channel_id is None: | ||
raise Exception() | ||
|
||
res: bool = await self._session.request( | ||
Route('POST', '/api/channels/favorite'), auth=True, json={'channelId': channel_id} | ||
) | ||
|
||
return res | ||
|
||
async def unfavorite(self, channel_id: str | None = None): | ||
|
||
if self._client._config.use_version < 13: | ||
raise Exception() | ||
|
||
channel_id = self._channel_id or channel_id | ||
if channel_id is None: | ||
raise Exception() | ||
|
||
res: bool = await self._session.request( | ||
Route('POST', '/api/channels/unfavorite'), auth=True, json={'channelId': channel_id} | ||
) | ||
|
||
return res | ||
|
||
|
||
class ChannelActions(ClientChannelActions): | ||
def __init__( | ||
self, channel_id: str | None = None, *, session: HTTPClient, client: ClientManager | ||
): | ||
super().__init__(channel_id=channel_id, session=session, client=client) | ||
|
||
async def get_my_favorite(self) -> list[Channel]: | ||
"""お気に入りに登録したチャンネルの一覧を取得します。 | ||
Returns | ||
------- | ||
Channel | ||
チャンネル | ||
""" | ||
if self._client._config.use_version < 13: | ||
raise Exception() | ||
|
||
res: list[IChannel] = await self._session.request( | ||
Route('POST', '/api/channels/my-favorites'), auth=True | ||
) | ||
return [Channel(i, client=self._client) for i in res] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.