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

Failing to fetch lyrics #40

Closed
robert-alfaro opened this issue Dec 16, 2024 · 7 comments
Closed

Failing to fetch lyrics #40

robert-alfaro opened this issue Dec 16, 2024 · 7 comments

Comments

@robert-alfaro
Copy link
Owner

Some folks are reporting lyrics searching simply not working. States are unknown and None.

For me, I'm not getting errors like:

Traceback (most recent call last):
  File "/workspaces/home-assistant/homeassistant/helpers/entity.py", line 939, in async_update_ha_state
    await self.async_device_update()
  File "/workspaces/home-assistant/homeassistant/helpers/entity.py", line 1259, 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 "/workspaces/home-assistant/config/custom_components/genius_lyrics/sensor.py", line 190, in update
    self._fetch_lyrics()
  File "/workspaces/home-assistant/config/custom_components/genius_lyrics/sensor.py", line 136, in _fetch_lyrics
    song = self._genius.search_song(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/genius.py", line 402, in search_song
    search_response = self.search_all(search_term)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/api/public_methods/search.py", line 210, in search_all
    return self.search(search_term, per_page, page, endpoint)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/api/public_methods/search.py", line 45, in search
    return self._make_request(path, params_=params, public_api=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/api/base.py", line 88, in _make_request
    raise HTTPError(response.status_code, error) from e
requests.exceptions.HTTPError: [Errno 403] 403 Client Error: Forbidden for url: https://genius.com/api/search/multi?q=Count+me+in+Rebelution

However, on any machine behind the same public IP (including machine with HA), hitting the URL directly is successful:

https://genius.com/api/search/multi?q=Count+me+in+Rebelution

{
  "meta": {
    "status": 200
  },
  "response": {
    "sections": [
      {
        "type": "top_hit",
        "hits": [
          {
            "highlights": [],
            "index": "song",
            "type": "song",
            "result": {
              "_type": "song",
              "annotation_count": 1,
              "api_path": "/songs/1154601",
              "artist_names": "Rebelution",
              "full_title": "Count Me In by Rebelution",
              "header_image_thumbnail_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "header_image_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "id": 1154601,
              "instrumental": false,
              "lyrics_owner_id": 1549345,
              "lyrics_state": "complete",
              "lyrics_updated_at": 1466101826,
              "path": "/Rebelution-count-me-in-lyrics",
              "primary_artist_names": "Rebelution",
              "pyongs_count": null,
              "relationships_index_url": "https://genius.com/Rebelution-count-me-in-sample",
              "release_date_components": {
                "year": 2014,
                "month": 6,
                "day": 17
              },
              "release_date_for_display": "June 17, 2014",
              "release_date_with_abbreviated_month_for_display": "Jun. 17, 2014",
              "song_art_image_thumbnail_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "song_art_image_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "stats": {
                "unreviewed_annotations": 0,
                "hot": false,
                "pageviews": 14062
              },
              "title": "Count Me In",
              "title_with_featured": "Count Me In",
              "updated_by_human_at": 1481909429,
              "url": "https://genius.com/Rebelution-count-me-in-lyrics",
              "featured_artists": [],
              "primary_artist": {
...

Related upstream issue: johnwmillr/LyricsGenius#220

@antoinevandenhurk
Copy link

Some folks are reporting lyrics searching simply not working. States are unknown and None.

For me, I'm not getting errors like:

Traceback (most recent call last):
  File "/workspaces/home-assistant/homeassistant/helpers/entity.py", line 939, in async_update_ha_state
    await self.async_device_update()
  File "/workspaces/home-assistant/homeassistant/helpers/entity.py", line 1259, 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 "/workspaces/home-assistant/config/custom_components/genius_lyrics/sensor.py", line 190, in update
    self._fetch_lyrics()
  File "/workspaces/home-assistant/config/custom_components/genius_lyrics/sensor.py", line 136, in _fetch_lyrics
    song = self._genius.search_song(
           ^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/genius.py", line 402, in search_song
    search_response = self.search_all(search_term)
                      ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/api/public_methods/search.py", line 210, in search_all
    return self.search(search_term, per_page, page, endpoint)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/api/public_methods/search.py", line 45, in search
    return self._make_request(path, params_=params, public_api=True)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/vscode/.local/lib/python3.11/site-packages/lyricsgenius/api/base.py", line 88, in _make_request
    raise HTTPError(response.status_code, error) from e
requests.exceptions.HTTPError: [Errno 403] 403 Client Error: Forbidden for url: https://genius.com/api/search/multi?q=Count+me+in+Rebelution

However, on any machine behind the same public IP (including machine with HA), hitting the URL directly is successful:

https://genius.com/api/search/multi?q=Count+me+in+Rebelution

{
  "meta": {
    "status": 200
  },
  "response": {
    "sections": [
      {
        "type": "top_hit",
        "hits": [
          {
            "highlights": [],
            "index": "song",
            "type": "song",
            "result": {
              "_type": "song",
              "annotation_count": 1,
              "api_path": "/songs/1154601",
              "artist_names": "Rebelution",
              "full_title": "Count Me In by Rebelution",
              "header_image_thumbnail_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "header_image_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "id": 1154601,
              "instrumental": false,
              "lyrics_owner_id": 1549345,
              "lyrics_state": "complete",
              "lyrics_updated_at": 1466101826,
              "path": "/Rebelution-count-me-in-lyrics",
              "primary_artist_names": "Rebelution",
              "pyongs_count": null,
              "relationships_index_url": "https://genius.com/Rebelution-count-me-in-sample",
              "release_date_components": {
                "year": 2014,
                "month": 6,
                "day": 17
              },
              "release_date_for_display": "June 17, 2014",
              "release_date_with_abbreviated_month_for_display": "Jun. 17, 2014",
              "song_art_image_thumbnail_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "song_art_image_url": "https://images.genius.com/d44bf17cd853d5fd785307d2ac200ec6.300x300x1.jpg",
              "stats": {
                "unreviewed_annotations": 0,
                "hot": false,
                "pageviews": 14062
              },
              "title": "Count Me In",
              "title_with_featured": "Count Me In",
              "updated_by_human_at": 1481909429,
              "url": "https://genius.com/Rebelution-count-me-in-lyrics",
              "featured_artists": [],
              "primary_artist": {
...

Related upstream issue: johnwmillr/LyricsGenius#220

I'm receiving this errors:
Logger: homeassistant.helpers.entity
Bron: helpers/entity.py:960
Eerst voorgekomen: 16 december 2024 om 17:17:08 (32 gebeurtenissen)
Laatst gelogd: 06:52:38

Update for sensor.genius_lyrics_mass_dell_lyrics fails
Update for sensor.genius_lyrics_pioneer_vsx_933_f37ad4_airplay_lyrics fails
Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/lyricsgenius/api/base.py", line 80, in _make_request
response.raise_for_status()
~~~~~~~~~~~~~~~~~~~~~~~~~^^
File "/usr/local/lib/python3.13/site-packages/requests/models.py", line 1024, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 403 Client Error: Forbidden for url: https://genius.com/api/search/multi?q=I+HAD+SOME+HELP+POST+MALONE+FT.+MORGAN+WALLEN

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/local/lib/python3.13/site-packages/requests/models.py", line 974, in json
return complexjson.loads(self.text, **kwargs)
~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/simplejson/init.py", line 514, in loads
return _default_decoder.decode(s)
~~~~~~~~~~~~~~~~~~~~~~~^^^
File "/usr/local/lib/python3.13/site-packages/simplejson/decoder.py", line 386, in decode
obj, end = self.raw_decode(s)
~~~~~~~~~~~~~~~^^^
File "/usr/local/lib/python3.13/site-packages/simplejson/decoder.py", line 416, in raw_decode
return self.scan_once(s, idx=_w(s, idx).end())
~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^
simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 960, in async_update_ha_state
await self.async_device_update()
File "/usr/src/homeassistant/homeassistant/helpers/entity.py", line 1320, in async_device_update
await hass.async_add_executor_job(self.update)
File "/usr/local/lib/python3.13/concurrent/futures/thread.py", line 58, in run
result = self.fn(*self.args, **self.kwargs)
File "/config/custom_components/genius_lyrics/sensor.py", line 190, in update
self._fetch_lyrics()
~~~~~~~~~~~~~~~~~~^^
File "/config/custom_components/genius_lyrics/sensor.py", line 136, in _fetch_lyrics
song = self._genius.search_song(
self._media_title, self._media_artist, get_full_info=False
)
File "/usr/local/lib/python3.13/site-packages/lyricsgenius/genius.py", line 401, in search_song
search_response = self.search_all(search_term)
File "/usr/local/lib/python3.13/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.13/site-packages/lyricsgenius/api/public_methods/search.py", line 45, in search
return self.make_request(path, params=params, public_api=True)
~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/usr/local/lib/python3.13/site-packages/lyricsgenius/api/base.py", line 86, in _make_request
error = get_description(e)
File "/usr/local/lib/python3.13/site-packages/lyricsgenius/api/base.py", line 108, in get_description
res = e.response.json()
File "/usr/local/lib/python3.13/site-packages/requests/models.py", line 978, in json
raise RequestsJSONDecodeError(e.msg, e.doc, e.pos)
requests.exceptions.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Deze fout is ontstaan door een aangepaste integratie.

Logger: custom_components.genius_lyrics.sensor
Bron: custom_components/genius_lyrics/sensor.py:120
integratie: Genius Lyrics (documentatie)
Eerst voorgekomen: 16 december 2024 om 10:16:59 (227 gebeurtenissen)
Laatst gelogd: 06:52:40

Cannot fetch lyrics without artist and title

@cellard0or
Copy link

I think this might have been fixed by johnwmillr/LyricsGenius@7635cff. Could you bump the version so we can try?
On a different note, what would I need to do to test this in my own HA instance? Would it suffice to adapt the requirements in the manifest?

@robert-alfaro
Copy link
Owner Author

robert-alfaro commented Dec 23, 2024

just tested johnwmillr/LyricsGenius@7635cff, all good. New version releasing soon!

ref johnwmillr/LyricsGenius#288

@antoinevandenhurk
Copy link

That's good news, can't wait for the new release

@cellard0or
Copy link

Release is out and now it is working, nice job!

@Sidsapphire
Copy link

can you share the config i never got it working with instructions given here

@robert-alfaro
Copy link
Owner Author

Hi @Sidsapphire, can you elaborate on which config? If you're looking to setup this integration, you install via hacs, then add integration using the UI in home assistant. No configuration.yaml.

Are you referring to a lovelace markdown card?

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

No branches or pull requests

4 participants