Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Import Last.fm favorites gives "Error: Invalid number of favorites [2664]" #881

Closed
harleypig opened this issue Mar 18, 2021 · 9 comments · Fixed by #1251
Closed

Import Last.fm favorites gives "Error: Invalid number of favorites [2664]" #881

harleypig opened this issue Mar 18, 2021 · 9 comments · Fixed by #1251
Assignees
Labels
bug This issue identifies a bug in Nuclear. good first issue This issue is a low hanging fruit perfect for new contributors and shouldn't take too much time.

Comments

@harleypig
Copy link

Just what the title says ... I logged in to last.fm with no apparent issues. Nuclear appears to be scrobbling correctly.

Clicking the Import button for Last.fm Favorites gives: "Error: Invalid number of favorites [2664]"

@harleypig harleypig added the bug This issue identifies a bug in Nuclear. label Mar 18, 2021
@nukeop
Copy link
Owner

nukeop commented Mar 18, 2021

Thanks for reporting, we'll look into it.

@nukeop
Copy link
Owner

nukeop commented Mar 19, 2021

Do you have the same nickname on last.fm as here? Maybe it's because of a large number of favorites and the API can't handle it?

@nukeop
Copy link
Owner

nukeop commented Mar 19, 2021

https://www.last.fm/api/show/user.getLovedTracks

According to the docs the "limit" param controls how many tracks we download. As it doesn't indicate the maximum limit, we try to download all the tracks at once. Apparently 2664 is too many.

@nukeop
Copy link
Owner

nukeop commented Mar 19, 2021

Looks like the max is 1000

@nukeop nukeop added the good first issue This issue is a low hanging fruit perfect for new contributors and shouldn't take too much time. label Mar 19, 2021
@json-lou
Copy link

Hi, I would be interested in working on this as my first issue if still available! :)

@nukeop
Copy link
Owner

nukeop commented Mar 19, 2021

Sure, I just identified the problem yesterday. Let me give you some more info for context:

getNumberOfLovedTracks(user: string, limit = 1): Promise<Response> {

This is where we download the favorites. Currently, this function returns a promise with the response, but now we need to check if the limit is greater than 1000, and paginate our requests as necessary to download the entire collection of favorite tracks.

Please remember to cover this functionality with tests as well.

@nukeop
Copy link
Owner

nukeop commented Mar 19, 2021

Ok looks like this limit was actually mentioned, and it's partially implemented in the related action:

export function fetchAllFmFavorites() {

It partially implements pagination for n>1000.

@json-lou
Copy link

json-lou commented Mar 24, 2021

@nukeop I have finished implementing this feature, I am just finishing up the tests now. What do you think would be the best way to test this feature?

Since this API call requires a userId, should I just use my own Last.fm account for the tests? For ex, I have 1000+ songs liked on my account so I could just test making multiple calls (with different pages passed in) to this endpoint and verify the responses are valid. I could add this to lastfm.test.ts. Would this be sufficient?

Let me know if you have any suggestions, thanks!

@KiritoStorm
Copy link

Is it possible to fix this soon? When I see this right, it just needs to be tested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug This issue identifies a bug in Nuclear. good first issue This issue is a low hanging fruit perfect for new contributors and shouldn't take too much time.
Projects
None yet
4 participants