Getting (reading) metadata from live stream #3230
Replies: 4 comments 3 replies
-
You should use |
Beta Was this translation helpful? Give feedback.
-
So I now have it working, but there is a problem whereby I need to url.encode the data, I though I could use url.encode but it is giving me an error: Updated code:
Gives this error:
I'm assuming I am not using url.encode correctly? Thanks. |
Beta Was this translation helpful? Give feedback.
-
@gavin2812: Just gave it a quick spin here, using a = mksafe(playlist("~/Musik/Electronic.m3u"))
def print_meta(m)
artist = url.encode(m["artist"])
title = url.encode(m["title"])
print("#{artist} - #{title}")
ignore(process.run("curl http://localhost:8000/api?artist=#{artist}'&'title=#{title}"))
end
a.on_metadata(print_meta)
output(a) Works fine:
(404 error since I actually got nothing there—just wanted to see the GETs produced by LS) Note the Also, be aware that with live streams, you often get
If you run into that situation, maybe part of my code can help—adapt as needed: nowplaying = ref("")
def update_nowplaying(m)
# For diagnostics: Show all metadata
#log("META: #{metadata.cover.remove(m)}")
# If we get an empty artist, assume a stream
# and try to split the title into artist and title.
nowplaying.set(shorten(m["title"]) ^ "\n" ^ shorten(m["artist"]))
if string.length(m["artist"]) <= 0 then
if string.contains(substring=" - ", m["title"]) then
let (a, t) = string.split.first(separator=" - ", m["title"])
nowplaying.set(shorten(t) ^ "\n" ^ shorten(a))
end
end
...
end You can neglect |
Beta Was this translation helpful? Give feedback.
-
Thanks all, I ended up going what would seem a very long way round and the only one I could get to work was the base64.encode function, so this also achieved what I was looking for, so used this instead... Thanks for the replies. |
Beta Was this translation helpful? Give feedback.
-
Hello,
I have seen quite a few examples in the documentation about setting/updating the metadata using insert_metadata but I can't immediately find anything for reading the metadata from a live stream and was wondering if anyone could help...
This is what I'm thinking as an example, I know code this does not work, but what I'm trying to do is to get the metadata (artist - title) every 20 seconds and output it via print (every 20 seconds):
Could someone help with this? I'm just trying to print out the artist - title of the live stream.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions