dbeley / rymscraper

Python library to extract data from rateyourmusic.com.
MIT License
163 stars 25 forks source link

difflib.get_close_matches is case sensitive and can cause lack of matches #24

Closed shatteringlass closed 3 years ago

shatteringlass commented 3 years ago

Here's an example of what could happen when querying for albums whose titles are sometimes stylised:

>>> ai = n.get_album_infos(name='Tyler the creator - IGOR')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/federico/rymscraper/rymscraper/__init__.py", line 28, in get_album_infos
    url = utils.get_url_from_album_name(self.browser, name)
  File "/Users/federico/rymscraper/rymscraper/utils.py", line 41, in get_url_from_album_name
    difflib.get_close_matches(album_name, artist_album_name)[0]
IndexError: list index out of range

This is caused by the implicit case-sensitivity of the difflib.get_close_matches method. I will submit a PR with a patch that can work around this limitation.

dbeley commented 3 years ago

Thanks a lot for chasing down that bug, I merged your pull request!