mopidy / mopidy-spotify

Mopidy extension for playing music from Spotify
https://mopidy.com/ext/spotify/
Apache License 2.0
933 stars 109 forks source link

"Your Music" limited to 20 results #256

Closed alfrdmalr closed 4 years ago

alfrdmalr commented 4 years ago

When browsing "Your Music" categories ("Your Tracks", "Your Albums") only 20 results are being returned. Initially, I thought that I just needed to set the set_[category]_count value in the config file, but changing this value has no impact on the results being returned (it does seem to work fine for 'normal' searches, but doesn't change the number of results for "Your [Category]").

Since 20 is the default limit for the relevant requests in Spotify's Web API (here), I'm wondering if the limit param is even being used.

Anyway, is this intended? I know most people just make playlists but I use my saved albums pretty heavily and it was a bit jarring to find that they don't all get loaded.

kingosticks commented 4 years ago

Correct, there's no pagination support yet for Your Music or any of the other browse features added in the 4.0 release. It's not intentional, I just ran out of steam. So if you fancy improving the support we'd love to have a PR.

kingosticks commented 4 years ago

The trick @adamcik used for the Dirble backend as described at https://github.com/mopidy/mopidy/pull/1879#issuecomment-583719247 might be worth replicating (note that most of that issue is talking about Core support for paginated search results, which is not the same thing).

M4cs commented 4 years ago

I was able to get this up to 50 maximum due to lack of pagination by hardcoding the limit in mopidy-spotify/browse.py on the lookup for Your Tracks

image

In the function _browse_your_music you can pass these params:

def _browse_your_music(web_client, variant):
    if not web_client.logged_in:
        return []

    if variant in ("tracks", "albums"):
        items = web_client.get_one(
            f"me/{variant}", params={"market": "from_token"},
        ).get("items", [])
        if variant == "tracks":
            return list(translator.web_to_track_refs(items))
        else:
            return list(translator.web_to_album_refs(items))
    else:
        return []

Not a full fledged fix but its better than 20! I'm not sure if there is a config value for this, it doesn't look like it

Jaxan commented 4 years ago

Thanks @M4cs for the hot fix. In case anyone is wondering, this changes the limit to 50.

         params={"market": "from_token", "limit": 50}
swooc commented 4 years ago

i'm also a heavy album user. my ghetto solution to this is to save all my albums into 1 playlist. unfortunately it takes a long time to scroll through it all.

sorry i have no idea about coding, so this is my best solution lol.