Fix Track model to match Python reference

- R128: changed from JSONR128 float64 to R128 struct with i, tp, important_secs fields
  (Python R128 is an object, not a number)
- StorageID -> StorageDir with json tag storage_dir (Python API uses storage_dir)
- Lyrics: replaced TrackLyricsInfo with Lyrics (from supplement/lyrics.py) and
  TrackLyricsInfo (from track/lyrics_info.py with has_available_sync_lyrics,
  has_available_text_lyrics fields)
- Track.Lyrics field now maps to lyrics_info JSON key with TrackLyricsInfo type
This commit is contained in:
Mrixs committed 2026-10-18 12:34:58 +03:00
1 parent ad83d84531
commit 6312c24b0f
5 files changed
+192 -52

No files matched your search

+12 -12
View File
@@ -30,7 +30,7 @@ func TestClient_GetTracks(t *testing.T) {
"id": "12345",
"title": "Test Track",
"duration_ms": 180000,
"storage_id": "67890",
"storage_dir": "67890",
"cover_uri": "https://example.com/cover.jpg",
"genre": "rock",
"version": "album",
@@ -42,7 +42,7 @@ func TestClient_GetTracks(t *testing.T) {
"artists": [{"id": "1", "name": "Artist 1", "cover_uri": "https://example.com/artist.jpg"}],
"albums": [{"id": "789", "title": "Test Album", "cover_uri": "https://example.com/album.jpg", "year": 2023}],
"major": {"id": "major1", "name": "Major Label", "description": "Big label"},
"lyrics": {"id": "lyr1", "text": "Test lyrics", "available": true, "has_text": true}
"lyrics_info": {"has_available_sync_lyrics": true, "has_available_text_lyrics": true}
}
]
}`),
@@ -63,8 +63,8 @@ func TestClient_GetTracks(t *testing.T) {
if tr.Major == nil || tr.Major.Name != "Major Label" {
t.Errorf("Expected Major 'Major Label'")
}
if tr.Lyrics == nil || tr.Lyrics.Text != "Test lyrics" {
t.Errorf("Expected Lyrics 'Test lyrics'")
if tr.LyricsInfo == nil || tr.LyricsInfo.HasAvailableSyncLyrics != true {
t.Errorf("Expected LyricsInfo.HasAvailableSyncLyrics true")
}
},
},
@@ -73,8 +73,8 @@ func TestClient_GetTracks(t *testing.T) {
trackIDs: []string{"12345", "67890"},
mockResponse: []byte(`{
"result": [
{"id": "12345", "title": "Track 1", "duration_ms": 100000, "storage_id": "1", "cover_uri": "", "genre": "", "version": "", "explicit": false, "available": true, "available_for_premium_users": true, "r128": 0, "track_sharing_flag": "", "artists": [], "albums": []},
{"id": "67890", "title": "Track 2", "duration_ms": 200000, "storage_id": "2", "cover_uri": "", "genre": "", "version": "", "explicit": false, "available": true, "available_for_premium_users": true, "r128": 0, "track_sharing_flag": "", "artists": [], "albums": []}
{"id": "12345", "title": "Track 1", "duration_ms": 100000, "storage_dir": "1", "cover_uri": "", "genre": "", "version": "", "explicit": false, "available": true, "available_for_premium_users": true, "r128": 0, "track_sharing_flag": "", "artists": [], "albums": []},
{"id": "67890", "title": "Track 2", "duration_ms": 200000, "storage_dir": "2", "cover_uri": "", "genre": "", "version": "", "explicit": false, "available": true, "available_for_premium_users": true, "r128": 0, "track_sharing_flag": "", "artists": [], "albums": []}
]
}`),
expectedTracks: 2,
@@ -189,7 +189,7 @@ func TestClient_GetTrack(t *testing.T) {
"id": "12345",
"title": "Test Track",
"duration_ms": 180000,
"storage_id": "67890",
"storage_dir": "67890",
"cover_uri": "https://example.com/cover.jpg",
"genre": "rock",
"version": "album",
@@ -201,7 +201,7 @@ func TestClient_GetTrack(t *testing.T) {
"artists": [{"id": "1", "name": "Artist 1", "cover_uri": "https://example.com/artist.jpg"}],
"albums": [{"id": "789", "title": "Test Album", "cover_uri": "https://example.com/album.jpg", "year": 2023}],
"major": {"id": "major1", "name": "Major Label", "description": "Big label"},
"lyrics": {"id": "lyr1", "text": "Test lyrics", "available": true, "has_text": true}
"lyrics_info": {"has_available_sync_lyrics": true, "has_available_text_lyrics": true}
}
]
}`),
@@ -311,7 +311,7 @@ func TestClient_SearchTracks(t *testing.T) {
"id": "1",
"title": "Track 1",
"duration_ms": 100000,
"storage_id": "1",
"storage_dir": "1",
"cover_uri": "",
"genre": "",
"version": "",
@@ -327,7 +327,7 @@ func TestClient_SearchTracks(t *testing.T) {
"id": "2",
"title": "Track 2",
"duration_ms": 200000,
"storage_id": "2",
"storage_dir": "2",
"cover_uri": "",
"genre": "",
"version": "",
@@ -408,7 +408,7 @@ func TestClient_SearchTracks_Mocked(t *testing.T) {
"id": "1",
"title": "Track 1",
"duration_ms": 100000,
"storage_id": "1",
"storage_dir": "1",
"cover_uri": "",
"genre": "",
"version": "",
@@ -424,7 +424,7 @@ func TestClient_SearchTracks_Mocked(t *testing.T) {
"id": "2",
"title": "Track 2",
"duration_ms": 200000,
"storage_id": "2",
"storage_dir": "2",
"cover_uri": "",
"genre": "",
"version": "",