getURLContentAsync hides the HTTP status: Genius lyrics source fails with [null,null] (HTTP 403)

To discuss development of addons / skins / customization of MediaMonkey v5 / v2024

Moderators: jiri, drakinite, Addon Administrators

santa808
Posts: 3
Joined: Thu May 25, 2023 7:24 am

getURLContentAsync hides the HTTP status: Genius lyrics source fails with [null,null] (HTTP 403)

Post by santa808 »

Hi,

I maintain the Genius Lyrics Source addon (https://www.mediamonkey.com/addons/brow ... ce-genius/, currently v1.0.4). It adds Genius .com as a lyrics source through Scripts/<addon>/helpers/lyricsSearch_add.js, the same way as the built-in lyricsSources addon.

Environment: MediaMonkey 2024.2.2.3222, Windows 11 (10.0.26200)

Problem:
Every lookup now ends in "Lyrics not found", for every song. The URLs are correct, for example genius .com/marilyn-manson-little-horn-lyrics and genius .com/metallica-welcome-home-sanitarium-lyrics, and both open normally in a browser.

In helpers/lyricsSearch.js, NotifyWebReq() loads the page with app.utils. web.getURLContentAsync(). The request fails, and the source's onFailure(err) receives only [null,null], with no HTTP status and no reason.

To find out why, I repeated the same request (same User-Agent header as NotifyWebReq) with app.utils. web.requestAsync(), whose doneCallback does report the status:

Code: Select all

re-request: genius .com/marilyn-manson-little-horn-lyrics
re-request status: 403
re-request response start: <!DOCTYPE html> <html lang="en"> <head> ... <title>Genius</title> ...
So Genius answers MediaMonkey's request with HTTP 403 and a block page, while getURLContentAsync passes nothing about it on to the lyrics source.

Possible cause: NotifyWebReq() sends a fixed User-Agent from 2021:

Code: Select all

Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36
Sites with bot protection often reject outdated browser identifiers like this, so it may be why Genius returns 403. I haven't been able to confirm that, because the status isn't exposed to the source.

Requests:
  1. Could the rejection from getURLContentAsync include the HTTP status code and reason, and could LoadWebPageFailed pass that on to onFailure(err)? Then lyrics sources and other addons could log or handle failures meaningfully. (Related to the non-200 handling in #16757.)
  2. Could you check whether the hard-coded User-Agent in NotifyWebReq() is still appropriate?
  3. Is there a recommended way for a lyrics source to report "blocked by the site" (HTTP 403) differently from "lyrics not found", so users get a clearer message?
Thanks!
MiPi
Posts: 951
Joined: Tue Aug 18, 2009 2:56 pm
Location: Czech Republic
Contact:

Re: getURLContentAsync hides the HTTP status: Genius lyrics source fails with [null,null] (HTTP 403)

Post by MiPi »

Hello,
to read errors in onFailure(err) use err.responseCode and err.response.
User-agent is really hardcoded now and cannot be passed from lyrics script. I will look at it soon, so this could be done in upcoming 2027 release.
Genius site does not like using their content from 3rd parties, that is why we decided to not include it in our sources. So it is possible, that they tightened their policy.

Michal
MiPi
Posts: 951
Joined: Tue Aug 18, 2009 2:56 pm
Location: Czech Republic
Contact:

Re: getURLContentAsync hides the HTTP status: Genius lyrics source fails with [null,null] (HTTP 403)

Post by MiPi »

Implemented, next 2027 build will include also support for passing user-agent from lyric search scripts (LyricsSource can contain attribute headers with StringList of headers to add, including user-agent).
santa808
Posts: 3
Joined: Thu May 25, 2023 7:24 am

Re: getURLContentAsync hides the HTTP status: Genius lyrics source fails with [null,null] (HTTP 403)

Post by santa808 »

Thanks for the fast reply!
I am looking forward for the 2027 release :D
Post Reply