This is a semi answer as I don't know your environment and the code I provide is intended to serve as an example only - running it as is shouldn't do any harm but I can't give any guarantee.
Tasks like this can be dealt with using simple bash scripts, e.g. in the following example I use eyeD3 to extract artist and title, then any WikiLirics-like web service to fetch lyrics and then eyeD3 again to add them as a tag. I encourage everyone who will use this code to look up their own lyrics website as exploiting the same service over and over can be considered malicious.
[edit] Someone have actually provided a lyrics API under the URL from this script and it works!
#!/bin/bash
url_template='http://makeitpersonal.co/lyrics?artist=<artist>&title=<title>'
failure_message="Sorry, We don't have lyrics for this song yet."
[ "$1" ] && cd "$1" # if argument provided, use it as working directory
for file in {.mp3,.m4a}; do
if [[ ! -r "$file" ]]; then # if file isn't readable
continue # skip to the next one
fi # but if it is readable...
# get artist&title line from eyeD3
song=$(eyeD3 --no-color "$file" | grep title)
# e.g. title: Alive artist: Bon Jovi
artist="${song#"artist: "}" # use everything after artist:
as artist
title="${song%"artist: "}" # use everything before artist:
as title
title="${title#"title: "}" # but cut the title:
keyword out
echo -n "$artist - $title" # $title has extra space at the end but YOLO
artist="${artist// /+}" # replace spaces in $artist and $title with
title="${title// /+}" # `+` characters for use in $url_template
url="${url_template//"<artist>"/$artist}" # replace `<artist>` with $artist
url="${url//"<title>"/$title}" # replace `<title>` with $title
lyrics=$(wget -qO- $url) # make `wget` read the response from $url
# which is lyrics or $failure_message
if [ "$lyrics" == "$failure_message" ]; then # if it is $failure_message
echo "No lyrics found... skipping!" # then lyrics aren't available
else # else save $lyrics in $file
eyeD3 --lyrics=eng:Lyrics:"$lyrics" "$file" 1>/dev/null
fi
done
Instructions (run commands in terminal):
- install
wget
and eyeD3
with command sudo apt install wget eyed3
- save above code to a file, e.g.
~/bin/lyrics_fetcher.sh
- add permission to run the file:
chmod u+x ~/bin/lyrics_fetcher.sh
- run the file (mind the quotes):
~/bin/lyrics_fetcher.sh "path/to/my album"
- you can stop script execution at any time by pressing ctrl+c
I checked this code with "AM" album by Arctic Monkeys and it did sweetly.
If you really want to fetch lyrics for all of your albums at once you can run the script in a loop for each directory:
cd path/to/my_music_directory
for album in */; do ~/bin/lyrics_fetcher.sh "$album"; done
Still, I wouldn't use it as a final solution - wikilyrics and everyone who supports it by mirroring are good guys and this answer is here to promote thinking, not abuse.
clementine
. Try it. It has support for different lyrics online DBs. (Fork of the old Amarok 1*). – ddmytrenko Oct 19 '15 at 20:08