Jingle with expiration date
  • Hi folks,

    This was a big request I think we all were expecting from Sourcefabric, we needed this functionality so much in our radio system, so we thought of a small "hack" (if it can be called hack because we did not modify original files).

    First of all, let me explain you the situation. We run a radio and obviously, we need to play jingles, either stations ids or commercials. Some of those jiingles have an expiration date (in case it is an event or so..) then we needed a way to set an expiration date and to automatically disable it.

    This is how we solved it:

    1- Jingles are marked as "jingle" in genre metadata.
    2- They are also marked as "station_id" or "commercial" in the  mood metadata.
    3- If it has an expiration date, we write it down in the isrc_number using this format YYYYMMDD

    Then, every day at 00:00 we run a cron with the following script:


    <?php
    define ('JINGLE_TAG', '%jingle%');
    define ('JINGLE_DISABLED_TAG', 'disabled');
    define('LOG_LEVEL', 3);

    # 1- Connect to PostgreSQL and get the available Jingles.
    $dbconn = pg_connect("host=localhost dbname=airtime user=airtime password=airtime")
    or error_log(date('d.m.Y h:i:s')." | ". basename(__FILE__) . " | Could not connect :'".pg_last_error()."'\n", 3, "/var/log/syslog");
    # 2- Compare the field ISRC Number against today's date:
    $query = "SELECT id, isrc_number FROM cc_files WHERE (genre LIKE '".JINGLE_TAG."') AND (mood!='".JINGLE_DISABLED_TAG."')";
    $result = pg_query($query)
    or error_log(date('d.m.Y h:i:s')." | ". basename(__FILE__) . " | Query failed :'".pg_last_error()."'\n", 3, "/var/log/syslog");
    $today = date("Ymd");
    while ($line = pg_fetch_array($result, null, PGSQL_ASSOC)) {
    // Script runs in a CRON every day at 00:00, disable every jingle in the past
    if (!empty($line['isrc_number']) && $line['isrc_number']<$today) {
    if (LOG_LEVEL>=3) error_log(date('d.m.Y h:i:s')." | " . basename(__FILE__) . " | Id ".$line['id']." needs to be disabled\n");
    $update_query = "UPDATE cc_files SET mood = '".JINGLE_DISABLED_TAG."' WHERE id=".$line['id'];
    #echo $update_query."\n";
    $update_result = pg_query($update_query)
    or error_log(date('d.m.Y h:i:s')." | ". basename(__FILE__) . " | Query failed :'".pg_last_error()."'\n", 3, "/var/log/syslog");
    }
    }
    # Close database
    pg_close($dbconn);

    ?>



    This, in combination with another script to create m3u files from cc_files table (executed everyday by the same cron at 00:00) makes fresh jingle playlists and music playlists that we later use in the fallback liq.

    In the other hand, users fill their spaces with audios they record, sometimes, they need to feed it with jingles or music via smart blocks. So, as the above php script updates the mood metadata field, they will always get the up to date jingles.
    Post edited by Bashatee Radio at 2015-03-12 20:18:27
  • 4 Comments sorted by
  • Excellent! Very well done!
    No longer using Airtime or Libretime.
  • Vote Up0Vote Down hoerichhoerich
    Posts: 627Member, Airtime Moderator
    thx for sharing!
    Official Airtime Forum Manager
    --------------------------
    Most of the time an issue is located between keyboard and chair.
  • "This, in combination with another script to create m3u files from cc_files table (executed everyday by the same cron at 00:00) makes fresh jingle playlists and music playlists that we later use in the fallback liq."

    This would be useful for our set up where is this other script "to create m3u files from cc_files table" ??

    steven
  • The first part of this post is found at the bottom here

    https://forum.sourcefabric.org/discussion/16909/autodj-sweetest-seen-fake-or-real-for-a-good-deal-free-free-no-unexpected-autoplay

    but i have your back here.
    That is exactly what I do for my autodj.

    I may be able to share my code with you for the controller and views ,just give me some time to get my bearings back,I was out for a little and just returning to the forumHappy Streaming


    Anyone reading this a find it funny about my grammar , I make no apology ,Go get a translator.
    "The Problem with education today is that it takes a university degree to switch on a light bulb"
    "You learn from your mistakes but wise people learn from others mistakes avoid Making mistakes there is not sufficient rooms to make them"
    "Innuendo","If's","Assumptions" and "Fear" are for politician.Who,What,where,When and How are for those seeking knowledge and care about Humanity.
    "I might be in Mud but that does not Make me a Wild Hog(pig)"
    “Any intelligent fool can make things bigger, more complex, and more violent. It takes a touch of genius — and a lot of courage to move in the opposite direction.”
    "The only thing that remains constant is change itself"
    May the force be with you,until our path or destiny bring us in tandem.