Skip to content

Inconsistent findLyrics calls #22

@tgambet

Description

@tgambet

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...).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions