base
PlayCallback
¶
Bases: Protocol
Callback that gets called upon playing a title, it accepts a anime and the stream being played.
__call__(anime, stream)
¶
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anime
|
Anime
|
The anime argument passed to the callback. This is the currently playing anime. |
required |
stream
|
ProviderStream
|
The stream argument passed to the callback. That is the currently playing stream. |
required |
Source code in api/src/anipy_api/player/base.py
PlayerBase(play_callback=None)
¶
Bases: ABC
The abstract base class for all the players.
To list available players or get one by name, use list_players and get_player respectively.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
play_callback
|
Optional[PlayCallback]
|
Callback called upon starting to play a title with |
None
|
Source code in api/src/anipy_api/player/base.py
kill_player()
abstractmethod
¶
play_file(path)
abstractmethod
¶
play_title(anime, stream)
abstractmethod
¶
Play a stream of an anime.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
anime
|
Anime
|
The anime |
required |
stream
|
ProviderStream
|
The stream |
required |
SubProcessPlayerBase(player_path, extra_args, play_callback=None)
¶
Bases: PlayerBase
The base class for all players that are run through a sub process.
For documentation of the other functions look at the base class.
Example
Here is how you might implement such a player on your own:
class Mpv(SubProcessPlayerBase):
def __init__(self, player_path: str, extra_args: List[str] = [], rpc_client=None):
self.player_args_template = [ # (1)
"{stream_url}",
"--force-media-title={media_title}",
"--force-window=immediate",
*extra_args,
]
super().__init__(
rpc_client=rpc_client,
player_path=player_path,
extra_args=extra_args
)
- This is the important part, those arguments will later be passed to the player.
There are two format fields you can use
{stream_url}
and{media_title}
.
Attributes:
Name | Type | Description |
---|---|---|
player_args_template |
List[str]
|
A list of arguments that are passed to the player command.
Fields that are replaced are |
Parameters:
Name | Type | Description | Default |
---|---|---|---|
player_path
|
str
|
The path to the player's executable |
required |
extra_args
|
List[str]
|
Extra arguments to be passed to the player |
required |
play_callback
|
Optional[PlayCallback]
|
Callback called upon starting to play a title with |
None
|