2019-12-27 18:14:51 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional
|
|
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
2019-12-27 18:14:51 +09:00
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from yandex_music import Client
|
|
|
|
|
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
|
|
|
|
|
class User(YandexMusicObject):
|
2020-01-26 08:55:56 +09:00
|
|
|
|
"""Класс, представляющий пользователя.
|
2019-11-11 03:43:04 +09:00
|
|
|
|
|
|
|
|
|
Attributes:
|
2019-11-12 02:35:51 +09:00
|
|
|
|
uid (:obj:`int`): Идентификатор пользователя.
|
|
|
|
|
login (:obj:`str`): Логин пользователя.
|
|
|
|
|
name (:obj:`str`): Имя пользователя.
|
|
|
|
|
sex (:obj:`str`): Пол пользователя.
|
2019-11-12 02:54:33 +09:00
|
|
|
|
verified (:obj:`bool`): Участвует ли пользователь в генерации плейлистов дня и т.д., и т.п.
|
2020-03-22 08:04:39 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`): Клиент Yandex Music.
|
2019-11-11 03:43:04 +09:00
|
|
|
|
|
|
|
|
|
Args:
|
2019-11-12 02:35:51 +09:00
|
|
|
|
uid (:obj:`int`): Идентификатор пользователя.
|
|
|
|
|
login (:obj:`str`): Логин пользователя.
|
|
|
|
|
name (:obj:`str`): Имя пользователя.
|
|
|
|
|
sex (:obj:`str`): Пол пользователя.
|
2019-11-12 02:54:33 +09:00
|
|
|
|
verified (:obj:`bool`): Участвует ли пользователь в генерации плейлистов дня и т.д., и т.п.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-11-11 03:43:04 +09:00
|
|
|
|
**kwargs: Произвольные ключевые аргументы полученные от API.
|
|
|
|
|
"""
|
2019-11-12 03:16:13 +09:00
|
|
|
|
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
def __init__(self,
|
Добавлены тайп хинты для Block, BlockEntity, Char, CharItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShortOld, AlbumsLikes, ArtistsLikes, PlaylistsLikes, CaseForms, MadeFor, PlayCounter, PlaylistAbsence, PlaylistId, User
2019-12-27 22:40:26 +09:00
|
|
|
|
uid: int,
|
|
|
|
|
login: str,
|
|
|
|
|
name: str,
|
|
|
|
|
sex: str,
|
|
|
|
|
verified: bool,
|
2019-12-27 18:14:51 +09:00
|
|
|
|
client: Optional['Client'] = None,
|
|
|
|
|
**kwargs) -> None:
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
self.uid = uid
|
|
|
|
|
self.login = login
|
|
|
|
|
self.name = name
|
|
|
|
|
self.sex = sex
|
|
|
|
|
self.verified = verified
|
|
|
|
|
|
|
|
|
|
self.client = client
|
2019-11-10 03:11:43 +09:00
|
|
|
|
self._id_attrs = (self.uid, self.login)
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
|
Добавлены тайп хинты для Block, BlockEntity, Char, CharItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShortOld, AlbumsLikes, ArtistsLikes, PlaylistsLikes, CaseForms, MadeFor, PlayCounter, PlaylistAbsence, PlaylistId, User
2019-12-27 22:40:26 +09:00
|
|
|
|
def download_avatar(self, filename: str, format_: str = 'normal') -> None:
|
2019-08-18 23:44:46 +09:00
|
|
|
|
"""Загрузка изображения пользователя.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
filename (:obj:`str`): Путь для сохранения файла с названием и расширением.
|
2020-01-26 21:19:22 +09:00
|
|
|
|
format_ (:obj:`str`, optional): Формат желаемого изображения (`normal`, `orig`, `small`, `big`).
|
2019-08-18 23:44:46 +09:00
|
|
|
|
"""
|
2019-12-27 04:51:29 +09:00
|
|
|
|
self.client.request.download(f'https://upics.yandex.net/{self.uid}/{format_}', filename)
|
2019-08-18 23:44:46 +09:00
|
|
|
|
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
@classmethod
|
Добавлены тайп хинты для Block, BlockEntity, Char, CharItem, MixLink, PersonalPlaylistsData, PlayContext, PlayContextsData, Promotion, TrackId, TrackShortOld, AlbumsLikes, ArtistsLikes, PlaylistsLikes, CaseForms, MadeFor, PlayCounter, PlaylistAbsence, PlaylistId, User
2019-12-27 22:40:26 +09:00
|
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['User']:
|
2019-11-11 03:43:04 +09:00
|
|
|
|
"""Десериализация объекта.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`dict`): Поля и значения десериализуемого объекта.
|
Удаление избыточной информации (#247)
Классы: Account, AutoRenewable, PassportPhone, Permissions, Plus, Price,
Product, Status, Subscription, UserSettings, Album, Label,
TrackPosition, Playlist
У всех классов изменено описание атрибута client
2020-03-22 04:49:20 +09:00
|
|
|
|
client (:obj:`yandex_music.Client`, optional): Клиент Yandex Music.
|
2019-11-11 03:43:04 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
2020-03-22 06:29:34 +09:00
|
|
|
|
:obj:`yandex_music.User`: Пользователь.
|
2019-11-11 03:43:04 +09:00
|
|
|
|
"""
|
New supported objects: Album, CaseForms, Label, Library, MadeFor, Major, Normalization, PlayCounter, Playlist, Track, TrackPosition, TrackShort, User
The following methods are wrapped:
- albums;
- playlists/list;
- users/{user_id}/playlists/list;
- tracks;
- users/{user_id}/likes/tracks.
Added property to get full track ID
Cover received more optional fields
Ability to pass arguments to the request
Removed unnecessary type conversions
2019-05-13 02:39:12 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(User, cls).de_json(data, client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
2019-08-18 23:44:46 +09:00
|
|
|
|
|
|
|
|
|
# camelCase псевдонимы
|
|
|
|
|
|
2019-10-19 17:55:45 +09:00
|
|
|
|
#: Псевдоним для :attr:`download_avatar`
|
2019-08-18 23:44:46 +09:00
|
|
|
|
downloadAvatar = download_avatar
|