robert-alfaro / genius-lyrics

Home Assistant custom component for fetching song lyrics from Genius.com
23 stars 7 forks source link

Still working? #25

Closed kuenkin closed 8 months ago

kuenkin commented 1 year ago

Hello, Thanks for this component it is awesome. The problem I have, since 2022.7 HA, it's that I don't get any lyrics. I tried to reinstall the custom component but, the same problem... This is the error I get in HA log:

Logger: homeassistant.helpers.entity Source: custom_components/genius_lyrics/sensor.py:211 Integration: Genius Lyrics (documentation) First occurred: 11:36:16 (7 occurrences) Last logged: 11:57:56

Update for sensor.volumio_lyrics fails Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 515, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 710, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/genius_lyrics/sensor.py", line 119, in update self._genius.fetch_lyrics() File "/config/custom_components/genius_lyrics/sensor.py", line 211, in fetch_lyrics song = self.genius.search_song(self.title, self.artist, get_full_info=False) File "/usr/local/lib/python3.10/site-packages/lyricsgenius/genius.py", line 436, in search_song lyrics = self.lyrics(song_url=song_info['url']) File "/usr/local/lib/python3.10/site-packages/lyricsgenius/genius.py", line 131, in lyrics html = BeautifulSoup( File "/usr/local/lib/python3.10/site-packages/bs4/init.py", line 228, in init self._feed() File "/usr/local/lib/python3.10/site-packages/bs4/init.py", line 289, in _feed self.builder.feed(self.markup) File "/usr/local/lib/python3.10/site-packages/bs4/builder/_htmlparser.py", line 215, in feed parser.feed(markup) File "/usr/local/lib/python3.10/html/parser.py", line 110, in feed self.goahead(0) File "/usr/local/lib/python3.10/html/parser.py", line 178, in goahead k = self.parse_html_declaration(i) File "/usr/local/lib/python3.10/html/parser.py", line 269, in parse_html_declaration self.handle_decl(rawdata[i+2:gtpos]) File "/usr/local/lib/python3.10/site-packages/bs4/builder/_htmlparser.py", line 160, in handle_decl self.soup.endData(Doctype) File "/usr/local/lib/python3.10/site-packages/bs4/init.py", line 365, in endData self.object_was_parsed(o) File "/usr/local/lib/python3.10/site-packages/bs4/init.py", line 370, in object_was_parsed previous_element = most_recent_element or self._most_recent_element File "/usr/local/lib/python3.10/site-packages/bs4/element.py", line 1054, in getattr__ return self.find(tag) File "/usr/local/lib/python3.10/site-packages/bs4/element.py", line 1292, in find l = self.find_all(name, attrs, recursive, text, 1, kwargs) File "/usr/local/lib/python3.10/site-packages/bs4/element.py", line 1313, in find_all return self._find_all(name, attrs, text, limit, generator, kwargs) File "/usr/local/lib/python3.10/site-packages/bs4/element.py", line 528, in _find_all strainer = SoupStrainer(name, attrs, text, kwargs) File "/usr/local/lib/python3.10/site-packages/bs4/element.py", line 1610, in init self.text = self._normalize_search_value(text) File "/usr/local/lib/python3.10/site-packages/bs4/element.py", line 1615, in _normalize_search_value if (isinstance(value, str) or isinstance(value, collections.Callable) or hasattr(value, 'match') AttributeError: module 'collections' has no attribute 'Callable'

Any help?

kuenkin commented 1 year ago

To add more background:

What am I doing wrong? Some other custom_component I could have installed maybe is the problem?

coolinx commented 1 year ago

Not sure since when, but I get this error and I'm not sure what is causing this:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse response.begin() File "/usr/local/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.10/http/client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 489, in send resp = conn.urlopen( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 787, in urlopen retries = retries.increment( File "/usr/local/lib/python3.10/site-packages/urllib3/util/retry.py", line 550, in increment raise six.reraise(type(error), error, _stacktrace) File "/usr/local/lib/python3.10/site-packages/urllib3/packages/six.py", line 769, in reraise raise value.with_traceback(tb) File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 703, in urlopen httplib_response = self._make_request( File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 449, in _make_request six.raise_from(e, None) File "", line 3, in raise_from File "/usr/local/lib/python3.10/site-packages/urllib3/connectionpool.py", line 444, in _make_request httplib_response = conn.getresponse() File "/usr/local/lib/python3.10/http/client.py", line 1374, in getresponse response.begin() File "/usr/local/lib/python3.10/http/client.py", line 318, in begin version, status, reason = self._read_status() File "/usr/local/lib/python3.10/http/client.py", line 287, in _read_status raise RemoteDisconnected("Remote end closed connection without" urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 541, in async_update_ha_state await self.async_device_update() File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 739, in async_device_update raise exc File "/usr/local/lib/python3.10/concurrent/futures/thread.py", line 58, in run result = self.fn(*self.args, self.kwargs) File "/config/custom_components/genius_lyrics/sensor.py", line 120, in update self._genius.fetch_lyrics() File "/config/custom_components/genius_lyrics/sensor.py", line 212, in fetch_lyrics song = self.__genius.search_song(self.title, self.artist, get_full_info=False) File "/usr/local/lib/python3.10/site-packages/lyricsgenius/genius.py", line 401, in search_song search_response = self.search_all(search_term) File "/usr/local/lib/python3.10/site-packages/lyricsgenius/api/public_methods/search.py", line 210, in search_all return self.search(search_term, per_page, page, endpoint) File "/usr/local/lib/python3.10/site-packages/lyricsgenius/api/public_methods/search.py", line 45, in search return self._makerequest(path, params=params, public_api=True) File "/usr/local/lib/python3.10/site-packages/lyricsgenius/api/base.py", line 75, in _make_request response = self._session.request(method, uri, File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 587, in request resp = self.send(prep, send_kwargs) File "/usr/local/lib/python3.10/site-packages/requests/sessions.py", line 701, in send r = adapter.send(request, **kwargs) File "/usr/local/lib/python3.10/site-packages/requests/adapters.py", line 547, in send raise ConnectionError(err, request=request) requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

jeepotvin commented 9 months ago

First, this integration idea is really great. My son and daughter loves this on the wall mounted tablet.

The problem is my integration sometimes work and often gets stuck. Here's the error log:

Logger: homeassistant.helpers.entity
Source: helpers/entity.py:698
First occurred: 3:16:59 PM (1 occurrences)
Last logged: 3:16:59 PM

Update for sensor.living_room_lyrics fails
Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 467, in _make_request
    six.raise_from(e, None)
  File "<string>", line 3, in raise_from
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 462, in _make_request
    httplib_response = conn.getresponse()
                       ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 1378, in getresponse
    response.begin()
  File "/usr/local/lib/python3.11/http/client.py", line 318, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/http/client.py", line 279, in _read_status
    line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/socket.py", line 706, in readinto
    return self._sock.recv_into(b)
           ^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ssl.py", line 1311, in recv_into
    return self.read(nbytes, buffer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/ssl.py", line 1167, in read
    return self._sslobj.read(len, buffer)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TimeoutError: The read operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 486, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 799, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/util/retry.py", line 550, in increment
    raise six.reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/packages/six.py", line 770, in reraise
    raise value
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 715, in urlopen
    httplib_response = self._make_request(
                       ^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 469, in _make_request
    self._raise_timeout(err=e, url=url, timeout_value=read_timeout)
  File "/usr/local/lib/python3.11/site-packages/urllib3/connectionpool.py", line 358, in _raise_timeout
    raise ReadTimeoutError(
urllib3.exceptions.ReadTimeoutError: HTTPSConnectionPool(host='genius.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/local/lib/python3.11/site-packages/lyricsgenius/api/base.py", line 75, in _make_request
    response = self._session.request(method, uri,
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/requests/adapters.py", line 532, in send
    raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='genius.com', port=443): Read timed out. (read timeout=5)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 698, in async_update_ha_state
    await self.async_device_update()
  File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 961, in async_device_update
    await hass.async_add_executor_job(self.update)
  File "/usr/local/lib/python3.11/concurrent/futures/thread.py", line 58, in run
    result = self.fn(*self.args, **self.kwargs)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/config/custom_components/genius_lyrics/sensor.py", line 120, in update
    self._genius.fetch_lyrics()
  File "/config/custom_components/genius_lyrics/sensor.py", line 212, in fetch_lyrics
    song = self.__genius.search_song(self.__title, self.__artist, get_full_info=False)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/lyricsgenius/genius.py", line 436, in search_song
    lyrics = self.lyrics(song_url=song_info['url'])
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/lyricsgenius/genius.py", line 132, in lyrics
    self._make_request(path, web=True).replace('<br/>', '\n'),
    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/local/lib/python3.11/site-packages/lyricsgenius/api/base.py", line 84, in _make_request
    raise Timeout(error)
requests.exceptions.Timeout: Request timed out:
HTTPSConnectionPool(host='genius.com', port=443): Read timed out. (read timeout=5)

Would gladly test a new version if updated. Thanks!

robert-alfaro commented 8 months ago

Would love to see this get re-tested with new changes in refactored branch.

robert-alfaro commented 8 months ago

read timeout issue is a requests timeout exception. Now being handled by using retries and catching the exception.