# What is current best practice to implement watched directory?

**URL:** <https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619>\
**Category:** Uncategorized\
**Created:** [July 6, 2020, 3:44pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619 "2020-07-06T15:44:18Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 6, 2020, 3:44pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/1 "2020-07-06T15:44:18Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kmahelona](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/kmahelona/32/807_2.png) [@kmahelona](https://discourse.libretime.org/u/kmahelona)\
**Post date:** [July 9, 2020, 9:27pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/2 "2020-07-09T21:27:42Z")

</div>

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](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.

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 10, 2020, 2:50pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/3 "2020-07-10T14:50:56Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![brig](https://avatars.discourse-cdn.com/v4/letter/b/4491bb/32.png) [@brig](https://discourse.libretime.org/u/brig)\
**Post date:** [July 12, 2020, 5:40am UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/4 "2020-07-12T05:40:39Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![kmahelona](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/kmahelona/32/807_2.png) [@kmahelona](https://discourse.libretime.org/u/kmahelona)\
**Post date:** [July 12, 2020, 8:43pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/5 "2020-07-12T20:43:26Z")

</div>

In that case, here’s the repo you’ll want to use: [https://github.com/TeHikuMedia/libretime/tree/libretime\_watch\_rebased](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.

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 15, 2020, 11:46pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/6 "2020-07-15T23:46:07Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 19, 2020, 12:45am UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/7 "2020-07-19T00:45:34Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![kmahelona](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/kmahelona/32/807_2.png) [@kmahelona](https://discourse.libretime.org/u/kmahelona)\
**Post date:** [July 20, 2020, 7:30am UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/8 "2020-07-20T07:30:44Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 20, 2020, 1:30pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/9 "2020-07-20T13:30:49Z")

</div>

> [@kmahelona](#):
>
> sudo service libretime-watch start

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.”

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 20, 2020, 3:45pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/10 "2020-07-20T15:45:05Z")

</div>

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

Did I miss anything?

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 20, 2020, 4:02pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/11 "2020-07-20T16:02:29Z")

</div>

> 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.

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [July 21, 2020, 4:08pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/12 "2020-07-21T16:08:27Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 21, 2020, 6:52pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/13 "2020-07-21T18:52:31Z")

</div>

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](https://discourse.libretime.org/u/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.

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [July 21, 2020, 10:32pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/14 "2020-07-21T22:32:58Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![johntinker](https://avatars.discourse-cdn.com/v4/letter/j/7cd45c/32.png) [@johntinker](https://discourse.libretime.org/u/johntinker)\
**Post date:** [July 23, 2020, 2:52pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/15 "2020-07-23T14:52:50Z")

</div>

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](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?

---

<div class="post-metadata">

**Author:** ![robbt](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/robbt/32/15_2.png) [@robbt](https://discourse.libretime.org/u/robbt)\
**Post date:** [August 24, 2020, 1:26pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/16 "2020-08-24T13:26:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![jfloury](https://avatars.discourse-cdn.com/v4/letter/j/b3f665/32.png) [@jfloury](https://discourse.libretime.org/u/jfloury)\
**Post date:** [July 16, 2021, 9:36pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/17 "2021-07-16T21:36:57Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xabispacebiker](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.libretime.org/xabispacebiker/32/24_2.png) [@xabispacebiker](https://discourse.libretime.org/u/xabispacebiker)\
**Post date:** [September 3, 2021, 9:30pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/18 "2021-09-03T21:30:30Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![cjsfmgr](https://avatars.discourse-cdn.com/v4/letter/c/77aa72/32.png) [@cjsfmgr](https://discourse.libretime.org/u/cjsfmgr)\
**Post date:** [January 26, 2023, 10:59pm UTC](https://discourse.libretime.org/t/what-is-current-best-practice-to-implement-watched-directory/619/19 "2023-01-26T22:59:31Z")

</div>

Is there any further progress on this?

We are planning to move to Libretime from Airtime but use the watched folders a lot.
