Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/liquidsoap
- pathToSocket="/home/radio/musicas/sckt";
- set("server.socket",true); #use a socket
- set("server.socket.path",pathToSocket); #the path to a socket
- set("server.socket.permissions",511) #the permission for the file, here is the equivalent to 777 .Ideally you would use a more restrictive permission
- set("harbor.bind_addr","0.0.0.0")
- set("server.telnet", true)
- ###########################################################
- ###########################################################
- # First, we create a list referencing the dynamic sources:
- dyn_sources = ref []
- # This is our icecast output.
- # It is a partial application: the source needs to be given!
- out = output.icecast(%mp3(bitrate=64, samplerate=44100, id3v2=true, stereo=false),
- host = "localhost",
- port = 8085,
- password = "_____",
- mount = "pgplaylist",
- fallible = true)
- # Now we write a function to create
- # a playlist source and output it.
- def create_playlist(uri) =
- # The playlist source
- s = mean(playlist.once(uri))
- # The output
- output = out(s)
- # We register both source and output
- # in the list of sources
- dyn_sources :=
- list.append( [(uri,s),(uri,output)],
- !dyn_sources )
- "Done!"
- end
- # And a function to destroy a dynamic source
- def destroy_playlist(uri) =
- # We need to find the source in the list,
- # remove it and destroy it. Currently, the language
- # lacks some nice operators for that so we do it
- # the functional way
- # This function is executed on every item in the list
- # of dynamic sources
- def parse_list(ret, current_element) =
- # ret is of the form: (matching_sources, remaining_sources)
- # We extract those two:
- matching_sources = fst(ret)
- remaining_sources = snd(ret)
- # current_element is of the form: ("uri", source) so
- # we check the first element
- current_uri = fst(current_element)
- if current_uri == uri then
- # In this case, we add the source to the list of
- # matched sources
- (list.append( [snd(current_element)],
- matching_sources),
- remaining_sources)
- else
- # In this case, we put the element in the list of remaining
- # sources
- (matching_sources,
- list.append([current_element],
- remaining_sources))
- end
- end
- # Now we execute the function:
- result = list.fold(parse_list, ([], []), !dyn_sources)
- matching_sources = fst(result)
- remaining_sources = snd(result)
- # We store the remaining sources in dyn_sources
- dyn_sources := remaining_sources
- # If no source matched, we return an error
- if list.length(matching_sources) == 0 then
- "Error: no matching sources!"
- else
- # We stop all sources
- list.iter(source.shutdown, matching_sources)
- # And return
- "Done!"
- end
- end
- # Now we register the telnet commands:
- server.register(namespace="dynamic_playlist",
- description="Start a new dynamic playlist.",
- usage="start <uri>",
- "start",
- create_playlist)
- server.register(namespace="dynamic_playlist",
- description="Stop a dynamic playlist.",
- usage="stop <uri>",
- "stop",
- destroy_playlist)
- ###########################################################
- ###########################################################
- # Some code...
- vinhetas = mean(mksafe(playlist("/home/radio/vinhetas/vinhetas.txt")))
- musicas = mean(mksafe(playlist(mode="normal", "/home/radio/musicas/playlist.txt")))
- files = rotate(weights=[1,7], [vinhetas, musicas])
- # This defines a source waiting on mount point
- # /test-harbor
- live = input.harbor("/",port=8080,password="_____",icy=true)
- pgplaylist = input.harbor("pgplaylist",port=8085,password="_____")
- # This is the final stream.
- # Uses the live source as soon as available,
- # and don't wait for an end of track, since
- # we don't want to cut the beginning of the live
- # stream.
- #
- # You may insert a jingle transition here...
- radio = fallback(track_sensitive=false,
- [live,pgplaylist,files])
- # A function applied to each metadata chunk
- def append_title(m) =
- # Grab the current title
- title = m["title"]
- # Return a new title metadata
- [("title","#{title} - #RadioCollegeRock (em testes)")]
- end
- # Apply map_metadata to s using append_title
- #radio = map_metadata(append_title, radio)
- output.icecast(%mp3(bitrate=64, samplerate=44100, id3v2=true, stereo=false),
- host = "localhost",
- port = 8000,
- password = "_____",
- icy_metadata = "true",
- url = "http://facebook.com/teucollegerock",
- description = "#RadioCollegeRock (em testes)",
- mount = "radiocollegerock.mp3", radio)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement