Album Art using ID3 for Libretime

Hey guys! I ran into this script not too long ago and I will experiment with it. How would you feel about having artwork on tracks?

I understand we could simply use an API to fetch it via Apple Music or another service, but in some cases it’s not enough. So I added support for ID3 tags using getID3 that allow us to do more with tracks, even modify the actual tracks.

I have an app that uses Apple Music to fetch the artwork, but in some cases some tracks are not available (custom, exclusives, etc…) therefor no artwork is available, well the solution was simple, if no track was found in Apple Music then the app fetches the artwork from my server. It’s why I think it should be included. Besides it looks great and give Libretime a little bit of life, being able to see an image attached to the file.

Watch my fork here: https://github.com/codenift/libretime.

It is still very buggy, not completed, but works… Don’t use on a production server yet. Test it, optimize it, improve on it, so we can make this better. Let me know. It can handle loading images quickly for the 100 tracks limit on each page it already queries. For testing, make sure the tracks all have artwork on it. I just did some quick tests and forgot to fix the fallback if it has no artwork. I wasn’t able to upload many of my tracks, maybe an issue with the formatting that needs to get checked, so for testing I had to delete a few of them and upload again. Incase it hangs in the library, just go to Settings > General and in Dangerous Options delete all files. Don’t upload the file that made it hang. This will be fixed in a update.

TODO:

  • Option to not show images in Library, I had this setup in Library columns but it showed the little sorting arrows so I just removed it for now.

  • Drag & drop artwork to the image that’s already there in edit tab using AJAX. Writes data URI into the existing file I set up for artwork. We’re not saving the data URI into database. Now with getID3 we can include artwork inside MP3 file if we wanted to, I know it may not be necessary if nothing is being moved but if something happens or just want to download at least all files will have updated data. And since Libretime has option to download then I think it makes sense.

  • Add artwork next to the current track being played on the top .

  • Scan and update tracks that don’t have artwork set? To have when updating a previous production Libretime.

  • Right click on artwork inside edit tab with option to fetch artwork in MP3

Any thoughts?

1 Like

I like the idea of aggregating and displaying artwork. Does you solution manage the artwork directly in the files or just in the UI?

The legwork for getting the artwork and storing it should probably be done somewhere in the python parts where there already is code that interacts with ID3 tags. Usually LibreTime has been doing stuff like this in libretime_analyzer and then posting the results to the php api server.

I think the artwork could also be useful in the now-playing widget in some way, I’m not sure if Apple Music T&Cs allow using their images in that way though.

Yes. The artwork is being fetched from the audio file and the Data URI for image is then saved into a file instead of saving into the database, only the path is saved into the cc_files table (eg. imported/1/artwork/artwork-file), i think it’s faster this way and not bloat the database. With getID3 we can also write back directly to the audio file if we wanted to incase someone just wants to replace the artwork with something else. Would just need to do a drag and drop feature on the image itself so that it saves into audio and also updates the Data URI. I’m not a python guy so I kinda avoid looking that way, still studying Libretime itself.

Yes, definitely! That’s the idea. One of the reasons I started it. I’ll push an update in a few since I already managed to set it up nicely on the top for Current Playing songs. So it will just need to be set up in the widget.

As far as Apple, that would be something you do only if developing an app with them. I created an app that is in the App Store for my radio station and uses SamCloud for the service, I fetch artwork from Apple and when it’s not available it fetches the artwork from SamCloud, but I will be switching to Libretime since I have more control here. So the idea is to have all the songs in Libretime using the artwork from MP3s. If you have an app then you can fetch artwork from Apple (which allows it) and if it’s not available in Apple Music it will then fetch the artwork from Libretime with a simple if and else rule. And of course if in Android, you can then make the app fetch from Google Music or other services …or just fetch everything from Libretime for any app or widgets.

Just an update on the artwork feature. Still needs some cleanup.

As far as making this happen with Python in metadata_analyzer, the only way I would see it working is by passing the Data URI and saving it into a bytea column which is what I was trying to prevent since that will just bloat the database, unless you’ll able to make it the same way I have it where it grabs the data and saves into in a file then save the path to the the database instead. I’m not too experienced with Python so I chose to do it this way, since we’re able to use the same library later to do more tasks in PHP such as write back to the file when uploading new artwork using AJAX. Either way, I guess I could work on my example just to get it out there as a proof of concept.

Video: https://youtu.be/yTJy5QcvKDs

ALL FIXED NOW :boom:

TODO:

  • Option to change/reset artwork from the edit tab (reset would just get artwork from file if available incase it is changed or never been set)

  • Setting page with option to scan through files and update previous imported files before this feature? :thinking: Incase it is used on a live server and not trying to “reset” it one by one.

Nice to read this.
Yes, this would give some color to Libretime.
Maybe it’s useful to write the small jpeg into the audio file during the file import process.
This will be complementary with a future option to analyze BPM and write the values into the file tags.
Alternatively we can create a new folder for Album Arts with album-titel.jpeg and write the link in database. Both systems are used in classical radio applications. I think it’s more useful when the cover picture is going out with the streaming of the audio file. So we can show the pictures easily in new DAB receivers. I am very interested by this future. Please do it if it’s possible.

I did change it a bit and now it adds a jpg additionally to the Data URI during import since I was having trouble showing it in my iOS app and needed to retrieve as a jpg instead, and using Data URI only within the LB. To get the JPG I had to add to the existing API where I can just retrieve metadata from any track by ID, so you would get it like this:
https://your-site/api/track?id=1276&return=artwork and I guess if add option for thumbnails later on we could just have it with “_32” and “_64” added to the end. It’s currently being saved in imported/artwork/

I was planning to add the option to add/change that artwork in the file this week, still need to add a few more things such as deleting the linked artwork files if a track is deleted.

1 Like

thank you very much for this positive information. Artwork in Libretime will be nice.
I’m new coming to Libretime and make much experimentation to understand how thing are organized and working. In the beginning I imported many audio files before I saw that it will be much better to make BPM analyzing/writing to audio files in front of this. So I deleted my maybe 20’000 audio files In Dashboard-Tracks again. Taking a look in /srv/airtime/stor/imported I can see in folder1 that there are still staying 5852 elements. This are the folders and sub folders using 4,9 Go with no audio files inside. How can I erase them without making trouble in Libretime database?
I hope this can be fixes too.
During experimentation with Libretime, I’m writing a french language manual how to work with Airtime.
We need this for our new community radio project in Avignon, south of France. I hope to contribute with testing Libretime and making translations to this wonderful project.

Yes, I agree. I’m actually experimenting with a few things I need for my station and BPM is one of the things I need, this way we can use them in smart blocks, I’m also experimenting with waveforms in edit tab, seeing how you can already cue in and out and I believe it will be much easier for us to actually see what’s going on and use sliders in the waveform to cue in and out, because we could have hundreds of songs and it would be hard to tell if one has empty space. I also think we have to look into ReplayGain, it’s just not working for me. I have a lot audio files that sound low. I think we need some kind of control for track individually that way we can use a slider for up/down on waveform controlling gain.

As far as your files, if you were trying to delete all your tracks. You can do that in Settings>General> and the very last option “Dangerous Options/Delete All Tracks” that should get rid of everything.

If you still see files in stor/imported then you could just remove it at this point. This will empty the directory.
rm -r /srv/airtime/stor/imported/*

Yes it worked fine.
I did dangerous operation and deleted all Tracks. Now in dashboard tracks I can see no more tracks.
The folders /srv/airtime/stor/imported/ was still keeping the empty folders.
sudo rm -r /srv/airtime/stor/imported/* cleaned all.
Now I can start again importing tracks, but I think this is not a general good solution.
I think it needs in the end of deleting tracks procedure the command to delete empty folders too.
Same like it’s done in EasyBrainz Picard. (I’m working with Xubuntu 16.04 and Libretime-Master)

Yes. Adding a function to check if it’s the only track remaining of the album should do the trick, if true then remove it on the fly… and perhaps adding a Clean option that will remove empty subfolders, just incase for people that already have them.

I want to try your Libretime with artwork from https://github.com/codenift/libretime and have a question now. Do you run it with Ubuntu 16.04 or 18.04 ? I tried it with 18.04 and cannot get access to localhost. It’s a problem of rights.

18.04. Should work. I have it working locally and on a remote server with no issues.

Thank you, so I try it with Xubuntu 18.04 and it runs very fine.

1 Like

I made some experiments with your Libretime Master. The cover art pictures make a nice lookup. If I’m right you added also in Tracks Edition the Media Type selection. That’s a good idea, if we can use it for quick selection, but it does not appears in the column listing. Also the first case for showing cover is missing the designation. Maybe it exists in English but I am using the French language. Can I add it in the French translation ?
An other question is following. I imported some music files to Libretime and removed some. Looking into the /srv/airtime/stor/imported/1/ folder I can still find the empty Artist and Album folders of the removed audio files. Do you think that you can add a function to Libretime that the empty folders in music library are removed too ? I don’t know if this affects the database too. I know that I can remove the empty folders with command line but this will be complicate when I have many Artist and Album folders. What do you think about ?

The Media Type is there, Just missed naming it “Media Type”, select the one that says “Type” instead.

The first case for the cover wasn’t really suppose to be there, I guess when I re-did everything I must’ve missed hiding it. Although it could be useful so I’ll see if I can do it without the name appearing in the table header. That’s the reason you don’t see the name.

Cleaning up empty folders is possible, we would just need to check if there are no other audio tracks in those folders when deleting tracks and then remove them. I had plan to make something for maintenance to scan the music directory also, perhaps adding the feature in settings. I’ll see if I work on it soon if nobody else is working on it.

Tank you very much for your reactive responding.

Removing empty folders will be important I think.

I’m not sure if I have signalised this to Robbt too.

  Do you think to implement the Cover Art into the Libretime3

alphaX ?

  My idea about Media type is maybe strange, but I will try to

explain it.

  I'm technician for some local non commercial Radio stations since
  By my experience I know that such stations will have many

collaborators (about 100) and each one will make his own special
input to the program. Often this are home-made one-hour themed
reports mixed with music.

  To get more easy overview in the audio file library, I would like

to store this files in folders with the same nomination like the
programme categories (Media Type) and a subfolder for each year.

  At the moment I try to organise this with the tags. Maybe we can

organise this in Media type like the genres in the music storage ?

Best regards, Klaus

Yes, Robbt knows. I made a Pull Request to the main LT on both “artwork” and “media type” and we’ve been discussing it on Github. He mentioned about storing files into media type folders (Commercials, Music, ect…) which I think is a great idea to keep things organized on that side of things. Storing them there on upload, and I guess when editing a track (using a track’s edit tab or inline edit on upload), if changing the media type to something else we could just move it to the folder representing the Media Type selected.

Hello, I try to make a new Libretime installation in Xubuntu 18.04.02. I take the code from https://github.com/codenift/libretime with last update made 29 day ago, using sudo ./install -fiap and get new difficulty to access by localhost the server.
The folder of Libretime is right well in home/user/ (user is root). I get answer forbidden access (403) from Apache/2.4.29 (Ubuntu) Server at localhost Port 80.
Can I do something to resolve this problem ?
Something changed between last installation of Libretime (with cover artworks) under Bionic18.04.one month ago. There I had not this problem.

Hi, keep in mind that the fork I had was just for testing and not really intended for production, I had to redo everything so that I can do clean Pull Requests and contribute to the original Libretime. The artwork feature you were testing was already merged to the main Libretime. I also made another PR with the drag and drop feature that allows you to change the artwork but hasn’t been merged yet to the main LT, should be available soon there.

I also made a PR for the Media Type feature you tested but I have it on hold for now since I was going to add something else.

I have another working update that I will be submitting after they merge the drag n drop feature that will allow writing the metadata to the file itself when editing a track, basically an ID3 editor. I just have to add an option on settings so admin can turn on/off this feature.

I made a new branch called merged, which is updated with the latest LT and everything I’ve done so far. If you change the branch to pull from the merged branch, that should update the one you’re currently testing.

Thank you for this information. I will do so and go on with testing new futures too. Our goal is to get this futures for production. I like your work and hope that you go on.I am aware that development is never finished otherwise, it does not justify the name development. Next weekend we will make a workshop with friends from https://www.opendigitalradio.org/software in south of France. One project will be to install sound-processing and AAC+ encoder working with Libretime server for DAB+ service. In Europe DAB+ will complete FM modulation in Broadcast services. This can have interest of new local non commercial radio stations. Thank you very much for all the time you contribute to Libretime.

2 Likes