On Thu, 28 Jun 2012 18:24:18 -0400, Audiodef Online <[email protected]>  
wrote:

> I think I've figured it out:
>
> #!/usr/local/bin/liquidsoap -t
>
> set("log.file.path","/home/audiodef/radio/liquidradio.log")
> set("log.level",4)
>
> main_radio=mksafe(playlist(timeout=3600.,conservative=true,"http://synthetronica/radio/main_playlist";))
>
> def append_artist(m) =
>          artist = m["artist"]
>          if artist == "" then [("artist","Synthetronica Radio")] else
> [("artist","Synthetronica Radio: #{artist}")] end
> end
> def append_title(m) =
>          title = m["title"]
>          if title == "" then [("title","Various Artists")] else
> [("title","#{title}")] end
> end
>
> main_radio = map_metadata(append_artist, main_radio)
> main_radio = map_metadata(append_title, main_radio)
>
> output.icecast(%vorbis(quality=0.6,samplerate=44100),
>          host="localhost", port=8000,
>          password="(password)", mount="radio.ogg", name="Synthetronica
> Radio",
>          description="Eclectic Electronica", genre="Electronic",
> url="synthetronica",
>          main_radio)
>
> It seems to me that all I need to do now is figure out how to call an
> external script from inside the defs, where the external script looks up
> the currently playing file in a database and returns the artist and
> title. Where do I get the currently playing file name? Is there an
> m["filename"]?
>
> Thanks,
> Damien


Hi Damien,

My setup is somewhat unique in that for any given program, I would have up  
to fifty episodes, but only one is played each day. Via crontab, I would  
load each show with its unique episode (for example, 'c', in code below  
'today-special-mp3-32.pls'). For these 'special' programs, I needed the  
day's unique title. The db field for special programs is never blank. But  
if it were, I would use php to locate any, and add an additional elsif  
below in the following code.



#{content} is derived from a db search for the current show's title field  
using a php system call: 'system("echo $title >  
/usr/local/www/rcr/radio/current/special/mp3/title.txt");'

This is rather clumsy code, but I only use it once daily, and it works. If  
I needed a more elegant approach for multiple shows, I could simply derive  
it for each entry, from db's 'title' field, but as I said, this is a quick  
fix for me.



This sounds a lot more complicated than it is.



     # === SP ===


                a = single("/usr/local/www/rcr/mp3/announce/TOHS.mp3")

                 b =  
single("/usr/local/www/rcr/mp3/announce/opener/opener-sp.mp3")

                 c = playlist.safe(mode="normal",  
"/usr/local/www/rcr/radio/current/special/mp3/today-special-mp3-32.pls")

                 d = single("/usr/local/www/rcr/mp3/announce/CLOSER.mp3")       

                 e = playlist.safe(mode="normal",  
"/usr/local/www/rcr/radio/current/mp3/sp-mp3-end.pls")




            sp = sequence([a,b,c,d,e])



                # Fill-in Title for ID3 Tag

                    def fill_in(s)

                        # the function f takes a list of pairs m representing 
the metadata
                        # and it maps an anonymous function on each pair
                        # replacing empty title definitions by title=filename

                        def f(m)

                            print("\n\nFor metadata: #{m}\n\n")
                            list.map(fun (key_value) ->

                            if key_value==("title","") then

                        
                                  if m["filename"] == 
"/usr/local/www/rcr/mp3/announce/TOHS.mp3" then
                                      ("title", "Rural Catholic Radio - from 
the heartland, with love")

                                  elsif m["filename"] ==  
"/usr/local/www/rcr/mp3/announce/opener/opener-sp.mp3" then
                                      ("title", "Welcome to this Special 
Program")
                                
                                  elsif m["filename"] ==  
"/usr/local/www/rcr/radio/current/special/mp3/today-special-mp3-32.pls"  
then
                                      content = list.hd(get_process_lines("cat  
/usr/local/www/rcr/radio/current/special/mp3/title.txt"))
                                      ("title", "Special Program - #{content}")

                                  elsif m["filename"] == 
"/usr/local/www/rcr/mp3/announce/CLOSER.mp3"  
then
                                      ("title", "Thank you for listening to 
this Special Program")                              

                                  elsif m["filename"] ==  
"/usr/local/www/rcr/radio/current/mp3/sp-mp3-end.pls" then
                                      ("title", "Interlude - Music by Eric 
Genuis")

                                  else
                                    content = list.hd(get_process_lines("cat  
/usr/local/www/rcr/radio/current/special/mp3/title.txt"))
                                      ("title", "Special Program - #{content}")
        
                                  end

                            else key_value end,
                            m)

                           end

                           map_metadata(f,s)

                    end


                sp = fill_in(sp)

Hth

>
> On 06/28/12 20:47, Audiodef Online wrote:
>> Thanks! I understand the logic of that code, but this made me realize I
>> don't know how to make static metadata replacement work. I need to
>> understand that before proceeding with hooking into external scripts.
>> After spending some time looking around and experimenting, I've modified
>> my script to this:
>>
>> #!/usr/local/bin/liquidsoap -t
>>
>> set("log.file.path","/home/audiodef/radio/liquidradio.log")
>> set("log.level",4)
>>
>> main_radio=mksafe(playlist(timeout=3600.,conservative=true,"http://synthetronica/radio/main_playlist";))
>>
>> pattern = '$(if $(display_artist),"Synthetronica Radio","Synthetronica
>> Radio: $(artist)")'
>> main_radio=rewrite_metadata([("artist",pattern)],main_radio)
>> pattern = '$(if $(display_title),"Various Artists","$(title)")'
>> main_radio=rewrite_metadata([("title",pattern)],main_radio)
>>
>> output.icecast(%vorbis(quality=0.6,samplerate=44100),
>>           host="localhost", port=8000,
>>           password="(password)", mount="radio.ogg", name="Synthetronica
>> Radio",
>>           description="Eclectic Electronica", genre="Electronic",
>> url="synthetronica",
>>           main_radio)
>>
>> This works - technically. But it doesn't do what I want, because the
>> fields display_artist and display_title exist for many of the tracks in
>> my playlist, but are empty. How do I modify this script so that if these
>> fields do not exist, or they do exist but are empty, my stream should
>> say "Synthetronica Radio - Various Artists" in Audacious (or whatever
>> media player)?
>>
>> Once I understand how to do this, I'll be ready to proceed to calling
>> external scripts. I would really appreciate any help on this part.
>>
>> Also, is there a page documenting all of the metadata fields? The only
>> reason I know about display_artist and display_title is because it was
>> in an example in the documentation. I haven't found these anywhere else,
>> so I'm hoping I simply did not know where to look.
>>
>> Thanks!
>> Damien
>>
>>
>>
>> On 06/27/12 23:46, [email protected] wrote:
>>> If it's any help, I use the following to get the value of the current
>>> title from
>>> a database entry (where 'title.txt' is a returned value):
>>>
>>>
>>> elsif m["filename"] ==
>>> "/usr/local/www/rcr/radio/current/special/mp3/today-special-mp3-32.pls"  
>>> then
>>>
>>>                        content = list.hd(get_process_lines("cat
>>> /usr/local/www/rcr/radio/current/special/mp3/title.txt"))
>>>                        ("title", "Special Program - #{content}")
>>>
>>> Hth
>>>
>>>
>>> On Wed, 27 Jun 2012 17:10:16 -0400, Audiodef Online
>>> <[email protected]> wrote:
>>>
>>>> Thanks, Martin.
>>>>
>>>> But I have to confess to not knowing how to use this:
>>>>
>>>> (string)->[string]
>>>>
>>>> Perform a shell call and return the list of its output lines.
>>>>
>>>> (unlabeled) (string)
>>>>
>>>> I don't need hand-holding, but I learn best from examples. Is there
>>>> an example
>>>> somewhere I can read to see how it actually works in practice?
>>>>
>>>> Thanks,
>>>> Damien
>>>>
>>>>
>>>> On 06/27/12 20:32, Martin Konečný wrote:
>>>>
>>>> Look up "get_process_lines" function call.
>>>>
>>>>
>>>> http://savonet.sourceforge.net/doc-1.0.0/reference.html
>>>>
>>>>
>>>>
>>>>
>>>> O Wed, Jun 27, 2012 at 4:29 PM, Audiodef Online <[email protected]>
>>>> wrote:
>>>>
>>>> Is it possible to have a LS script execute an external script, wait  
>>>> for
>>>> the external script to return a value, and use that value?
>>>>
>>>> Specifically, I would like my LS script to parse the stream's  
>>>> metadata.
>>>> If the metadata has the literal string "unknown" (case insensitive) as
>>>> the title of the track, then the LS script should execute a PHP script
>>>> (via CGI, of course) and store the result of that script (which would  
>>>> be
>>>> exactly one value - a string) and then set the metadata of the current
>>>> track with the string retrieved from the PHP script.
>>>>
>>>> Can I do this? How would it be done?
>>>>
>>>> --
>>>> My music: http://audiodef.com
>>>> Synthetronica: http://synthetronica.com
>>>> Male survivors of domestic violence: http://abusedmen.org
>>>>
>>>>
>>>> ------------------------------------------------------------------------------
>>>>
>>>> Live Security Virtual Conference
>>>> Exclusive live event will cover all the ways today's security and
>>>> threat landscape has changed and how IT managers can respond.
>>>> Discussions
>>>> will include endpoint security, mobile security and the latest in
>>>> malware
>>>> threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
>>>> _______________________________________________
>>>> Savonet-users mailing list
>>>> [email protected]
>>>> https://lists.sourceforge.net/lists/listinfo/savonet-users
>>>>
>>>>
>>>>
>>>
>>
>
>


-- 
Using Opera's revolutionary email client: http://www.opera.com/mail/

------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and 
threat landscape has changed and how IT managers can respond. Discussions 
will include endpoint security, mobile security and the latest in malware 
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to