Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues/#509 Новые поля #576

Merged
merged 16 commits into from
Mar 27, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
16 commits
Select commit Hold shift + click to select a range
466c887
Классу Playlist добавлены новые поля
andrew097 Nov 25, 2022
c7bae21
Классу TrackShort добавлено поле original_index
andrew097 Nov 25, 2022
0b69164
Добавлен класс r128, описывающий свойства трека.
andrew097 Nov 25, 2022
7d58b79
Добавлен класс LyricsInfo, описывающий наличие текстов трека
andrew097 Nov 25, 2022
8ba2bb6
Классу Track добавлены новые поля
andrew097 Nov 25, 2022
3e54bea
Merge branch 'issues/#509_TrackShort' into issues/#509_NewFields
andrew097 Nov 25, 2022
b29db00
Merge branch 'issues/#509_Track' into issues/#509_NewFields
andrew097 Nov 25, 2022
1b16af4
Обновлена документация.
andrew097 Nov 25, 2022
d8fe47f
Добавлены известные занчения поля track_source. Исправления по ревью
andrew097 Nov 28, 2022
8b307cb
Изменено наименование класса R128. Актуализирована документация, скор…
andrew097 Nov 28, 2022
1f9838e
Исправлено описание поля
andrew097 Nov 28, 2022
f7814ca
Исправлена документация к методу
andrew097 Nov 28, 2022
9657e64
Классу Album добавлено новое поле
andrew097 Nov 28, 2022
65505d6
Класс R128, обновлена документация класса
andrew097 Nov 28, 2022
2e08bbe
Изменения по ревью
andrew097 Dec 3, 2022
99c82ed
Исправлена документация
MarshalX Mar 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ def artist_decomposed(artist_without_nested_artist):


@pytest.fixture(scope='session')
def track_factory(major, normalization, user, meta_data, poetry_lover_match):
def track_factory(major, normalization, user, meta_data, poetry_lover_match, r128_, lyrics_info):
class TrackFactory:
def get(self, artists, albums, track_without_nested_tracks=None):
return Track(
Expand Down Expand Up @@ -292,6 +292,11 @@ def get(self, artists, albums, track_without_nested_tracks=None):
TestTrack.background_video_uri,
TestTrack.short_description,
TestTrack.is_suitable_for_children,
TestTrack.track_source,
TestTrack.available_for_options,
r128_,
lyrics_info,
TestTrack.track_sharing_flag,
)

return TrackFactory()
Expand Down
22 changes: 22 additions & 0 deletions tests/test_track.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,9 @@ class TestTrack:
' желания познакомиться с девушкой, достаточно много. Обычно они сводятся к опасениям,'
)
is_suitable_for_children = True
track_source = 'OWN'
available_for_options = ['bookmate']
track_sharing_flag = 'VIDEO_ALLOWED'

def test_expected_values(
self,
Expand All @@ -48,6 +51,8 @@ def test_expected_values(
user,
meta_data,
poetry_lover_match,
r128_,
lyrics_info,
):
assert track.id == self.id
assert track.title == self.title
Expand Down Expand Up @@ -87,6 +92,11 @@ def test_expected_values(
assert track.background_video_uri == self.background_video_uri
assert track.short_description == self.short_description
assert track.is_suitable_for_children == self.is_suitable_for_children
assert track.track_source == self.track_source
assert track.available_for_options == self.available_for_options
assert track.r128 == r128_
assert track.lyrics_info == lyrics_info
assert track.track_sharing_flag == self.track_sharing_flag

def test_de_json_none(self, client):
assert Track.de_json({}, client) is None
Expand All @@ -111,6 +121,8 @@ def test_de_json_all(
user,
meta_data,
poetry_lover_match,
r128_,
lyrics_info,
):
json_dict = {
'id': self.id,
Expand Down Expand Up @@ -151,6 +163,11 @@ def test_de_json_all(
'background_video_uri': self.background_video_uri,
'short_description': self.short_description,
'is_suitable_for_children': self.is_suitable_for_children,
'track_source': self.track_source,
'available_for_options': self.available_for_options,
'r128': r128_.to_dict(),
'lyrics_info': lyrics_info.to_dict(),
'track_sharing_flag': self.track_sharing_flag,
}
track = Track.de_json(json_dict, client)

Expand Down Expand Up @@ -192,6 +209,11 @@ def test_de_json_all(
assert track.background_video_uri == self.background_video_uri
assert track.short_description == self.short_description
assert track.is_suitable_for_children == self.is_suitable_for_children
assert track.track_source == self.track_source
assert track.available_for_options == self.available_for_options
assert track.r128 == r128_
assert track.lyrics_info == lyrics_info
assert track.track_sharing_flag == self.track_sharing_flag

def test_equality(self):
a = Track(self.id)
Expand Down
21 changes: 20 additions & 1 deletion yandex_music/track/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
MetaData,
PoetryLoverMatch,
TrackLyrics,
LyricsInfo,
r128,
)


Expand All @@ -29,6 +31,10 @@ class Track(YandexMusicObject):

Известные значения поля `type`: `music`.

Известные значения поля `track_sharing_flag`: 'VIDEO_ALLOWED', 'COVER_ONLY'
andrew097 marked this conversation as resolved.
Show resolved Hide resolved

Известные значения поля `available_for_options`: 'bookmate'
andrew097 marked this conversation as resolved.
Show resolved Hide resolved

Поля `can_publish`, `state`, `desired_visibility`, `filename`, `user_info` доступны только у треков что были
загружены пользователем.

Expand Down Expand Up @@ -76,6 +82,12 @@ class Track(YandexMusicObject):
background_video_uri (:obj:`str`, optional): Ссылка на видеошот.
short_description (:obj:`str`, optional): Краткое опсание эпизода подкаста.
is_suitable_for_children (:obj:`bool`, optional): Подходит ли для детей TODO.
track_source (:obj:`str`, optional): Источник трека.
available_for_options (:obj:`list` из :obj:`str`, optional): Возможные опции для трека.
r128 (:obj:`yandex_music.r128`, optional): Свойства трека.
andrew097 marked this conversation as resolved.
Show resolved Hide resolved
lyrics_info (:obj:`yandex_music.LyricsInfo`, optional): Данные о наличии текстов трека.
track_sharing_flag (:obj:`str`, optional): TODO.

client (:obj:`yandex_music.Client`): Клиент Yandex Music.
"""

Expand Down Expand Up @@ -117,6 +129,11 @@ class Track(YandexMusicObject):
background_video_uri: Optional[str] = None
short_description: Optional[str] = None
is_suitable_for_children: Optional[bool] = None
track_source: Optional[str] = None
available_for_options: Optional[List[str]] = None
andrew097 marked this conversation as resolved.
Show resolved Hide resolved
r128: Optional['r128'] = None
andrew097 marked this conversation as resolved.
Show resolved Hide resolved
lyrics_info: Optional['LyricsInfo'] = None
track_sharing_flag: Optional[str] = None
client: Optional['Client'] = None

def __post_init__(self):
Expand Down Expand Up @@ -466,7 +483,7 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Track']:
return None

data = super(Track, cls).de_json(data, client)
from yandex_music import Normalization, Major, Album, Artist, User, MetaData, PoetryLoverMatch
from yandex_music import Normalization, Major, Album, Artist, User, MetaData, PoetryLoverMatch, r128, LyricsInfo

data['albums'] = Album.de_list(data.get('albums'), client)
data['artists'] = Artist.de_list(data.get('artists'), client)
Expand All @@ -477,6 +494,8 @@ def de_json(cls, data: dict, client: 'Client') -> Optional['Track']:
data['user_info'] = User.de_json(data.get('user_info'), client)
data['meta_data'] = MetaData.de_json(data.get('meta_data'), client)
data['poetry_lover_matches'] = PoetryLoverMatch.de_list(data.get('poetry_lover_matches'), client)
data['r128'] = r128.de_json(data.get('r128'), client)
andrew097 marked this conversation as resolved.
Show resolved Hide resolved
data['lyrics_info'] = LyricsInfo.de_json(data.get('lyrics_info'), client)

return cls(client=client, **data)

Expand Down