get_album: return new "views" key for each track
This commit is contained in:
parent
1971121add
commit
f3e747103f
2 changed files with 12 additions and 1 deletions
|
|
@ -266,6 +266,8 @@ class TestYTMusic(unittest.TestCase):
|
|||
results = self.yt_auth.get_album(sample_album)
|
||||
self.assertGreaterEqual(len(results), 9)
|
||||
self.assertTrue(results["tracks"][0]["isExplicit"])
|
||||
self.assertTrue(all(item["views"] is not None for item in results["tracks"]))
|
||||
self.assertTrue(all(item["album"] is not None for item in results["tracks"]))
|
||||
self.assertIn("feedbackTokens", results["tracks"][0])
|
||||
self.assertGreaterEqual(len(results["other_versions"]), 1) # appears to be regional
|
||||
results = self.yt.get_album("MPREb_BQZvl3BFGay")
|
||||
|
|
@ -483,7 +485,9 @@ class TestYTMusic(unittest.TestCase):
|
|||
|
||||
def test_get_playlist_foreign(self):
|
||||
self.assertRaises(Exception, self.yt.get_playlist, "PLABC")
|
||||
playlist = self.yt.get_playlist("PLk5BdzXBUiUe8Q5I13ZSCD8HbxMqJUUQA", limit=300, suggestions_limit=7)
|
||||
playlist = self.yt_auth.get_playlist(
|
||||
"PLk5BdzXBUiUe8Q5I13ZSCD8HbxMqJUUQA", limit=300, suggestions_limit=7
|
||||
)
|
||||
self.assertGreater(len(playlist["duration"]), 5)
|
||||
self.assertGreater(len(playlist["tracks"]), 200)
|
||||
self.assertNotIn("suggestions", playlist)
|
||||
|
|
|
|||
|
|
@ -49,6 +49,12 @@ def parse_playlist_items(results, menu_entries: List[List] = None):
|
|||
|
||||
album = parse_song_album(data, 2)
|
||||
|
||||
views = None
|
||||
if album and album["id"] is None:
|
||||
# views currently only present on albums and formatting is localization-dependent -> no parsing
|
||||
if (views := (get_item_text(data, 2))) is not None:
|
||||
album = None
|
||||
|
||||
duration = None
|
||||
if "fixedColumns" in data:
|
||||
if "simpleText" in get_fixed_column_item(data, 0)["text"]:
|
||||
|
|
@ -85,6 +91,7 @@ def parse_playlist_items(results, menu_entries: List[List] = None):
|
|||
"isAvailable": isAvailable,
|
||||
"isExplicit": isExplicit,
|
||||
"videoType": videoType,
|
||||
"views": views,
|
||||
}
|
||||
if duration:
|
||||
song["duration"] = duration
|
||||
|
|
|
|||
Loading…
Reference in a new issue