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

lyrics: tekstowo backend does not check if the found song actually matches #4406

Closed
valpackett opened this issue Jul 8, 2022 · 4 comments · Fixed by #4546
Closed

lyrics: tekstowo backend does not check if the found song actually matches #4406

valpackett opened this issue Jul 8, 2022 · 4 comments · Fixed by #4546
Labels
bug bugs that are confirmed and actionable

Comments

@valpackett
Copy link

Problem

Running this command in verbose (-vv) mode:

$ beet -vv lyrics -p 'kelly bailey'

Led to this problem:

lyrics: failed to fetch: https://www.musixmatch.com/lyrics/Kelly-Bailey/Black-Mesa-Inbound (404)
lyrics: Genius failed to find a matching artist for 'Kelly Bailey'
lyrics: got lyrics from backend: Tekstowo
lyrics: fetched lyrics: Kelly Bailey - Half-Life 2 - Black Mesa Inbound
Sending event: write
Sending event: after_write
Sending event: database_change
Black eyed Susan
Sun shines in your veins
If the clouds are moving
Never hear her complain
Yeah, black eyed Susan
Just waiting on a drop of rain
…

…there are no lyrics. It's an instrumental track.

The backend seems to blindly trust that the first row in search results would be the actual expected song:

beets/beetsplug/lyrics.py

Lines 486 to 494 in 7c67071

song_row = song_rows[0]
if not song_row:
return None
link = song_row.find('a')
if not link:
return None
return self.BASE_URL + link.get('href')

But the site absolutely can return something with vaguely similar names!!!

image

Setup

  • OS: FreeBSD -CURRENT
  • Python version: 3.9.4
  • beets version: current git
  • Turning off plugins made problem go away (yes/no): no
@sampsyo sampsyo added the bug bugs that are confirmed and actionable label Jul 9, 2022
@sampsyo
Copy link
Member

sampsyo commented Jul 9, 2022

Ack, that's pretty bad! We should absolutely confirm that we have a match… these backends aren't really supposed to be "fuzzy" in this way.

@luharder
Copy link
Contributor

luharder commented Nov 2, 2022

I have been looking into this issue and plan on contributing (first time). Would we want to only return lyrics on an exact match of the title and artist between the top search result and the search query? Or would we prefer a type of similarity score (like the similarity ratio used in the code for finding lyrics through Google search) rather than an exact match?

@valpackett
Copy link
Author

Thank you for your interest! Yeah I think it should be a bit fuzzy, using difflib.SequenceMatcher like the Google backend does seems fine.

@sampsyo
Copy link
Member

sampsyo commented Nov 3, 2022

We also have an existing utility, string_dist, for comparing the similarity of two strings:

def string_dist(str1, str2):

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug bugs that are confirmed and actionable
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants