get_playlist: join multiple title runs (#667)
* Return complete titles when split on time-like strings:
```diff
>>> yt.get_playlist("PLaZPMsuQNCsWn0iVMtGbaUXO6z-EdZaZm")["title"]
-03 Jan
+03 Jan 12:09
```
* `test_get_playlist`: assert more props have the expected value/shape
Co-authored-by: sigma67 <sigma67.github@gmail.com>
This commit is contained in:
parent
1f14332eb4
commit
74411149d4
5 changed files with 43 additions and 13 deletions
|
|
@ -13,25 +13,28 @@ from ytmusicapi.exceptions import YTMusicUserError
|
|||
|
||||
class TestPlaylists:
|
||||
@pytest.mark.parametrize(
|
||||
("test_file", "owned"),
|
||||
"test_file",
|
||||
[
|
||||
("2024_03_get_playlist.json", True),
|
||||
("2024_03_get_playlist_public.json", False),
|
||||
("2024_07_get_playlist_collaborative.json", True),
|
||||
"2024_03_get_playlist.json",
|
||||
"2024_03_get_playlist_public.json",
|
||||
"2024_07_get_playlist_collaborative.json",
|
||||
],
|
||||
)
|
||||
def test_get_playlist_2024(self, yt, test_file, owned):
|
||||
with open(Path(__file__).parent.parent / "data" / test_file, encoding="utf8") as f:
|
||||
def test_get_playlist(self, yt, test_file):
|
||||
data_dir = Path(__file__).parent.parent / "data"
|
||||
with open(data_dir / test_file, encoding="utf8") as f:
|
||||
mock_response = json.load(f)
|
||||
with open(data_dir / "expected_output" / test_file, encoding="utf8") as f:
|
||||
expected_output = json.load(f)
|
||||
|
||||
with mock.patch("ytmusicapi.YTMusic._send_request", return_value=mock_response):
|
||||
playlist = yt.get_playlist("MPREabc")
|
||||
assert playlist["year"] == "2024"
|
||||
assert playlist["owned"] == owned
|
||||
assert "hours" in playlist["duration"] or "minutes" in playlist["duration"]
|
||||
assert playlist["id"]
|
||||
assert isinstance(playlist["description"], str) and playlist["description"]
|
||||
assert len(playlist["tracks"]) > 0
|
||||
assert playlist == playlist | expected_output
|
||||
|
||||
for thumbnail in playlist.get("thumbnails", []):
|
||||
assert thumbnail["url"] and thumbnail["width"] and thumbnail["height"]
|
||||
|
||||
assert len(playlist["tracks"]) > 0
|
||||
for track in playlist["tracks"]:
|
||||
assert isinstance(track["title"], str) and track["title"]
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue