[WS] Genius (Lyrics)

Intro

After my first Web Source Script [WS] Tunebat and working on knowledge of regular expressions, I decided to create a new script and start a new thread to improve a web script for the best lyrics web source.

I've been working on trying to search on genius.com songs by artist and title and get a dialog to select the best option. It has been impossible for me to get search results, so I've seen it is better to try your luck and access directly to a web address. Maybe one day I develop a search script.

To access Genius Lyrics you have three options:

  1. Lyrics by Artist+Title: Try your luck and enter artist and title. The script will separate words with character '-' and append '-lyrics' at the end, or
  2. Lyrics by URL: The script brings forward an optional URL, and you can change or find it using a web browser and copy/paste the url in input dialog. This is the safer way. :wink:
  3. Lyrics by URL (Ouargi): Similar to previous but the scripts brings forward an URL computed by Ouargi method.

Genius.com is a server difficult to work on, because it can answer the request using two different formats. The script supports both answers, so: Enjoy my work

Download

Genius#Lyrics.v0.21.zip (4.2 KB)
Last Modified: 2021-07-19

How to Install

  1. Download the .zip and extract to %appdata%\mp3tag\data\sources directory (Just hit Win+R and copy paste %appdata%\mp3tag\data\sources)
  2. You can access the scripts right-clicking on the title with mouse and Tag sources->Genius->Lyrics... if using version 3.06 or above.

Script Info

Availables tags are: LYRICS,UNSYNCEDLYRICS

Additional tags are: TITLE, COVERURL, GENIUS_URL. They are here to show you more information about what Mp3tag has found. If you don't want them just remove # sign in "Customization" section in Genius#Lyrics.inc file.

If you need more information that my script does not supply or is incomplete please don't hesitate to contact me.

You can try it and make suggestions. Enjoy!

Version History

0.1: First Public Release
0.2: Added a new search option, additional tags.
0.21: Genius.com has modified one of the versions

6 Likes

Hello, script works astonishingly well except for a case i came across, that of an instrumental/lyrics missing from the new web page, other than that i would like to express an enormous gratitude to you. cheers

2 Likes

Hi @Ouargui, do you mean an instrumental song like Martin Garrix - Poison? I've tested it and unfortunately it works in only one of both web responses. I'm trying to fix it.

2 Likes

exactly the case, best of luck to you

This looks like a fine plugin and I was super happy to find it. However I can't quite get it to work. When I request lyrics on any song, I get the error:

Fehler beim Verbinden zum Server: Genius.com

> 404: Not Found

I verified that MP3tag is not blocked by the firewall and that I'm using the latest version (3.07). I've tired both the config file as-is and with everything but "LYRICS" disabled.

Can you please check if it still works for you? I suspect that genius.com has changed their API in the meantime, but I have no way of telling it.

Yes I've verified it still works.

The web source script can't find the address itself, and it proposes 3 ways to generate a link using song tracks.

Have you tried to search the address by yourself using genius.com search facility and paste it to Lyrics by URL as shown:

LinkasURL

My textbox does not show the "https://genius.com/:"-prefix, so I didn't realize that the content os part of the URL. With the correct formatting (thanks @Ouargui) it works fine

Screenshot 2021-07-17

Sometimes the second window opens, but intead of the lyrics it only shows <Error> instead of the lyrics. Is this a known issue?

Last question: Is it possible to tag multiple files at once? Like to mark all files of an album and then let your script fetch the lyircs for each file?

1 Like

I'm having issues with this script as well. It was working fine up until last month and I've always been putting in the correct search formats for all 3 options as instructed. why is this is happening all of a sudden?

Both Links by URL and Links by URL (Ouargi) work removing https://genius.com from the start, but use different methods to obtain a link.

I've seen the issue and I will try to correct it. Maybe they have changed one of the two different responses they send.

Try to repeat the process because if you do it the web will send you a different answer and the script will get it fine.

I will try to check the script.

@sruxd and @testtyphoon88, I've updated the script. It was only a small modification. Check it please

1 Like

yeah it works now. thank you for fixing this!

even i feel this would be really helpful because it takes some time to repeat everything again and again

sruxd and testtyphoon88, I've updated the script. It was only a small modification. Check it please

Can confirm, works now without a single error ever! Thanks @bugzero


@royden

This seams not possible directly in mp3tag, so I came up with a really hack-y solution using autohotkey:

  1. install the scripting language from autohotkey.com
  2. create a new text file and rename the extention to .ahk
  3. right click to edit the file, paste the code below
  4. double click on the file to run the script. There will be a tray icon which you can right click to stop or reload the script
  5. in mp3tag open the file(s) you want to add lyrics to and select the first row
  6. press CTRL M to open the multi tag window
  7. enter the number of files to tag and press enter
  8. the script will now automatically simulate keyboard presses to re-run @bugzero's script N times. After each run, it will press down to progress to the next file.
  9. DO NOT click on a different window wile the script is running, it will mess up things! If you do so accidentally, you can exit the script through the tray icon.
  10. if your title/artist fields are not correct, lyrics lookup will fail. It will still progress to the next file for N files total, BUT you'll have to tag all un-tagged files manually.

Code:

; Multi Tag Lyrics v0.11, designed to be used with "MP3TAG v3.07" and "[WS] Genius (Lyrics) v0.21" (https://community.mp3tag.de/t/ws-genius-lyrics/52933)
; AutoHotKey script written by sruxd (https://community.mp3tag.de/u/sruxd)
; You can use this code for free under the MIT License

SetTitleMatchMode, RegEx			; use regex to detect which window is active

#IfWinActive ^Mp3tag.*?\\			; only enable hotkey in main window mp3tag; window title must start with "Mp3tag" and end with the "\" of the path name
^m::								; hotkey = CTRL + G

InputBox, count, Multi Tag Lyrics, Number of files to tag:

WinActivate ^Mp3tag.*?\\			; move focus back to the main window		
Loop %count%
{
	send, {CTRL UP}{ALT}			; press ALT to enter menu, press arrow right to select the tag sources
	loop 5 {
		send, {RIGHT}
	}
	send, {ENTER}

	loop 8 {						; press down until genius scrips
		send, {DOWN}
	}
	send, {ENTER}

	send, {DOWN}					; choose 3rd script, seems most reliable
	send, {DOWN}
	send, {ENTER}

	WinWaitActive .*lyrics$			; wait till message box with search suggestion appears
	send, {ENTER}
	WinWaitNotActive .*lyrics$
	
	WinWaitNotActive ^Mp3tag.*?\\	; wait till next window opens
	if WinActive("^Mp3tag v\d+\.\d+$")	; detect if error window is shown
	{
		send, {RIGHT}				; select "cancel"
		send, {ENTER}				; confirm "cancel"
	}
	else
	{
		send, {ENTER}				; auto confirm suggested string
		send, {ENTER}				; auto confirm whatever was found
		WinWaitNotActive ^Mp3tag.*?\\
	}

	WinWaitActive ^Mp3tag.*?\\		; ensure main window is open
	send, {DOWN}					; jump to next entry in list
}
return								; exit function

Edit: use loop command for right and down keys

1 Like

I was running into problems with non-alphanumeric characters, particularly in the Artist+Title search. Modifying the SearchBy to this strips all the non-alphanumerics and seems to work fine. I haven't tried testing it on a file with diacritics, though:

[SearchBy]=$caps3($lower($if2(%artist%,%albumartist%)) $regexp(%title%,'[^a-zA-Z0-9 -]',))

Is there a way to ONLY have the lyrics added automatically? I do not want the cover art or anything else to be added or changed.

In the Customization part of the webscript it is explained.

Thanks. I missed that. I'm trying to see the lyrics added from the script in the tag panel. Is that possible? I do see it in the extended tag panel.