diff --git a/tests/mixins/test_browsing.py b/tests/mixins/test_browsing.py index 9eb939b..cdd98b8 100644 --- a/tests/mixins/test_browsing.py +++ b/tests/mixins/test_browsing.py @@ -6,7 +6,7 @@ class TestBrowsing: def test_get_home(self, yt, yt_auth): result = yt.get_home() - assert len(result) == 2 + assert len(result) >= 2 result = yt_auth.get_home(limit=15) assert len(result) >= 15 diff --git a/tests/mixins/test_explore.py b/tests/mixins/test_explore.py index 54f27fd..8d32ef4 100644 --- a/tests/mixins/test_explore.py +++ b/tests/mixins/test_explore.py @@ -9,9 +9,10 @@ def test_get_mood_playlists(self, yt): def test_get_charts(self, yt, yt_oauth): charts = yt_oauth.get_charts() - # songs section appears to be removed currently (US) - assert len(charts) >= 3 + assert len(charts) == 4 charts = yt.get_charts(country="US") + assert len(charts) == 4 + charts = yt_oauth.get_charts(country="US") assert len(charts) == 5 charts = yt.get_charts(country="BE") - assert len(charts) == 4 + assert len(charts) == 3 diff --git a/tests/mixins/test_playlists.py b/tests/mixins/test_playlists.py index 3ce433f..f4e333f 100644 --- a/tests/mixins/test_playlists.py +++ b/tests/mixins/test_playlists.py @@ -66,7 +66,7 @@ def test_end2end(self, config, yt_brand, sample_video): ) assert response["status"] == "STATUS_SUCCEEDED", "Adding playlist item failed" assert len(response["playlistEditResults"]) > 0, "Adding playlist item failed" - time.sleep(3) + time.sleep(5) yt_brand.edit_playlist(playlist_id, addToTop=False) playlist = yt_brand.get_playlist(playlist_id, related=True) assert len(playlist["tracks"]) == 46, "Getting playlist items failed" diff --git a/tests/setup/setup_account.py b/tests/setup/setup_account.py index a00fb54..c1cd2b8 100644 --- a/tests/setup/setup_account.py +++ b/tests/setup/setup_account.py @@ -17,7 +17,7 @@ def populate_account(): """idempotent requests to populate an account""" - # library + # subscribe to some artists playlist_id = "RDCLAK5uy_l9ex2d91-Qb1i-W7d0MLCEl_ZjRXss0Dk" # fixed playlist with many artists yt_playlist = yt_brand.get_playlist(playlist_id) artists = [track["artists"] for track in yt_playlist["tracks"]] diff --git a/ytmusicapi/mixins/_protocol.py b/ytmusicapi/mixins/_protocol.py index 40fe733..45915d7 100644 --- a/ytmusicapi/mixins/_protocol.py +++ b/ytmusicapi/mixins/_protocol.py @@ -1,5 +1,5 @@ """protocol that defines the functions available to mixins""" -from typing import Dict, Optional, Protocol +from typing import Dict, Optional, Protocol, Union from requests import Response @@ -10,6 +10,8 @@ class MixinProtocol(Protocol): """protocol that defines the functions available to mixins""" + auth: Optional[Union[str, Dict]] + auth_type: AuthType parser: Parser diff --git a/ytmusicapi/mixins/browsing.py b/ytmusicapi/mixins/browsing.py index b7386a3..390802a 100644 --- a/ytmusicapi/mixins/browsing.py +++ b/ytmusicapi/mixins/browsing.py @@ -424,7 +424,9 @@ def get_album_browse_id(self, audioPlaylistId: str) -> Optional[str]: params = {"list": audioPlaylistId} response = self._send_get_request(YTM_DOMAIN + "/playlist", params) - with warnings.catch_warnings(action="ignore", category=DeprecationWarning): + with warnings.catch_warnings(): + # merge this with statement with catch_warnings on Python>=3.11 + warnings.simplefilter(action="ignore", category=DeprecationWarning) decoded = response.text.encode("utf8").decode("unicode_escape") matches = re.search(r"\"MPRE.+?\"", decoded) diff --git a/ytmusicapi/mixins/explore.py b/ytmusicapi/mixins/explore.py index 93b3bb0..62e40c1 100644 --- a/ytmusicapi/mixins/explore.py +++ b/ytmusicapi/mixins/explore.py @@ -220,18 +220,15 @@ def get_charts(self, country: str = "ZZ") -> Dict: charts_categories = ["videos", "artists"] has_genres = country == "US" - has_trending = country != "ZZ" # use result length to determine if songs category is present # could also be done via an is_premium attribute on YTMusic instance - has_songs = (len(results) - 1) > (len(charts_categories) + has_genres + has_trending) + has_songs = (len(results) - 1) > (len(charts_categories) + has_genres) if has_songs: charts_categories.insert(0, "songs") if has_genres: charts_categories.append("genres") - if has_trending: - charts_categories.append("trending") parse_chart = lambda i, parse_func, key: parse_content_list( nav(results[i + has_songs], CAROUSEL_CONTENTS), parse_func, key @@ -250,7 +247,4 @@ def get_charts(self, country: str = "ZZ") -> Dict: if has_genres: charts["genres"] = parse_chart(3, parse_playlist, MTRIR) - if has_trending: - charts["trending"]["items"] = parse_chart(3 + has_genres, parse_chart_trending, MRLIR) - return charts