Le 08/11/2011 16:46, Martin Hamant a écrit :
Le 08/11/2011 12:19, Martin Hamant a écrit :
It works like expected, I'm going forward to the next step !
So... I have something that almost works !
A question: I am using insert_metadata to insert a "title" field in
the stream. But I would also need to remove it.
I walked in the documentation, and I've found that map_metadata() has
a strip option.
Does it means I have to convert my code to map_metadata() instead of
insert_metadata() ? Can you give me a direction to achieve this ?
"Still from documentation, I can read "The effect of |map_metadata| by
default is to update the metadata with the returned values. Hence in
the function |append_title| defined in the code above returns a new
metadata for the label |title| and the other metadata remain
untouched. You can change this by using the |update| option, and you
can also remove any metadata (even empty one) using the |strip| option."
about the part "and you can also remove any metadata (even empty one)
using the |strip| option." - in map_metadata() doc I can read for
'strip' : "Completely remove empty metadata. Operates on both empty
values and empty metadata chunk."
Does it means that "the content of the given label (field) should be
empty for the metadata to be deleted" ?
To feed the question considering the following snip:
# A function to update metadata
def update_meta() =
url = get_url(output)
print(url)
if url != "" then
data = http.get(url)
m = [("title", snd(data))]
print(m)
if m != !latest_meta then
latest_meta := m
insert(m)
print("new metadata !")
end
end
# restart in X sec.
3.
end
the "else" iteration of the "if url not null" should return the same
type (unit)
Also - I have not tried but - as map_metadata() return a new source, I
would have to call it *before* I create the output ?
(But I can't, because I need the output in my update_meta() :D)
With insert_metadata, it is smooth because I can attach the insertion
hook to the source before output creation.
(my current code)
# Attach metadata insertion hooks
# s0 is the input source
x = insert_metadata(s0)
insert = fst(x)
s = snd(x)
# output creation
output = out(..... ,s)
# metadata update function
def update_meta() =
... (see above) ...
end
add_timeout(0., update_meta)
Thanks !
------------------------------------------------------------------------------
RSA(R) Conference 2012
Save $700 by Nov 18
Register now
http://p.sf.net/sfu/rsa-sfdev2dev1
_______________________________________________
Savonet-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/savonet-users