Пример #1
0
    def test_bad_artists_filtered(self, web_artist_mock, web_track_mock):
        refs = list(
            translator.web_to_artist_refs([{}, web_artist_mock, web_track_mock])
        )

        assert len(refs) == 1

        assert refs[0].type == "artist"
        assert refs[0].uri == "spotify:artist:abba"
        assert refs[0].name == "ABBA"
Пример #2
0
def _browse_toplist_user(web_client, variant):
    if not web_client.logged_in:
        return []

    if variant in ("tracks", "artists"):
        items = web_client.get_one(f"me/top/{variant}").get("items", [])
        if variant == "tracks":
            return list(
                translator.web_to_track_refs(items, check_playable=False))
        else:
            return list(translator.web_to_artist_refs(items))
    else:
        return []
Пример #3
0
def _browse_toplist_user(web_client, variant):
    if not web_client.logged_in:
        return []

    if variant in ("tracks", "artists"):
        items = flatten([
            page.get("items", []) for page in web_client.get_all(
                f"me/top/{variant}",
                params={"limit": 50},
            ) if page
        ])
        if variant == "tracks":
            return list(
                translator.web_to_track_refs(items, check_playable=False))
        else:
            return list(translator.web_to_artist_refs(items))
    else:
        return []