2019-12-27 18:14:51 +09:00
|
|
|
from typing import TYPE_CHECKING, Optional, List
|
|
|
|
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
from yandex_music import Client
|
|
|
|
|
2019-05-11 17:37:47 +09:00
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
|
|
|
|
|
|
class Link(YandexMusicObject):
|
|
|
|
def __init__(self,
|
2019-12-28 22:25:09 +09:00
|
|
|
title: str,
|
|
|
|
href: str,
|
|
|
|
type_: str,
|
|
|
|
social_network: Optional[str] = None,
|
2019-12-27 18:14:51 +09:00
|
|
|
client: Optional['Client'] = None,
|
|
|
|
**kwargs) -> None:
|
2019-05-11 17:37:47 +09:00
|
|
|
self.title = title
|
|
|
|
self.href = href
|
2019-12-27 04:51:29 +09:00
|
|
|
self.type = type_
|
2019-05-11 17:37:47 +09:00
|
|
|
|
|
|
|
self.social_network = social_network
|
|
|
|
|
|
|
|
self.client = client
|
2019-11-08 06:37:53 +09:00
|
|
|
self._id_attrs = (self.title, self.href, self.type)
|
2019-05-11 17:37:47 +09:00
|
|
|
|
|
|
|
@classmethod
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['Link']:
|
2019-05-11 17:37:47 +09:00
|
|
|
if not data:
|
|
|
|
return None
|
|
|
|
|
|
|
|
data = super(Link, cls).de_json(data, client)
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
@classmethod
|
Тайп хинты для Label, TrackPosition, Artist, ArtistAlbums, ArtistTracks, BriefInfo, Counts, Description, Link, Ratings, Vinyl, AlbumEvent, ArtistEvent, Day, Event, GeneratedPlaylist, TrackWithAds, Genre, Images, Title
2019-12-28 20:38:59 +09:00
|
|
|
def de_list(cls, data: dict, client: 'Client') -> List['Link']:
|
2019-05-11 17:37:47 +09:00
|
|
|
if not data:
|
|
|
|
return []
|
|
|
|
|
|
|
|
links = list()
|
|
|
|
for link in data:
|
|
|
|
links.append(cls.de_json(link, client))
|
|
|
|
|
|
|
|
return links
|