# TOH news playing old file

**URL:** <https://discourse.libretime.org/t/toh-news-playing-old-file/524>\
**Category:** Dev Talk\
**Created:** [April 11, 2020, 8:20am UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524 "2020-04-11T08:20:39Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![hansommen](https://avatars.discourse-cdn.com/v4/letter/h/58f4c7/32.png) [@hansommen](https://discourse.libretime.org/u/hansommen)\
**Post date:** [April 11, 2020, 8:20am UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524/1 "2020-04-11T08:20:39Z")

</div>

Hello for the TOH news i use a smartblock where the news file will be loaded only if it was uploaded 3 minutes or less ago. The latest news is dowloaded from our news agent 4 minutes before the hour and added to the database by a python script in a crontab task. In this case the file will not play but if i set the uploaded time to 63 minutes ago in the smartblock it is playing (but not the actual) news. So it seems that the update of the database took a longer time than 4 minutes. Is there a possibility to force the update to take place for example 1 minute before the hour. Thanks,

---

<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:** [April 11, 2020, 1:27pm UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524/2 "2020-04-11T13:27:22Z")

</div>

So if you are using an autoloading playlist to add the smartblock this currently happens an hour before a show is set to air, there isn’t currently a way to modify in the UI but the code is there and the idea of making this variable on a global or even per show basis is definitely a feature that would be useful for someone to contribute.

So I suspect this is what is happening to make the news out of date. Let me know if this makes sense. If you need help modifying the time I can point out where it is hardcoded and can be changed.

---

<div class="post-metadata">

**Author:** ![hansommen](https://avatars.discourse-cdn.com/v4/letter/h/58f4c7/32.png) [@hansommen](https://discourse.libretime.org/u/hansommen)\
**Post date:** [April 12, 2020, 9:30am UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524/3 "2020-04-12T09:30:46Z")

</div>

Thanks for the info,so i have to look for another solution. Maybe i’ll try to make a live stream (as master source) of the news which interrupt the running show and after the news (approx 2 minutes) restart it

---

<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:** [April 17, 2020, 12:19pm UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524/4 "2020-04-17T12:19:31Z")

</div>

I could probably provide you with a pointer to the section of code so that you could try modifying it. Making this a customizable feature was a development goal.

---

<div class="post-metadata">

**Author:** ![hansommen](https://avatars.discourse-cdn.com/v4/letter/h/58f4c7/32.png) [@hansommen](https://discourse.libretime.org/u/hansommen)\
**Post date:** [April 18, 2020, 8:32pm UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524/5 "2020-04-18T20:32:11Z")

</div>

Robbt, thanks but my suggested solution works, i just have to fine tune it, in libretime i add every hour a 2 minutes dummy file (silent) and at the same time the master source takes over with the news (downloaded 2 minutes ago) a cron task started on 58 minutes takes care of it.

---

<div class="post-metadata">

**Author:** ![hansommen](https://avatars.discourse-cdn.com/v4/letter/h/58f4c7/32.png) [@hansommen](https://discourse.libretime.org/u/hansommen)\
**Post date:** [April 28, 2020, 2:19pm UTC](https://discourse.libretime.org/t/toh-news-playing-old-file/524/6 "2020-04-28T14:19:24Z")

</div>

FYI My solution:  
The news ends always exact on the hour+2 minutes, so it has to start in minute 59 of the hour before.  
The length of the file and the delay time is calculated after the downloading.  
To execute this i made some tasks which are called in contrab (in this case to play the news from 9…23),  
in terminal:

crontab -e  
add:  
57 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 \* \* \* curl or wget for your download from your newsagent

after that set a contrab task to call a python file i.e.

59 8,9,10,11,12,13,14,15,16,17,18,19,20,21,22 \* \* \* cd /home/omroep/nosnieuws && python /home/omroep/nosnieuws/uurnieuws.py

script uurnieuws.py:  
#################################################################################  
#!/usr/bin/python  
from mutagen.mp3 import MP3  
from mutagen.easyid3 import EasyID3  
from datetime import datetime  
from shutil import copyfile  
import mutagen.id3, time, subprocess

delaytime = 60  
filename = ‘/home/omroep/nosnieuws/nosnieuwsnuldb.mp3’  
file\_error = ‘/home/omroep/nosnieuws/nieuwsfiller.mp3’  
try:  
mp3file = MP3(filename, ID3=EasyID3)  
except:  
copyfile(file\_error, filename)  
finally:  
mp3file = MP3(filename, ID3=EasyID3)

seconds = (mp3file.info.length)  
if int(seconds) \>= 150 or int(seconds) \<= 90:  
copyfile(file\_error, filename)  
else:  
delaytime = 166 - (int(seconds))

now = datetime.now()  
uur = str(now.hour)  
uurfile = “/home/omroep/nosnieuws/tijdmelding/” + uur + “.mp3”  
copyfile(uurfile, “/home/omroep/nosnieuws/uur.mp3”)  
time.sleep(delaytime)  
subprocess.call([’/home/omroep/nosnieuws/uurnieuws.sh’])

#end uurnieuws.py  
####################################################################################

and uurnieuws.sh:

####################################################################################  
#!/bin/bash  
liquidsoap ‘output.icecast(%mp3, host=“localhost”, port=8038, user=“user\_name”, password=“user\_password”, mount=“your\_mount i.e. live”, fallible=true, on\_stop=shutdown, playlist.once(“your\_playlist.m3u”))’  
####################################################################################

the playlist:  
####################################################################################  
uurjingle.mp3  
uur.mp3  
nosnieuwsnuldb.mp3  
####################################################################################

and the files in /home/omroep/nosnieuws/tijdmelding/  
9.mp3  
10.mp3  
11.mp3  
ext until  
22.mp3

announce the actual hour + 1 for example 10.mp3 says: “It’s now eleven o’clock”
