Accounts Reference
The accounts interface provides a way to login, register and modify user specific data with the Kemono API.
Accounts
- class pykemo.accounts.account.Account(*, id, username, created_at, role, session)
A Kemono account.
Warning
It is not recommended to use unless you know what you’re doing. Methods like
login()are preferred as they automatically create a session internally.- Parameters:
id (
int) – The account ID.username (
str) – The name of the user’s account.created_at (
datetime.datetime) – When was the account created.role (
AccountRole) – The special role/rank of the account.session (
KemoSession) – The underlying session of the account context.
- async change_password(current_password, new_password, close_on_fail=True)
Attempts to change the current password for this account.
Warning
Be careful. If this launches an exception and
close_on_failis set toFalse, the internal session will not close. It’s the responsability of the programmer at this point to close it if that happens.- Parameters:
current_password (
str) – The password that is already set.new_password (
str) – The new value to overwrite the current password with.close_on_fail (
bool, optional) – Wether to close the internal session if this launches an exception, defaults toTrue.
- Raises:
PyKemoException – If the change fails for whatever reason.
- Return type:
None
- async favorite_artists()
Tries to retrieve this account’s favorite artists. Alias for
favorite_creators().- Returns:
The list of favorite artists (creators).
- Return type:
list[
Creator]
- async favorite_creators()
Tries to retrieve this account’s favorite creators.
- Returns:
The list of favorite creators.
- Return type:
list[
Creator]
- async favorite_posts()
Tries to retrieve this account’s favorite posts.
- Returns:
The list of favorite posts.
- Return type:
list[
Post]
- async get_creator(service, creator_id)
A wrapper for fetching a creator with the account session.
- Parameters:
service (
ServiceLike) – The service of the creator.creator_id (str) – The ID of the creator.
- Returns:
The creator instance, if found. Otherwise returns
None.- Return type:
Optional[
Creator]
- async classmethod login(user, password)
Tries to login with a given user and password.
- Parameters:
user (
str) – The username to try to login with.password (
str) – The password to try to login with.
- Raises:
InvalidLogin – The login had incorrect data.
AlreadyLoggedIn – The user is already logged in.
LoginError – Another error ocurred.
- Returns:
The account of the user, if sucessfully logged in.
- Return type:
- async logout()
Log out of the session.
- Return type:
None
- async random_creator()
Wrapper for retrieving a random creator from the site.
- Returns:
If a creator is found, retrieve and create a
Creatorinstance, otherwise returnNone.- Return type:
Optional[
Creator]
- async random_post()
Wrapper for retrieving a random post from the site.
- async classmethod register(user, password)
Tries to register a accountuser.
- Parameters:
user (
str) – The username to try to register with.password (
str) – The password to try to register with.
- Raises:
InvalidRegister – Failed to register due to user errors.
RegisterError – Another error ocurred.
- Returns:
The account of the user, if sucessfully logged in after registering.
- Return type: