organizing off airplay w. liquidsoap
  • hey,

    i have airtime 2.0.3 and on silence i want liquidsoap to start broadcasting. 
    only that i want it to play from a certain folder between certain hours. i have folders for each of the shows and adapted a script for the ls_script.liq
    still, it seems i have something wrong (i don't know to code). could someone tell me where? 


    #default = amplify(0.00001, noise())
    #default = rewrite_metadata([("artist","Airtime"), ("title", "offline")],default)

    playlist1 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst1/")
    playlist2 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst2/")
    playlist3 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst3/")
    playlist4 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst4/")
    playlist5 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst5/")
    playlist6 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst6/")
    playlist7 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst7/")
    playlist8 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst8/")
    playlist9 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst9/")
    playlist10 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst10/")
    playlist11 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst11/")
    playlist12 = playlist(mode='randomize',reload=1,reload_mode="rounds", "/srv/users/plst13/")


    default=fallback([ 
    switch([
    ({ 0h-2h}, playlist1),
    ({ 2h-3h}, playlist2),
    ({ 3h-4h}, playlist3),
    ({ 4h-5h}, playlist4),
    ({ 5h-8h}, playlist5),
    ({ 8h-10h}, playlist6),
    ({ 10h-11h}, playlist7),
    ({ 11h-13h}, playlist8), 
    ({ 13h-14h}, playlist9),
    ({ 14h-17h), playlist10),
    ({ 17h-19h}, playlist11),
    ({ 19h-20h}, playlist12),
    ({ 20h-22h}, playlist10),
    ({ 22h-0h}, playlist13)
    ])
    ])

    Post edited by stefan s at 2012-05-29 14:10:04
  • 15 Comments sorted by
  • You shouldn't need to have the switch statement nested in a fallback. Just remove the fallback part. Also you should probably try running 

    "sudo -u pypo /usr/lib/airtime/pypo/bin/airtime-liquidsoap"

    from the command-line so you can see any error messages.
    Airtime Pro Hosting: http://airtime.pro
  • Any time I modify ls_script.liq, I like to run:

    sudo tail -f /var/log/airtime/pypo-liquidsoap/ls_script.log

    and watch for problems. I like Martin's suggestion too because it let's you see everything liquidsoap is doing, although the amount of information can be a little overwhelming because it's generated so quickly.
  • hey,

    thanks for your answers. 
    @martin: when removing the fallback part, you suggest smth like this
    default= switch([
    ({ 0h-2h}, playlist1),
    ({ 2h-3h}, playlist2),
    ({ 3h-4h}, playlist3),
    ({ 4h-5h}, playlist4),
    and so on...?

    i'll try this out and keep you posted.

    thanks a lot! 
    Post edited by stefan s at 2012-05-29 10:22:58

  • this is the log i get

    stefan@station-1501:~$ sudo tail -f /var/log/airtime/pypo-liquidsoap/ls_script.log
    2012/05/29 20:16:39 [main:3] Shutdown started!
    2012/05/29 20:16:39 [main:3] Waiting for threads to terminate...
    2012/05/29 20:16:39 [funkside(dot)down:3] Closing connection...
    2012/05/29 20:16:39 [sase:3] Finished with "/srv/users/sase//boombaptist-ghetto-blaster.mp3".
    2012/05/29 20:16:39 [cinci:3] Finished with "/srv/users/cinci//205-alif_tree_-_reality.mp3".
    2012/05/29 20:16:39 [patru:3] Finished with "/srv/users/patru//02.birdy nam nam -  body, mind, spirit.mp3".
    2012/05/29 20:16:39 [clock.wallclock_main:3] Streaming loop stopped.
    2012/05/29 20:16:39 [threads:3] Thread "wallclock_main" terminated (0 remaining).
    2012/05/29 20:16:39 [main:3] Cleaning downloaded files...
    2012/05/29 20:16:39 >>> LOG END


    stefan@station-1501:~$ sudo -u pypo /usr/lib/airtime/pypo/bin/airtime-liquidsoapLine 55, char 3 before "(": Parse error!


    line 55 is the second one after the switch function
        ({ 2h-3h}, plst2)

    and this is the final script:

    default=switch([
        ({ 0h-2h}, plst1)
        ({ 2h-3h}, plst2)
        ({ 3h-4h}, plst3)
        ({ 4h-5h}, plst4)
        ({ 5h-8h}, plst5)
        ({ 8h-10h}, plst6)
        ({ 10h-11h}, plst8)
        ({ 11h-13h}, plst9)
        ({ 13h-14h}, plst10)
        ({ 14h-17h), plst11)
        ({ 17h-19h}, plst12)
        ({ 19h-20h}, plst13)
        ({ 20h-22h}, plst14)
        ({ 22h-0h}, plst15)
    ])

    what's wrong?
  • Vote Up0Vote Down NaomiNaomi
    Posts: 228Member
    hey I'm not a liquidsoap expert, but I think you just need commas after each item, I'm checking the example switch on liquidsoaps documentation and they write it like this

    switch([ 
    	({0h-7h}, night), <-- commas separating items before the end
    	({7h-24h}, day) 
    ])

    try this:

    default=switch([ 
        ({ 0h-2h}, plst1) ,
        ({ 2h-3h}, plst2) ,
        ({ 3h-4h}, plst3) ,
        ({ 4h-5h}, plst4) ,
        ({ 5h-8h}, plst5) ,
        ({ 8h-10h}, plst6), 
        ({ 10h-11h}, plst8), 
        ({ 11h-13h}, plst9) ,
        ({ 13h-14h}, plst10), 
        ({ 14h-17h), plst11) ,
        ({ 17h-19h}, plst12) ,
        ({ 19h-20h}, plst13) ,
        ({ 20h-22h}, plst14) ,
        ({ 22h-0h}, plst15) 
    ]) 
  • @ naomi: i tried the commas as you suggested but no chance. liquidsoap still encounters a problem and won't work :/
  • Vote Up0Vote Down NaomiNaomi
    Posts: 228Member
    Is there another error you are getting now?
  • Vote Up0Vote Down NaomiNaomi
    Posts: 228Member
    what does your new script look like now? I saw you used to name playlists like this above "playlist1", but now it's "plst1"
  • well, the only changes i made to the script are the folder names and the playlist titles. 
    some folders are named unu, doi, trei, patru, cinci, sase and the rest are plst1, plst2 (just testing-purposes)

    but the rule will apply from now on: 'playlistX' is the name of the playlist while plstX is the folder assigned to it. 

  • You should run the script and post the errors Liquidsoap points out. Only that will help debug the problem
    Airtime Pro Hosting: http://airtime.pro
  • @ martin:

    stefan@station-1501:~$ sudo -u pypo /usr/lib/airtime/pypo/bin/airtime-liquidsoapLine 55, char 3 before "(": Parse error!

  • Ok, so you simply need to look at line 55 and post that here. Otherwise we can't help you :)
    Airtime Pro Hosting: http://airtime.pro
  • now i get this:

    sudo -u pypo /usr/lib/airtime/pypo/bin/airtime-liquidsoap

    At file /etc/airtime/liquidsoap.cfg, line 46, character 19: The variable
      dj_live_stream_mp defined here is not used anywhere in its scope.
      Use ignore(...) instead of dj_live_stream_mp = ... if you meant
      to not use it. Otherwise, this may be a typo or a sign that your script
      does not do what you intend.

  • Reply to @stefan+s:

    Exactly as the error message says, there is a variable that isn't being used, and so Liquidsoap is refusing to start.

    Did you remove a part of the code that uses this variable?
    Airtime Pro Hosting: http://airtime.pro
  • yes, i managed to make it work.
    it seems that the script didn't work because i used a playlist twice from 12h to 14h and then again from 15h to 17h. i wanted it to be this way but liquidsoap didn't like it so i renamed it (still, it plays music from the same folder under a different name).
    thanks everyone!