Created
August 21, 2014 20:45
-
-
Save naxxfish/d9a38dcd8e6ca7364f11 to your computer and use it in GitHub Desktop.
This Liqudisoap script allows you to stream from Mixxx and get some metadata out of it
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
set("log.stdout",true) | |
set("harbor.bind_addr","127.0.0.1") | |
meta = ref [] | |
s = input.harbor("mixxx",port=8000,password="derp") | |
s = mksafe(s) | |
# Update current metadata | |
# converted in UTF8 | |
def update_meta(m) = | |
m = metadata.export(m) | |
recode = string.recode(out_enc="UTF-8") | |
def f(x) = | |
(recode(fst(x)),recode(snd(x))) | |
end | |
meta := list.map(f,m) | |
end | |
# Apply update_metadata | |
# every time we see a new | |
# metadata | |
s = on_metadata(update_meta,s) | |
# Return the json content | |
# of meta | |
def get_meta(~method,~protocol,~data,~headers,uri) = | |
m = !meta | |
http_response( | |
protocol=protocol, | |
code=200, | |
headers=[("Content-Type","application/json; charset=utf-8")], | |
data=json_of(m) | |
) | |
end | |
output.dummy(s) | |
# Register get_meta at port 7000 | |
harbor.http.register( port=7000, "/getmeta", get_meta) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
An issue in your script, cann you help me?
Mär 28 16:11:49 userver systemd[1]: Starting LSB: Starts the liquidsoap daemon...
Mär 28 16:11:49 userver liquidsoap[3524]: Starting liquidsoap channels: neu.liq At line 38, char 54:
Mär 28 16:11:49 userver liquidsoap[3524]: this value has type
Mär 28 16:11:49 userver liquidsoap[3524]: (protocol:,data:,headers:,,method:)-> (inferred at line 26 char 1 - line 34 char 3)
Mär 28 16:11:49 userver liquidsoap[3524]: but it should be a subtype of
Mär 28 16:11:49 userver liquidsoap[3524]: (protocol:,data:,headers:,)->string
Mär 28 16:11:49 userver liquidsoap[3524]: OK