Hi,

2013/6/20  <[email protected]>:
>
> Hi,
>
> I am trying to assign a title or filename to a switch element that utiizes
> (playlist.safe(mode="random", of a directory. However, since the filename
> is not known until after the random selection is chosen by LS, the
> following code produces "Unknown' as the result in YP listings.
>
> How would I assign the value in the 'else' statement below as 'title' of
> all the random selections?
>
>
>      # === GSMBA ===
>
>                 gsmba = audio_to_stereo(playlist.safe(mode="random",
> "/usr/local/www/rcr/mp3/music/Phillips/Blessed_Assurance"))
>
>                 # 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/TOHN.mp3"
> then
>                                       ("title", "Rural Catholic Radio - from 
> the heartland, with love")
>
>
>                                   else ("title", "Gentle Spirit Music - 
> Latest Album - Blessed
> Assurance by David Phillips - see www.RuralCatholicRadio.com for details")
>
>                                   end
>
>                             else key_value end,
>                             m)
>
>                            end
>
>                            map_metadata(f,s)
>
>                     end
>
>
>                 gsmba = fill_in(gsmba)

You should not use list.map. First you should locate the title meta,
if existing, using list.assoc or the shorthand notation l[key]:

def f(m) =
  title = m["title"]

  # Now you can return something:
  if title == "" then
    ....
    [("title", "...")]
  else
    [] # nothing in this case?
  end
end

Hope that helps,
Romain

------------------------------------------------------------------------------
This SF.net email is sponsored by Windows:

Build for Windows Store.

http://p.sf.net/sfu/windows-dev2dev
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to