get_album: track positions (#510)
* get_album (via parse_playlist_items): add track_position key + tests for the badly indexed album * get_album & parse_playlist_items: nav changes * parse_playlist_items: only add track_position for albums * parse_playlist_items & related test_browsing: track_position > track_number --------- Co-authored-by: sigma67 <sigma67.github@gmail.com>
This commit is contained in:
parent
b60bcd7675
commit
ba71fc998d
4 changed files with 18 additions and 3 deletions
|
|
@ -24,6 +24,12 @@ def fixture_sample_album() -> str:
|
|||
return "MPREb_4pL8gzRtw1p"
|
||||
|
||||
|
||||
@pytest.fixture(name="badly_indexed_album")
|
||||
def fixture_badly_indexed_album() -> str:
|
||||
"""Sean Paul - Dutty Classics Collection"""
|
||||
return "MPREb_TPH4WqN5pUo"
|
||||
|
||||
|
||||
@pytest.fixture(name="sample_video")
|
||||
def fixture_sample_video() -> str:
|
||||
"""Oasis - Wonderwall"""
|
||||
|
|
|
|||
|
|
@ -66,12 +66,13 @@ class TestBrowsing:
|
|||
escaped_browse_id = yt.get_album_browse_id("OLAK5uy_nbMYyrfeg5ZgknoOsOGBL268hGxtcbnDM")
|
||||
assert escaped_browse_id == "MPREb_scJdtUCpPE2"
|
||||
|
||||
def test_get_album(self, yt, yt_auth, sample_album):
|
||||
def test_get_album(self, yt, yt_auth, sample_album, badly_indexed_album):
|
||||
results = yt_auth.get_album(sample_album)
|
||||
assert len(results) >= 9
|
||||
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 "feedbackTokens" in results["tracks"][0]
|
||||
assert len(results["other_versions"]) >= 1 # appears to be regional
|
||||
results = yt.get_album("MPREb_BQZvl3BFGay")
|
||||
|
|
@ -79,6 +80,9 @@ class TestBrowsing:
|
|||
assert len(results["tracks"][0]["artists"]) == 1
|
||||
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_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
|
||||
|
|
|
|||
Loading…
Reference in a new issue