vkpymusic.models
This module contains all models for vkpymusic.
Classes:
Name | Description |
---|---|
Song |
A class that represents a song. |
Playlist |
A class that represents a playlist. |
UserInfo |
A class that represents a main user's info. |
vkpymusic.models.Song
A class that represents a song.
Attributes:
Name | Type | Description |
---|---|---|
title |
str
|
The title of the song. |
artist |
str
|
The artist of the song. |
duration |
int
|
The duration of the song in seconds. |
track_id |
str
|
The ID of the song. |
owner_id |
str
|
The ID of the song's owner. |
url |
str
|
The URL of the song. |
__init__(title, artist, duration, track_id, owner_id, url='')
Initializes a Song object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
The title of the song. |
required |
artist
|
str
|
The artist of the song. |
required |
duration
|
int
|
The duration of the song in seconds. |
required |
track_id
|
str
|
The ID of the song. |
required |
owner_id
|
str
|
The ID of the song's owner. |
required |
url
|
str
|
The URL of the song. |
''
|
to_dict()
Converts the song to a dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The song as a dictionary. |
to_safe()
Removes all non-alphanumeric characters from the song's title and artist.
from_json(item)
classmethod
Creates a Song object from a JSON object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
dict
|
A JSON object. |
required |
Returns:
Name | Type | Description |
---|---|---|
Song |
Song
|
A Song object. |
vkpymusic.models.Playlist
A class that represents a playlist.
Attributes:
Name | Type | Description |
---|---|---|
title |
str
|
The title of the playlist. |
description |
str
|
The description of the playlist. |
photo |
str
|
The URL of the playlist's photo. |
count |
int
|
The number of tracks in the playlist. |
owner_id |
int
|
The ID of the playlist's owner. |
playlist_id |
int
|
The ID of the playlist. |
access_key |
str
|
The access key of the playlist. |
__init__(title, description, photo, count, followers, owner_id, playlist_id, access_key)
Initializes a Playlist object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
title
|
str
|
The title of the playlist. |
required |
description
|
str
|
The description of the playlist. |
required |
photo
|
str
|
The URL of the playlist's photo. |
required |
count
|
int
|
The number of tracks in the playlist. |
required |
owner_id
|
int
|
The ID of the playlist's owner. |
required |
playlist_id
|
int
|
The ID of the playlist. |
required |
access_key
|
str
|
The access key of the playlist. |
required |
to_dict()
Converts the playlist to a dictionary.
Returns:
Name | Type | Description |
---|---|---|
dict |
dict
|
The playlist as a dictionary. |
from_json(item)
classmethod
Converts a JSON object to a Playlist object.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
item
|
dict
|
A JSON object. |
required |
Returns:
Name | Type | Description |
---|---|---|
Playlist |
Playlist
|
The Playlist object. |
vkpymusic.models.UserInfo
A class that represents a user.
Attributes:
Name | Type | Description |
---|---|---|
userid |
int
|
The ID of the user. |
first_name |
str
|
The first name of the user. |
last_name |
str
|
The last name of the user. |
photo |
str
|
The URL of the user's photo. |
phone |
str
|
The phone number of the user. |
__init__(userid, first_name, last_name, photo='', phone='')
Initializes a UserInfo object.
Args: userid (int): The ID of the user. first_name (str): The first name of the user. last_name (str): The last name of the user. photo (str): The URL of the user's photo. phone (str): The phone number of the user.
to_dict()
Converts the user to a dictionary.
from_json(item)
classmethod
Converts a JSON object to a UserInfo object.