Skip to content

Commit

Permalink
get_album: rename track_number to trackNumber
Browse files Browse the repository at this point in the history
  • Loading branch information
sigma67 committed Jan 21, 2024
1 parent 9170197 commit 650bc24
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tests/mixins/test_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def test_get_album(self, yt, yt_auth, sample_album):
assert results["tracks"][0]["isExplicit"]
assert all(item["views"] is not None for item in results["tracks"])
assert all(item["album"] is not None for item in results["tracks"])
assert results["tracks"][0]["track_number"] == 1
assert results["tracks"][0]["trackNumber"] == 1
assert "feedbackTokens" in results["tracks"][0]
assert len(results["other_versions"]) >= 1 # appears to be regional
results = yt.get_album("MPREb_BQZvl3BFGay")
Expand All @@ -81,10 +81,10 @@ def test_get_album(self, yt, yt_auth, sample_album):
results = yt.get_album("MPREb_rqH94Zr3NN0")
assert len(results["tracks"][0]["artists"]) == 2
results = yt.get_album("MPREb_TPH4WqN5pUo") # album with tracks completely removed/missing
assert results["tracks"][0]["track_number"] == 3
assert results["tracks"][13]["track_number"] == 18
assert results["tracks"][0]["trackNumber"] == 3
assert results["tracks"][13]["trackNumber"] == 18
results = yt.get_album("MPREb_YuigcYm2erf") # album with track (#8) disabled/greyed out
assert results["tracks"][7]["track_number"] is None
assert results["tracks"][7]["trackNumber"] is None

def test_get_song(self, config, yt, yt_oauth, sample_video):
song = yt_oauth.get_song(config["uploads"]["private_upload_id"]) # private upload
Expand Down
3 changes: 2 additions & 1 deletion ytmusicapi/mixins/browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ def get_album(self, browseId: str) -> Dict:
returned by :py:func:`search`
:return: Dictionary with album and track metadata.
Each track is in the following format::
The result is in the following format::
{
"title": "Revival",
Expand Down Expand Up @@ -471,6 +471,7 @@ def get_album(self, browseId: str) -> Dict:
"isExplicit": true,
"duration": "5:03",
"duration_seconds": 303,
"trackNumber": 0,
"feedbackTokens": {
"add": "AB9zfpK...",
"remove": "AB9zfpK..."
Expand Down
2 changes: 1 addition & 1 deletion ytmusicapi/mixins/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def get_playlist(
:return: Dictionary with information about the playlist.
The key ``tracks`` contains a List of playlistItem dictionaries
Each item is in the following format::
The result is in the following format::
{
"id": "PLQwVIlKxHM6qv-o99iX9R85og7IzF9YS_",
Expand Down
2 changes: 1 addition & 1 deletion ytmusicapi/parsers/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def parse_playlist_items(results, menu_entries: Optional[List[List]] = None, is_
}

if is_album:
song["track_number"] = int(nav(data, ["index", "runs", 0, "text"])) if isAvailable else None
song["trackNumber"] = int(nav(data, ["index", "runs", 0, "text"])) if isAvailable else None

if duration:
song["duration"] = duration
Expand Down

0 comments on commit 650bc24

Please sign in to comment.