Skip to content

vkpymusic.utils

This module contains utilities for conversion and logging.

Classes:

Name Description
Converter

A class for performing various conversion operations.

create_logger

A function for getting or creating a logger.

Converter

A class that converts a response from VK to a list of songs or playlists.

response_to_songs(response) staticmethod

Converts a response to a list of songs.

Parameters:

Name Type Description Default
response VkApiResponse

The response object from VK.

required

Returns:

Type Description
List[Song]

List[Song]: A list of songs converted from the response.

response_to_playlists(response) staticmethod

Converts a response to a list of playlists.

Parameters:

Name Type Description Default
response VkApiResponse

The response object from VK.

required

Returns:

Type Description
List[Playlist]

List[Playlist]: A list of playlists converted from the response.

response_to_userinfo(response) staticmethod

Converts a response to a UserInfo.

Parameters:

Name Type Description Default
response VkApiResponse

The response object from VK.

required

Returns:

Name Type Description
UserInfo UserInfo

A UserInfo converted from the response.

Converts a response to a list of POPULAR songs.

Parameters:

Name Type Description Default
response VkApiResponse

The response object from VK.

required

Returns:

Type Description
List[Song]

List[Song]: A list of songs converted from the response.

on_captcha_handler(url)

Default sync handler to captcha.

Parameters:

Name Type Description Default
url str

Url to captcha image.

required

Returns:

Name Type Description
str str

Key/decoded captcha.

on_2fa_handler()

Default sync handler to 2fa.

Returns:

Name Type Description
str str

code from VK/SMS.

on_invalid_client_handler()

Default sync handler to invalid_client.

on_critical_error_handler(response_or_error)

Default sync handler to critical error.

Parameters:

Name Type Description Default
response_auth_json ...

Message or object to research.

required

on_captcha_handler_async(url) async

Default async handler to captcha.

Parameters:

Name Type Description Default
url str

Url to captcha image.

required

Returns:

Name Type Description
str str

Key/decoded captcha.

on_2fa_handler_async() async

Default async handler to 2fa.

Returns:

Name Type Description
str str

code from VK/SMS.

on_invalid_client_handler_async() async

Default async handler to invalid_client.

on_critical_error_handler_async(response_or_error) async

Default async handler to critical error.

Parameters:

Name Type Description Default
response_auth_json ...

Message or object to research.

required

create_logger(name, console=True, file=True)

Returns a logger instance with configured handlers.

Parameters:

Name Type Description Default
name str

The name of the logger.

required
console bool

Whether to enable debug messages in the console.

True
file bool

Whether to enable debug messages in the log file.

True

Returns:

Name Type Description
logger Logger

A logger instance with configured handlers.