2019-12-28 22:25:09 +09:00
|
|
|
|
from typing import TYPE_CHECKING, Optional, List, Union
|
Добавлены тайп хинты в соответствии с документацией для следуюшщих классов: YandexMusicObject, Cover, Captcha, DownloadInfo, Experiments, Icon, InvocationInfo, Pager, PermissionAlerts, PromoCodeStatus, Settings, TrackShort, TracksList, Video #120
2019-12-24 16:17:04 +09:00
|
|
|
|
|
2020-01-26 21:19:22 +09:00
|
|
|
|
from yandex_music import YandexMusicObject
|
|
|
|
|
|
Добавлены тайп хинты в соответствии с документацией для следуюшщих классов: YandexMusicObject, Cover, Captcha, DownloadInfo, Experiments, Icon, InvocationInfo, Pager, PermissionAlerts, PromoCodeStatus, Settings, TrackShort, TracksList, Video #120
2019-12-24 16:17:04 +09:00
|
|
|
|
if TYPE_CHECKING:
|
|
|
|
|
from yandex_music import Client
|
|
|
|
|
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
|
|
|
|
|
class Video(YandexMusicObject):
|
2020-01-26 23:50:54 +09:00
|
|
|
|
"""Класс, представляющий .
|
|
|
|
|
|
|
|
|
|
Attributes:
|
Удаление избыточной информации (#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.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
|
|
|
|
|
Args:
|
Удаление избыточной информации (#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.
|
2020-01-26 23:50:54 +09:00
|
|
|
|
**kwargs: Произвольные ключевые аргументы полученные от API.
|
|
|
|
|
"""
|
|
|
|
|
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
def __init__(self,
|
2019-12-28 22:25:09 +09:00
|
|
|
|
title: str,
|
|
|
|
|
cover: Optional[str] = None,
|
|
|
|
|
embed_url: Optional[str] = None,
|
|
|
|
|
provider: Optional['str'] = None,
|
|
|
|
|
provider_video_id: Optional[Union[int, str]] = None,
|
|
|
|
|
youtube_url: Optional[str] = None,
|
|
|
|
|
thumbnail_url: Optional[str] = None,
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
duration=None,
|
|
|
|
|
text=None,
|
|
|
|
|
html_auto_play_video_player=None,
|
|
|
|
|
regions=None,
|
Добавлены тайп хинты в соответствии с документацией для следуюшщих классов: YandexMusicObject, Cover, Captcha, DownloadInfo, Experiments, Icon, InvocationInfo, Pager, PermissionAlerts, PromoCodeStatus, Settings, TrackShort, TracksList, Video #120
2019-12-24 16:17:04 +09:00
|
|
|
|
client: Optional['Client'] = None,
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
**kwargs):
|
Добавлен метод получения информации об артисте (Brief Info https://github.com/MarshalX/yandex-music-api/issues/9).
Добавлены следующие классы: BriefInfo, Description, Vinyl, PlaylistId.
Класс Video вынесен из пакета Search в корень.
Добавлен de_list в Cover.
Добавлены следующие поля в класс Artist: likes_count, full_names, description, countries, en_wikipedia_link, db_aliases, aliases, init_date, end_date.
Добавлено поле track_id в класс Chart.
Добавлено поле available_full_without_permission в класс Track.
Класс Video расширен для поддержки второго типа (используется в brief info, спасибо яндух) видео (добавлены необязательные поля cover, embed_url, provider, provider_video_id).
Обновлена документация.
2019-09-13 00:32:43 +09:00
|
|
|
|
self.title = title
|
|
|
|
|
|
|
|
|
|
# Видео из brief info
|
|
|
|
|
self.cover = cover
|
|
|
|
|
self.embed_url = embed_url
|
|
|
|
|
self.provider = provider
|
|
|
|
|
self.provider_video_id = provider_video_id
|
|
|
|
|
|
|
|
|
|
# Видео из результатов поиска
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
self.youtube_url = youtube_url
|
|
|
|
|
self.thumbnail_url = thumbnail_url
|
|
|
|
|
self.duration = duration
|
|
|
|
|
self.text = text
|
|
|
|
|
self.html_auto_play_video_player = html_auto_play_video_player
|
|
|
|
|
self.regions = regions
|
|
|
|
|
|
|
|
|
|
self.client = client
|
2019-11-08 04:52:26 +09:00
|
|
|
|
self._id_attrs = (self.provider_video_id, self.youtube_url, self.title)
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
|
|
|
|
|
@classmethod
|
Добавлены тайп хинты в соответствии с документацией для следуюшщих классов: YandexMusicObject, Cover, Captcha, DownloadInfo, Experiments, Icon, InvocationInfo, Pager, PermissionAlerts, PromoCodeStatus, Settings, TrackShort, TracksList, Video #120
2019-12-24 16:17:04 +09:00
|
|
|
|
def de_json(cls, data: dict, client: 'Client') -> Optional['Video']:
|
2020-01-26 22:17:09 +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.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`yandex_music.Video`: Объект класса :class:`yandex_music.Video`.
|
|
|
|
|
"""
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return None
|
|
|
|
|
|
|
|
|
|
data = super(Video, cls).de_json(data, client)
|
|
|
|
|
|
|
|
|
|
return cls(client=client, **data)
|
|
|
|
|
|
|
|
|
|
@classmethod
|
Добавлены тайп хинты в соответствии с документацией для следуюшщих классов: YandexMusicObject, Cover, Captcha, DownloadInfo, Experiments, Icon, InvocationInfo, Pager, PermissionAlerts, PromoCodeStatus, Settings, TrackShort, TracksList, Video #120
2019-12-24 16:17:04 +09:00
|
|
|
|
def de_list(cls, data: dict, client: 'Client') -> List['Video']:
|
2020-01-26 22:17:09 +09:00
|
|
|
|
"""Десериализация списка объектов.
|
|
|
|
|
|
|
|
|
|
Args:
|
|
|
|
|
data (:obj:`list`): Список словарей с полями и значениями десериализуемого объекта.
|
Удаление избыточной информации (#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.
|
2020-01-26 22:17:09 +09:00
|
|
|
|
|
|
|
|
|
Returns:
|
|
|
|
|
:obj:`list` из :obj:`yandex_music.Video`: Список объектов класса :class:`yandex_music.Video`.
|
|
|
|
|
"""
|
New supported objects: Search, Suggestions, Video, Best, AlbumSearchResult, ArtistSearchResult, PlaylistSearchResult, TrackSearchResult, VideoSearchResult,
The following methods are wrapped:
- /search
- /search/suggest
The following classes received optional fields instead of required ones: Album, Artist, Playlist, Track
Added "params" arg to the GET request
Code refactoring
2019-05-18 01:20:34 +09:00
|
|
|
|
if not data:
|
|
|
|
|
return []
|
|
|
|
|
|
|
|
|
|
videos = list()
|
|
|
|
|
for video in data:
|
|
|
|
|
videos.append(cls.de_json(video, client))
|
|
|
|
|
|
|
|
|
|
return videos
|