anisette

Anisette provider in a Python package.

Submodules

Classes

AnisetteDeviceConfig

Anisette

The main Anisette provider class.

Package Contents

class anisette.AnisetteDeviceConfig
server_friendly_description: str
unique_device_id: str
adi_id: str
local_user_uuid: str
classmethod default() typing_extensions.Self
class anisette.Anisette(ani_provider: anisette._ani_provider.AnisetteProvider)

The main Anisette provider class.

This is the main Anisette provider class, which provides the user-facing functionality of this package. Each instance of Anisette represents a single Anisette session.

This class should not be instantiated directly through its __init__ method. Instead, you should use Anisette.init() or Anisette.load() depending on your use case.

classmethod init(file: BinaryIO | str | pathlib.Path | None = None, default_device_config: anisette._device.AnisetteDeviceConfig | None = None) typing_extensions.Self

Initialize a new Anisette session from an Apple Music APK or Anisette.py library file.

The file type will be detected automatically. If :param:`file` is not provided, a library bundle will be downloaded automatically. This file is usually a few megabytes large.

Parameters:

file (BinaryIO, str, Path, None) – A file, path or URL to a library file or Apple Music APK.

Returns:

An instance of Anisette.

Return type:

Anisette

classmethod load(*files: BinaryIO | str | pathlib.Path, default_device_config: anisette._device.AnisetteDeviceConfig | None = None) typing_extensions.Self

Load a previously-initialized Anisette session.

Required files can be obtained using the Anisette.save_provisioning(), Anisette.save_libs() and/or Anisette.save_all() methods.

Parameters:

files (BinaryIO, str, Path) – File objects or paths that together form the provider’s virtual file system.

Returns:

An instance of Anisette.

Return type:

Anisette

save_provisioning(file: BinaryIO | str | pathlib.Path) None

Save provisioning data of this Anisette session to a file.

The size of this file is usually in the order of kilobytes.

Saving provisioning data is required if you want to re-use this session at a later time.

A session may be reconstructed from saved data using the Anisette.load() method.

The advantage of using this method over Anisette.save_all() is that it results in less overall disk usage when saving many sessions, since library data can be saved separately and may be re-used across sessions.

Parameters:

file (BinaryIO, str, Path) – The file or path to save provisioning data to.

save_libs(file: BinaryIO | str | pathlib.Path) None

Save library data to a file.

The size of this file is usually in the order of megabytes.

Library data is session-agnostic and may be used in as many sessions as you wish. It can also be used to initialize a new session, without requiring the full Apple Music APK.

The advantage of using this method over Anisette.save_all() is that it results in less overall disk usage when saving many sessions, since library data can be saved separately and may be re-used across sessions.

Parameters:

file (BinaryIO, str, Path) – The file or path to save library data to.

save_all(file: BinaryIO | str | pathlib.Path) None

Save a complete copy of this Anisette session to a file.

The size of this file is usually in the order of megabytes.

Saving session data is required if you want to re-use this session at a later time.

A session may be reconstructed from saved data using the Anisette.load() method.

The advantage of using this method over Anisette.save_provisioning() and Anisette.save_libs() is that it is easier to use, since all information to reconstruct the session is contained in a single file.

Parameters:

file (BinaryIO, str, Path) – The file or path to save session data to.

provision() None

Provision the virtual device, if it has not been provisioned yet.

In most cases it is not necessary to manually use this method, since Anisette.get_data() will call it implicitly.

get_data() dict[str, Any]

Obtain Anisette headers for this session.

Returns:

Anisette headers that may be used for authentication purposes.