What is current best practice to implement watched directory?

I am new to Libretime, but have been working to implement it at our station. We used to run on Airtime, and had an extensive system for automating file ingestion using watched directories. As a work-around in Libretime, I have been replacing files in /srv/airtime/stor/imported///*/ with the updated versions of the mp3s, retaining the constant filenames. The result is that older files are being played out, not the current file that is resident in the above named directory. Old file is being cached somewhere. I saw reference to this in a thread here from late March, early April, but I do not know the current situation, or how I might best approach getting the file automation put together. Any explanations or suggestions will be most welcome.


Kia ora. We were in the same scenario as you, and so I’ve continued the work on the old watch folder feature so that we could migrate from Airtime to LibreTime. We hit “go” on the migration during the start of COVID19 as it was an essential strategy for our team to broadcast from home.

Here’s the PR https://github.com/LibreTime/libretime/pull/908. We’ve been running this now 24/7 since the middle of March. It’s almost ready to be merged into the master branch but there are a few things that need to happen. One of the “harder” ones is that there’s a new “type” field for media files and so the watch folder needs to implement that somehow. I’ve been super busy but I’m gonna try and get this PR merged as soon as possible. There are other who really need this feature. In the meantime you can manually merge this PR into your local copy of master… but tbh I’m still using an older fork of the master branch since before the new “type” feature was added.

Sorry I know this isn’t helpful, but your post will motivate me to give this some time.

Thank you for your post. Yes, this is very good news. I will see how far I can get with this. I’m a long-time programmer, but not in the git environment, so I need to become familiar with it. I will be working at this until it is functional, as we absolutely need it for our community station, KPIP-LP.

This is awesome, I am also waiting for the this feature to be working again. We use 2 back up servers in case of server down time. Having the ability to be able to FXP between servers will make our life so much easier. Keep up the good work.

In that case, here’s the repo you’ll want to use: https://github.com/TeHikuMedia/libretime/tree/libretime_watch_rebased. I’ve merged the most recent LibreTime master branch into this one over the weekend. It’s pretty much the same as old Airtime. I haven’t updated any docs yet but call out if you need help. Hopefully we can get this PR merged soon.

Thank you for merging them. I will be giving it a try soon. Thanks also for you offer of help down the road, if I need it.

I installed from the “libretime_watch_rebased” repository and everything looked ok. Where will I find the watched directory? Or, did I need to do something related to the install that I did not do?

Were you able to add watch folders via the Settings > Media Folders preference? If so, and you’re not seeing files sync over, then yea something is wrong. You might have to try running sudo service libretime-watch start

In terms of a watch directory, that can be any directory you choose.

I have tried several times, including deleting /etc/airtime/airtime.conf, then re-doing the configuration screens.

I re-installed and did the starts, including libertime-watch, but that last one gave me
“Failed to start libretime-watch.service: Unit libretime-watch.service not found.”

I installed by doing a git on https://github.com/TeHikuMedia/libretime.git and then cd to libretime-watch/libretime, then ./install

Did I miss anything?

Were you able to add watch folders via the Settings > Media Folders preference?

No, it did not appear as an option. Maybe I misunderstood. I saw a screen proposing /srv/airtime/stor and I accepted that. But I did not see a reference to a watched directory.

I am wondering whether I did the git right. Specifically, did I need to do anything other than the simple git command? I am a newby to this.

This would most likely be after the installation on the settings page of LibreTime’s admin section where you can set the Media Folder.

Is the media folder related to, or perhaps the same thing as, the watched directory? My goal is to get a watched directory system that I can move files to and have them be automatically updated in the database. kmahelona had been working on getting that working. I am not sure whether I am following expected procedures to be able to install his code. When I execute the libretime-watch service, I am getting an error that the service is not found. I am not sure whether I even performed the git command correctly, as I am new to the git system.

The watched folder is probably best a separate directory. But yeah it’s still a work in progress and I’m waiting for him to finish something that we can integrate but I am not sure the status, it is a tricky problem to get right for all users. There have been a few works in progress on this that ended up working fine for the stations that coded them but we haven’t quite gotten them to the point where we could include them by default.

Let me know if there is anything I can help with regards to this.

I could use some pointers with regard to modifying code and installing the result.
I have done a git on kmahelona’s code:

$ git https://github.com/TeHikuMedia/libretime.git

If I change something in my local copy of it, then execute ./install again, is that all I need to do to put my changes into effect?

Yeah I don’t think that the kmahelona’s code is compatible with track types and album art. Unfortunately it hasn’t been merged into master and not updated yet. So it might break things if you try to deploy it off of a recently installed master.

Hi !
Great work !
Is it currently in a good way to be merged into master branch of LibreTime, to finish the PR ?

Thanks a lot

I have successfully implemented a working version of the watched folders functionality with Python’s watchdog library. It works great, I’ll tie everything up and push a commit so you guys can test the feature, then if you like it I’ll send you a PR.