podcasts features ✨ (#559)

This commit is contained in:
sigma67 2024-03-06 23:02:19 +01:00 • committed by GitHub
commit 90d172b1d3
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
46 changed files with 802 additions and 318 deletions

View file

@ -60,6 +60,20 @@ class TestLibrary:
artists = yt_empty.get_library_subscriptions()
assert len(artists) == 0
def test_get_library_podcasts(self, yt_brand, yt_empty):
podcasts = yt_brand.get_library_podcasts(limit=50, order="a_to_z")
assert len(podcasts) > 25
empty = yt_empty.get_library_podcasts()
assert len(empty) == 1 # saved episodes playlist is always there
def test_get_library_channels(self, yt_brand, yt_empty):
channels = yt_brand.get_library_channels(limit=50, order="recently_added")
assert len(channels) > 25
empty = yt_empty.get_library_channels()
assert len(empty) == 0
def test_get_liked_songs(self, yt_brand, yt_empty):
songs = yt_brand.get_liked_songs(200)
assert len(songs["tracks"]) > 100

View file

@ -1,13 +1,26 @@
class TestPodcasts:
def test_get_channel(self, config, yt):
podcast_id = config["podcasts"]["channel_id"]
channel = yt.get_channel(podcast_id)
assert len(channel["episodes"]["results"]) == 10
assert len(channel["podcasts"]["results"]) > 5
def test_get_channel_episodes(self, config, yt_oauth):
channel_id = config["podcasts"]["channel_id"]
channel = yt_oauth.get_channel(channel_id)
channel_episodes = yt_oauth.get_channel_episodes(channel_id, channel["episodes"]["params"])
assert len(channel_episodes) >= 150
assert len(channel_episodes[0]) == 9
def test_get_podcast(self, config, yt, yt_brand):
podcast_id = config["podcasts"]["podcast_id"]
results = yt.get_podcast(podcast_id)
assert len(results["episodes"]) == 100
assert not results["saved"]
podcast = yt.get_podcast(podcast_id)
assert len(podcast["episodes"]) == 100
assert not podcast["saved"]
results = yt_brand.get_podcast(podcast_id, limit=None)
assert len(results["episodes"]) > 100
assert results["saved"]
podcast = yt_brand.get_podcast(podcast_id, limit=None)
assert len(podcast["episodes"]) > 100
assert podcast["saved"]
def test_many_podcasts(self, yt):
results = yt.search("podcast", filter="podcasts")
@ -17,13 +30,13 @@ class TestPodcasts:
def test_get_episode(self, config, yt, yt_brand):
episode_id = config["podcasts"]["episode_id"]
result = yt.get_episode(episode_id)
assert len(result["description"]) >= 20
assert not result["saved"]
assert result["playlistId"] is not None
episode = yt.get_episode(episode_id)
assert len(episode["description"]) >= 20
assert not episode["saved"]
assert episode["playlistId"] is not None
result = yt_brand.get_episode(episode_id)
assert result["saved"]
episode = yt_brand.get_episode(episode_id)
assert episode["saved"]
def test_many_episodes(self, yt):
results = yt.search("episode", filter="episodes")

View file

@ -15,7 +15,7 @@ brand_account = "114511851949139689139"
yt_brand = YTMusic(Path(__file__).parent.joinpath("oauth.json").as_posix(), brand_account)
def populate_account():
def populate_music():
"""idempotent requests to populate an account"""
# library
playlist_id = "RDCLAK5uy_l9ex2d91-Qb1i-W7d0MLCEl_ZjRXss0Dk" # fixed playlist with many artists
@ -53,10 +53,18 @@ def populate_account():
)
print(f"Created playlist {playlistId}, don't forget to set this in test.cfg playlists/own")
# podcasts
def populate_podcasts():
yt_brand.rate_playlist(config["podcasts"]["podcast_id"], rating="LIKE")
yt_brand.add_playlist_items("SE", [config["podcasts"]["episode_id"]])
podcasts = yt_brand.search("podcast", filter="podcasts", limit=40)
for podcast in podcasts:
playlist_id = podcast["browseId"][4:]
yt_brand.rate_playlist(playlist_id, rating="LIKE")
podcast = yt_brand.get_podcast(playlist_id)
yt_brand.subscribe_artists([podcast["author"]["id"]])
if __name__ == "__main__":
populate_account()
populate_music()
populate_podcasts()

View file

@ -31,6 +31,11 @@ private_album_id = sample_id_of_private_album
private_artist_id = sample_id_of_private_artist
private_upload_id = sample_video_id_of_private_upload
[podcasts]
channel_id = UCGwuxdEeCf0TIA2RbPOj-8g
podcast_id = PLxq_lXOUlvQDgCVFj9L79kqJybW0k6OaB
episode_id = KNkyHCLOr1o
[limits]
library_playlists = 100
library_songs = 200