Skip to content

Commit

Permalink
parse_playlist_items & related test_browsing: track_position > track_…
Browse files Browse the repository at this point in the history
…number
  • Loading branch information
jcbirdwell committed Jan 11, 2024
1 parent 9d65913 commit 0aff162
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions tests/mixins/test_browsing.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def test_get_album(self, yt, yt_auth, sample_album, badly_indexed_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_position"] == 1
assert results["tracks"][0]["track_number"] == 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 @@ -70,8 +70,8 @@ def test_get_album(self, yt, yt_auth, sample_album, badly_indexed_album):
results = yt.get_album("MPREb_rqH94Zr3NN0")
assert len(results["tracks"][0]["artists"]) == 2
results = yt.get_album(badly_indexed_album) # album with non-standard indexing
assert results["tracks"][0]["track_position"] == 3
assert results["tracks"][13]["track_position"] == 18
assert results["tracks"][0]["track_number"] == 3
assert results["tracks"][13]["track_number"] == 18

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
4 changes: 2 additions & 2 deletions ytmusicapi/parsers/playlists.py
Original file line number Diff line number Diff line change
Expand Up @@ -94,8 +94,8 @@ def parse_playlist_items(results, menu_entries: Optional[List[List]] = None, is_
}

if is_album:
track_pos_found = nav(data, ["index", "runs", 0, "text"], True)
song["track_position"] = track_pos_found if track_pos_found is None else int(track_pos_found)
track_idx_found = nav(data, ["index", "runs", 0, "text"], True)
song["track_number"] = track_idx_found if track_idx_found is None else int(track_idx_found)

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

0 comments on commit 0aff162

Please sign in to comment.