My Scheduled Liquidsoap Script
  • Since there is no way (for now) to permanently attach a dynamic/smart playlist to a scheduled event on Airtime which could be a groundbreaking feature for Airtime to have. i had to go old school and create a schedule script.


    EDIT:
    Post edited by Guytrance at 2012-10-06 11:39:39
  • 85 Comments sorted by
  • Vote Up1Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    good job ;)
  • Well it seems this script wont let Airtime launch :( can someone take a look at it and tell me where the problem is?

    If i insert the above script after:

    server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end)
    server.register(namespace="vars", "web_stream_enabled", fun (s) -> begin web_stream_enabled := (s == "true") string_of(!web_stream_enabled) end) 
    server.register(namespace="vars", "stream_metadata_type", fun (s) -> begin stream_metadata_type := int_of_string(s) s end) 
    server.register(namespace="vars", "show_name", fun (s) -> begin show_name := s s end) 
    server.register(namespace="vars", "station_name", fun (s) -> begin station_name := s s end)
    server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s end) 
    server.register(namespace="streams", "connection_status", fun (s) -> begin "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end) 

    And then restart Airtime..I get:
    sudo service airtime-playout restart
    Restarting Airtime Playout: ('Error loading config file: %s', error(111, 'Connection refused'))
    Done.

    Airtime Status gives:
    LIQUIDSOAP_PROCESS_ID          = FAILED



    Post edited by Guytrance at 2012-09-17 07:59:00
  • Vote Up1Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    server.register(namespace="vars", "pypo_data", fun (s) -> begin pypo_data := s "Done" end),
    server.register(namespace="vars",
    "web_stream_enabled", fun (s) -> begin web_stream_enabled := (s ==
    "true") string_of(!web_stream_enabled) end) ,
    server.register(namespace="vars", "stream_metadata_type", fun (s) -> begin stream_metadata_type := int_of_string(s) s end) ,
    server.register(namespace="vars", "show_name", fun (s) -> begin show_name := s s end) ,
    server.register(namespace="vars", "station_name", fun (s) -> begin station_name := s s end),
    server.register(namespace="vars", "bootup_time", fun (s) -> begin time := s s end) ,
    server.register(namespace="streams",
    "connection_status", fun (s) -> begin
    "1:#{!s1_connected},2:#{!s2_connected},3:#{!s3_connected}" end) ,


    perhaps no at the last line, i'm not sure...
    I can't try this for the moment (limited connexion :(
    Post edited by Albert FR at 2012-09-17 08:10:09
  • nope, still the same..added "," to each end, but still not working..also tried without the last line..

    Attached the full script file.


    Post edited by Guytrance at 2012-09-17 08:14:46
  • Vote Up1Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    I m almost sure the last one is not good...
    I'm looking your script
  • @Albert

    Any ideas m8?
  • Hey FrancescoP :) thank you for the help..this is the output of your command..

    /usr/lib/airtime/pypo/bin/liquidsoap_scripts# liquidsoap -c ls_script.liq
    At line 128, char 29: the variable randomize used here has not been
      previously defined.


    and this is line 128

    128)  silkmornings = randomize(weights = [1, 6,], [jingles,silk])
    Any thoughts?
    Post edited by Guytrance at 2012-09-18 12:35:35
  • Thanx for the tips guys...

    indeed that error went but another came by..

     (at line 130, char 34) has no argument labeled "weights"!


    130)  hortaweekly = smart_crossfade(weights = [1, 1,], [jingles,hortaclassic])

    I'm guessing smart_crossfade is different then random in terms of how to weigh them?! i need this playlist to be played in order, not random. but with jingles..

    Sorry for all the Q's.. pretty new to LS...

    Post edited by Guytrance at 2012-09-18 16:09:10
  • Vote Up1Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    modify schedule like this :

        silkmornings = rotate(weights = [1, 6,], [jingles,silk])

    ...

  • Reply to @Albert+FR, @FrancescoP 

    ok..i managed to leap over these problems but the main issue still remains..it says that replays and jingles are not defined. thats because they are not in the schedule..i need them to rotate 24/7 when there is no scheduled show runing.

    Before i built this schedule i had this script:

    default = rotate(weights=[1,2,1,5],[jingles,replays,jingles,singles]) 
    ignore(output.dummy(default, fallible=true)) 

    that allowed 24/7 broadcasting of that rotation, now, to get rid of the replays error by liquidsoap i need to insert that script again, i did it, airtime started, but it only plays the scheduled shows (it is what i need) but there is dead air which means it ignores the default = rotate. and just waits for the given day and time for the next show.

    the question is how can i make 'replays' and 'singles' rotate like before while the schedule is not picking something? (dead air)??


    Post edited by Guytrance at 2012-09-19 07:12:41
  • Any thoughts? someone?
  • Vote Up1Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    fast look ;)

    that's seems to be normal
    your declaration of "default" is everywhere (I see 3 iterations)
    for liquidsoap only the last one is considered
  • Reply to @Albert+FR:

    So basically whatever 'default' is attached to will get priority right? so how can i make the schedule work behind a default rotation? besides default what else can i use for the schedule?!


    Post edited by Guytrance at 2012-09-20 11:02:07
  • Reorganising the 'default' order of appearance is not helping...:( i posted this question to the Savonet mailing list in the hopes ill get more help for this...

    Renaming the question as urgent, since were near the opening date for the station, and i'm stuck with this script :(

    Post edited by Guytrance at 2012-09-23 11:46:26
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    I think you need a comma " , " a the end of line
    But I can't try this for the moment...
    do it and say that to us :D
  • Reply to @Albert+FR:

    At the end of which line? :)
  • Reply to @Albert+FR:

    I did exclude the last ","..but still same error..
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    oh sorry I've forgot yesterday..
    I'm looking your script today :/
  • Thank you m8 :) appreciate it! 
  • Hi @Guytrance,

    I can not test your script now (BTW, I'd like to implement something like that but with playlist generated from ID3v2 tags), but you can check syntax on ls_script.liq with the following command:

    liquidsoap -c ls_script.liq

    You have to be in the directory where the script resides, and this command should tell you what exactly is wrong in the script!

    It is a good habit to run that command whenever you change a liquidsoap script, especially on a production system. :)
  • You should use the function random(), randomize() does not exist!

    I think that normal() does not exists too, you should use crossfade() or smart_crossfade() in that section, you already randomized the playlist.

    Take a look at http://savonet.sourceforge.net/doc-1.0.1/reference.html!
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    exactly

    randomize exist but is not a function
    you can call it like that :

    music = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/music/")

    and smart_crossfade is better
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    you have the rotate function to do that , for example :

    default = rotate(weights=[1,3,1,4], [jingles, music,jingles,music])
  • Reply to @Albert+FR:

    This is the whole modified script..which section do i need to rotate to achieve hat i need?

    # START MODIFICATION
    # default = amplify(0.00001, noise())
    # default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)
    singles = playlist(mode='randomize',reload=1,reload_mode="rounds", "/home/tranceilmusic/singles")
    replays = playlist(mode='randomize',reload=1,reload_mode="rounds", "/home/tranceilmusic/replays")  
    jingles = playlist(mode='randomize',reload=1,reload_mode="rounds", "/home/tranceilmusic/jingles/")
    silk = playlist(mode='randomize',reload=1,reload_mode="rounds", "/home/tranceilmusic/silk/")
    chill = playlist(mode='randomize',reload=1,reload_mode="rounds", "/home/tranceilmusic/chillednights/")
    hortaclassic = playlist(mode='smart_crossfade',reload=1,reload_mode="rounds", "/home/tranceilmusic/hortaclassic/")
    helmano = playlist(mode='smart_crossfade',reload=1,reload_mode="rounds", "/home/tranceilmusic/moranhelman/")
    tilsessions = playlist(mode='smart_crossfade',reload=1,reload_mode="rounds", "/home/tranceilmusic/tilsessions/")
    danmeyerdeep = playlist(mode='smart_crossfade',reload=1,reload_mode="rounds", "/home/tranceilmusic/danmeyerdeep/")
    dasha = playlist(mode='smart_crossfade',reload=1,reload_mode="rounds", "/home/tranceilmusic/dasha/")



    # Schedule
        silkmornings = random(weights = [1, 6,], [jingles,silk])
        chillout = random(weights = [1, 6,], [jingles,chill])
        hortaweekly = smart_crossfade(weights = [1, 1,], [jingles,hortaclassic])
        moranhelman = smart_crossfade(weights = [1, 1,], [jingles,helmano])
        tranceilsessions = smart_crossfade(weights = [1, 1,], [jingles,tilsessions])
        danmeyer = smart_crossfade(weights = [1, 1,], [jingles,danmeyerdeep])
        dashalove = smart_crossfade(weights = [1, 1,], [jingles,dasha])
            
        default=fallback([
            switch([
                ({ (0w or 1w or 2w or 3w or 4w or 5w or 6w) and 7h-12h}, silkmornings),
                ({ (0w or 2w or 3w) and 2h-7h}, chillout),
                ({ (3w) and 19h-21h}, hortaweekly),
                ({ (0w) and 20h-21h}, moranhelman),
                ({ (6w) and 21h-23h}, tranceilsessions),
                ({ (5w) and 18h-19h}, danmeyer),
                ({ (6w) and 18h-19h}, dashalove),
                ])
                ])

  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    send your script corrected again ;)
  • There ya go :)
  • please attach the ls_lib you use as well

    Airtime Pro Hosting: http://airtime.pro
  • Reply to @Martin+Konecny:

    Hey Martin.

    attached. (it is the same ls_lib that came with airtime, i havent changed it.) only modifications i did are to ls_script file attached a few posts up..

    Thank you for helping out m8.
    Post edited by Guytrance at 2012-09-24 16:55:31
  • If you haven't modified ls_lib.liq, that is one problem.

    That file is using "current_dyn_id" which appears to have been removed from your ls_script.liq

    martin@Thinkpad-T410:~/tmp/liq$ airtime-liquidsoap test.liq 
    At ./ls_lib.liq, line 13, char 13-126: the variable current_dyn_id used here
      has not been previously defined.

    Airtime Pro Hosting: http://airtime.pro
  • Reply to @Martin+Konecny:

    I'm not sure what how to proceed from your last error you got..i am completely new to scripting with liquidsoap and i find liquidsoap's manuals very hard to be put together..

    When i run the attached ls_script file i get dead air (it is online and waiting for first scheduled show) but its dead air...i need to rotate some folders whenever i dont have a scheduled show coming up. apparently default=rotate just dont cut it.

    This is what i'm trying to achieve while scheduled show is not on air:
    default = rotate(weights=[1,2,1,5],[jingles,replays,jingles,singles]) 


    Will it help if i grant you access to the server?
    Post edited by Guytrance at 2012-09-24 17:39:36
  • ls_lib.liq in "included" inside of ls_script.liq which basically means that you can replace "include ls_lib.liq" with the contents of that file and you get the same end result.

    This should help understanding why moving the variable declaration broke stuff in ls_lib.liq
    Airtime Pro Hosting: http://airtime.pro
  • Reply to @Martin+Konecny:

    I placed the contents of ls_lib file inside ls_script and removing the include call..

    but running liquidsoap -c ls_script.liq  passes...no errors..stream starts at dead air as usual. 


  • Simply attach the entire file you've made, and we'll try to point out any obvious errors.
    Airtime Pro Hosting: http://airtime.pro
  • Reply to @Martin+Konecny:

    Hey Martin. thanx for replying.

    This is the ls_script along with ls_lib inside

    Post edited by Guytrance at 2012-10-01 09:37:28
  • Ok, I found and ran the file, no obvious script errors anymore. But it would be good, if you started with the original ls_script.liq, made your changes (without merging ls_lib.liq), and then submitted this, so it's easy for me to use a tool that highlights the differences you made. 
    Airtime Pro Hosting: http://airtime.pro
  • well basically i took the 2.2 RC1 file and added the schedule elements...

    Heres the file without the ls_lib add..only my modification starts at line 115.




  • I dont know if this is related..and it dosent seem to interfere with the broadcast...but eversince i installed 2.2, running liquidsoap -c ls_script.liq 

    Gives me:

    Traceback (most recent call last):
      File "pyponotify.py", line 28, in <module>
        from api_clients import *
    ImportError: No module named api_clients
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    Guytrance,
    please close one of your thread ...
  • yup..second one closed. ;)
  • Albert: Attached as requested
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    lol

    that's normal, you haven't really pasting what I write (look the other thread :-)
    albert or rotating would be used into your next declaration ;-)


    like this :

    default=fallback([

    switch([

    ({ (0w or 1w or 2w or 3w or 4w or 5w or 6w) and 23h-07h}, rotating),

    ({ (0w or 2w or 3w) and 2h-7h}, chillout),

    ({ (3w) and 19h-21h}, hortaweekly),

    ({ (0w) and 20h-21h}, moranhelman),

    ({ (6w) and 21h-23h}, tranceilsessions),

    ({ (5w) and 18h-19h}, rotating),

    ({ (6w) and 18h-19h}, dashalove),

     ])

    ])

    Post edited by Albert FR at 2012-10-01 10:44:04
  • Oh yes i see what you were trying to explain...

    I did that, and it dose give 24h rotation of "rotating" but the problem is whenever another program is scheduled to kick in, it cant. because "rotating" is playing as a scheduled show...;)

    Take a look, i modify 'chillout' to play now...but 'rotating' still play...

    Any thoughts?

    Post edited by Guytrance at 2012-10-01 11:53:17
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    erase theses lines :

    # Optional Processing (comment out if too loud/pumpy for your kind of music
    default=nrj(default)

    # Let's play!
    default=mksafe(default)
    # s = fallback(track_sensitive=false, [queue, default])
    # s = normalize (s)


    and try again :-)
    Post edited by Albert FR at 2012-10-01 15:05:52
  • Reply to @Albert+FR:

    still the same...'rotating' show wont let other scheduled shows kick in...

    ;)

    The right ls_script is the current one..
    Post edited by Guytrance at 2012-10-01 22:27:07
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    once again, it's normal, follow what I said...

    under switch function, put this :

                ignore(output.dummy(default, fallible=true)) 

    I really don't understand why you erase it...
    Post edited by Albert FR at 2012-10-02 03:55:10
  • Reply to @Albert+FR:

    lol...i didn't!
    i messed up the files yet again..i have so many copies created. THIS is the real one.. 

    I erased every unneeded copy.

    sorry m8. :)


    Post edited by Guytrance at 2012-10-02 05:08:09
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    yes that's better, but you have erase others call into ls_script...
    have you the original ls_script of the 2.2 ? compare the two

    all under :

                ignore(output.dummy(default, fallible=true)) 

    would be the same...

  • Reply to @Albert+FR:

    i copied the contents of original 1.0.1 from that line to the end, just to be sure

    Just as a notice: liquidsoap didn't upgraded with 2.2, i installed it manually (as instructed by the installation notes upon release)

    Post edited by Guytrance at 2012-10-02 06:31:02
  • Vote Up0Vote Down Albert FRAlbert FR
    Posts: 1,978Member, Airtime Moderator
    do you really work on 2.2 rc1 ?
  • Reply to @Albert+FR:

    im pretty sure ;)
     

    About

    Airtime 2.2.0, the open radio software for scheduling and remote station management.
    © 2012 Sourcefabric o.p.s. Airtime is distributed under the GNU GPL v.3

    Post edited by Guytrance at 2012-10-02 08:19:14