The Superior Feeling

To somewhat paraphrase that Shania Twain chorus, “God, I feel like a God today.”  I’ve mentioned before that being a programmer is the best thing in the world and it’s the closest you can get to being a god.  Parents, you may think you get to play god, too, but there’s a little issue with deleting your creations when you’re done with them.  So, being a programmer is still the best.

I’ve mentioned before that one of the best things about programming is the ability to automate.  Taking what would be an insurmountable task and making it simple.  And that is what I managed to do today.  As I’ve mentioned before, I’ve set up a music server in the house, Plex, and in prior posts, I’ve talked about my digital music collection.  Occasionally, I mention that the metadata in the files needs improvement.  And that is also what I’ve done.

Metadata in digital files can be as extensive as you want them to be.  At a minimum, you want the artist and song title to be in there, because most players display that important identifying information.  You can go further and add the album release year and genre, so you can sort and group things that are of similar values.  You can go further still and embed artwork in the file, usually the album cover, so your music player can display that, too.  You can go even further than that and put the lyrics for the song in the metadata so some players will show you the lyrics while the song plays.  That is where I am at and it is what I have done.

There are utilities that let you edit the metadata directly, so you can create a new tag and paste in the lyrics for a song.  But, is that even fathomable to do with over 15,000 songs?  There are tools that will let you look up the lyrics to a song and create the tag automatically, but still, song by song.  I never got to the point of finding utilities that would process a whole album at one time, because I realized I could do it better.  I could do it exactly as I needed it to be done.

With Plex, there is no support for embedded lyrics in the metadata.  Instead, they use what’s called a “side-car” file, which is the same file name, but different extension.  So you have your .flac file and a duplicate .txt file with the lyrics.  Ok, that’s pretty crappy, but I can do it.  But, if I’m going to go through the trouble of getting all these lyric files, why not embed them at the same time?

So I did a quick search online and found a code library that would read and write FLAC metadata.  That’s the only thing I couldn’t do on my own, so I was golden now.  I learned of a website that had a simple means of downloading lyrics through their website, as long as I stripped out everything else from the webpage.  A simple RegEx statement accomplished that.  Writing to a text file, recursing through directories,  all that is simple stuff.

image1

So, I process each artist in a batch, which enumerates all songs for all albums.  One button click to retrieve all the lyrics for all the songs, then a review of any songs that had no matches.  Correct the titles for the non-matches and get lyrics again.  Then a button to process the lyrics which both embeds the lyrics in the FLAC files and also creates a sidecar text file with the lyrics.  So, if all goes well, one double-click on the artist folder, click on Retrieve Lyrics, scroll to confirm that all lyrics came in, click Process.

So, yeah, I do have to process a little over 500 artists, but that is substantially better than thousands of albums or many thousands of songs.

Comments are closed.