lrc_kit icon indicating copy to clipboard operation
lrc_kit copied to clipboard

Exceptions during search not handled

Open SimonIT opened this issue 4 years ago • 13 comments

AttributeError: 'NoneType' object has no attribute 'group'
  File "services.py", line 42, in wrapper
    return func(*args, **kwargs)
  File "services.py", line 89, in _lrckit
    result = engine.search(search)
  File "lrc_kit\providers.py", line 92, in search
    res = provider(**self.kwargs).search(search_request)
  File "lrc_kit\providers.py", line 45, in search
    raise e
  File "lrc_kit\providers.py", line 34, in search
    lrc = self.fetch(val)
  File "lrc_kit\providers.py", line 406, in fetch
    match = re.search(lyric_regex, lyrics_page).group(1)
TypeError: 'NoneType' object is not subscriptable
  File "services.py", line 42, in wrapper
    return func(*args, **kwargs)
  File "services.py", line 89, in _lrckit
    result = engine.search(search)
  File "lrc_kit\providers.py", line 92, in search
    res = provider(**self.kwargs).search(search_request)
  File "lrc_kit\providers.py", line 45, in search
    raise e
  File "lrc_kit\providers.py", line 34, in search
    lrc = self.fetch(val)
  File "lrc_kit\providers.py", line 512, in fetch
    lyric_text = lyrics[1].replace('<br />','')

SimonIT avatar Mar 15 '21 19:03 SimonIT

Can you provide the code used to generate this error.

reteps avatar Mar 15 '21 19:03 reteps

    my_ses = requests.Session()
    my_ses.proxies.update(Config.PROXY)
    engine = ComboLyricsProvider(session=my_ses)
    search = SearchRequest(song.artist, song.name)
    result = engine.search(search)

SimonIT avatar Mar 15 '21 20:03 SimonIT

What is Config.PROXY's value

reteps avatar Mar 15 '21 20:03 reteps

It's an empty dictionary

SimonIT avatar Mar 15 '21 20:03 SimonIT

Ok, and finally what is the song you are using? I need this because I suspect the engine is having trouble with that specific song or case.

reteps avatar Mar 15 '21 20:03 reteps

https://www.syair.info/lyrics/modjo/lady/Ykx5VQ https://www.megalobiz.com/lrc/maker/Beyonc%C3%A9+-+Single+Ladies+%28Put+a+Ring+on+It%29.54733707 These are the lyrics where the exceptions happen

SimonIT avatar Mar 15 '21 20:03 SimonIT

I see.

https://www.syair.info/lyrics/modjo/lady/Ykx5VQ does not have valid LRC text.

See the LRC regex we match against:

line_regex = re.compile(r'\[(?:(\d+):)?(\d+)(?:\.(\d+))?\]([^\[]+)')

Normally we get matches like this: image

And what the lady modjo file looks like:

image

reteps avatar Mar 15 '21 20:03 reteps

What do you think the library should do when it sees a Lyrics File like this and cannot parse it?

reteps avatar Mar 15 '21 20:03 reteps

I think I could change the return cases of the providers from:

return Lyrics(full_text)

to

try:
   return Lyrics(full_text)
except InvalidLyricsException:
   return None

reteps avatar Mar 15 '21 20:03 reteps

I will be able to implement that later this week.

reteps avatar Mar 15 '21 20:03 reteps

I think that's valid. I had this already multiple times.

I handle this in https://github.com/doakey3/pylrc correct If you look here https://de.wikipedia.org/wiki/LRC_(Dateiformat)#Aufbau, it's also an example how to shorten lyrics with duplicate lines

SimonIT avatar Mar 15 '21 20:03 SimonIT

Ok I can change the parsing later this week. Basically the tag processing and text processing will be split up then we have to sort the lyrics based on the time.

reteps avatar Mar 15 '21 20:03 reteps

I no longer have time to fix this issue, but open to PRs! :)

reteps avatar Sep 18 '22 23:09 reteps