Hi, all!
Here is a last version of the script (only functions I've changed).
Any remarks?
# Split args of the form arg=bar&arg2=bar2
# into [("arg","bar"),("arg2","bar2")]
# @category String
# @param uri Args to split
def arg.split(args)
  if args != "" then
    l = string.split(separator="&",args)
    def f(x) =
      ret = string.split(separator="=",x)
      (url.decode(list.nth(ret,0)),
       url.decode(list.nth(ret,1)))
    end
    list.map(f,l)
  else
    []
  end
end

# Now we write a function to create
# a playlist source and output it.
def create_playlist(uri) =
#uri = "playlist=pl.m3u&shuffle=1&ads=1&mount=m1"
#playlist for commercial jingles
ads = playlist("~/ads.pls")
args = arg.split(uri)
#main playlist source
pl = list.assoc("playlist", args)
pl = if pl == "" then
        log("playlist is not set. using default")
        "/home/alius/pl.pls"
     else
        pl
end

#set play mode
s = if args["shuffle"] == "1" then
        playlist(reload=300, pl)
    else
        playlist(mode="normal", reload=300, pl)
end
#The output
m = list.assoc("mount",args)
m = if m == "" then
        log("mount is not set. using default")
        "default_mount"
    else
        m
end
#if ads are selected, include them in playback with the proportion 1:4
s = if args["ads"] == "1" then
                random(weights=[1,4], [ads, s])
        else
                s
        end
output = out(mount="#{m}",s)
log(uri)
#Â Register output is the list of sources
  dyn_sources :=
      list.append( [(uri,output)],
                    !dyn_sources )

  "Done!"
end

On Sat, Mar 19, 2011 at 9:37 PM, Boris Zhidkov <[email protected]>wrote:

> Hi!
>
> I've solved an issue I'd wrote below.
>
> def create_playlist(uri) =
> #uri = "?playlist=pl.m3u&mount=m1";
> args = url.split(uri)
> #The playlist source
> pl  = list.assoc("playlist", snd(args))
> if (pl=="") then
>        pl = "~/pl.pls"
> end
>  s = playlist(pl)
>  # The output
> m = list.assoc("mount",snd(args))
> if(m=="") then
>        m="defaultmount"
> end
> log(m)
>  output = out(mount="#{m}",s)
>
> Now I'm working with correct playlist removing.
>
> Thanks,
> Boris
>
> On 3/19/11, Boris Zhidkov <[email protected]> wrote:
> > Hi, Romain.
> >
> > After a week of rest, I returned to work with liquidsoap.
> > I've got a trouble with url.split.
> > AFAIU, it returns list, but when I try to use it like this:
> > def create_playlist(uri) =
> > args = url.split(uri)
> > pl = args["playlist"]
> > s = playlist(pl)
> >
> > or like that:
> > args = url.split(uri)
> > #Â The playlist source
> > pl = list.nth(args,0)
> >
> > I get errors.
> >
> > Can you explain how to work with it, please?
> >
> > Thanks,
> > Boris
> >
> > --
> > -------------------------------------------
> > WBR, Boris Zhidkov
> >
>
>
> --
> -------------------------------------------
> WBR, Boris Zhidkov
>



-- 
-------------------------------------------
WBR, Boris Zhidkov
------------------------------------------------------------------------------
Colocation vs. Managed Hosting
A question and answer guide to determining the best fit
for your organization - today and in the future.
http://p.sf.net/sfu/internap-sfd2d
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users

Reply via email to