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

Inconsistent findLyrics calls #22

Open
tgambet opened this issue Dec 15, 2018 · 0 comments
Open

Inconsistent findLyrics calls #22

tgambet opened this issue Dec 15, 2018 · 0 comments

Comments

@tgambet
Copy link

tgambet commented Dec 15, 2018

When calling findLyrics several times in a row, results may differ since it gives the lyrics found in the fastest responding website as per this code :

alltomp3/index.js

Lines 192 to 201 in 7129f17

promises.push(reqWikia);
promises.push(reqParolesNet);
promises.push(reqLyricsMania1);
promises.push(reqLyricsMania2);
promises.push(reqLyricsMania3);
promises.push(reqSweetLyrics);
return Promise.any(promises).then((lyrics) => {
return lyrics;
});

This might be the best for speed, but not for consistency as one will get different lyrics on different calls.
The code above could be replaced with something like:

return reqWikia
    .catch(() => reqParolesNet)
    .catch(() => reqLyricsMania1)
    .catch(() => reqLyricsMania2)
    .catch(() => reqLyricsMania3)
    .catch(() => reqSweetLyrics)

Requests would still be made in parallel but that would give a preference order to the websites that are requested (in this example first reqWikia, then reqParolesNet, etc...).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant