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

Remove '&' from last.fm track name #249

Merged
merged 2 commits into from
Feb 8, 2019
Merged

Remove '&' from last.fm track name #249

merged 2 commits into from
Feb 8, 2019

Conversation

Hanouta
Copy link
Contributor

@Hanouta Hanouta commented Feb 8, 2019

Currently last.fm returns wrong results if the track name contains a '&'-symbol, because it tries to get results from an url like this:

http://ws.audioscrobbler.com/2.0/?method=track.search&track=Artist1%20&%20Artist2%20Trackname&limit=[...]
so basically everything after Artist1%20 gets cut off, which leads to wrong results in many cases. This issue happened only after searching for a youtube url.

Example:
Enter this link in the search bar: https://www.youtube.com/watch?v=hj4g-hHw9CI (track name is Deadly Guns & E-Force - Invincible)
The song result is Deadly Guns - Deadly Venoms (Official Snakepit 2017 Anthem) because it searches only for Deadly Guns.

@@ -12,7 +12,7 @@ function makeLastfmRequest (parameters) {
}

function searchTracks (terms, limit = 30) {
let parameters = 'track.search&track=' + encodeURI(terms);
let parameters = 'track.search&track=' + encodeURI(terms).replace('&', '');
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with the issue, but would rather use encodeURIComponent(terms) in order to deal with other characters such as "#", "/" ,"." or ":"

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, that´s a better solution... I´ve updated the file

@nukeop nukeop merged commit a4802d4 into nukeop:master Feb 8, 2019
@nukeop
Copy link
Owner

nukeop commented Feb 8, 2019

Thanks for spotting this.

nukeop added a commit that referenced this pull request Sep 30, 2019
Remove '&' from last.fm track name
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

Successfully merging this pull request may close these issues.

3 participants