vkpymusic.utils
This module contains utilities for conversion and logging.
Classes:
Name | Description |
---|---|
Converter |
A class for performing various conversion operations. |
get_logger |
A function for getting or creating a logger. |
vkpymusic.utils.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
|
Response
|
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
|
Response
|
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
|
Response
|
The response object from VK. |
required |
Returns:
Name | Type | Description |
---|---|---|
UserInfo |
Optional[UserInfo]
|
A UserInfo converted from the response. |
response_to_popular(response)
staticmethod
Converts a response to a list of POPULAR songs.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
response
|
Response
|
The response object from VK. |
required |
Returns:
Type | Description |
---|---|
List[Song]
|
List[Song]: A list of songs converted from the response. |
vkpymusic.utils.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. |