--- a/src/ldt/ldt/api/ldt/handlers.py Thu Jun 07 11:43:48 2012 +0200
+++ b/src/ldt/ldt/api/ldt/handlers.py Thu Jun 07 18:18:05 2012 +0200
@@ -90,6 +90,11 @@
"end": 2100000,\
"content": {\
"data": "new scar annot"\
+ "audio": {\
+ "mimetype": "audio/mp3",\
+ "src": "mic",\
+ "href": "rtmp://media.iri.centrepompidou.fr/ddc_micro_record/r_20120606190143793"\
+ }\
},\
"tags": [ "json","dude" ]\
}\
@@ -194,7 +199,15 @@
for a in new_annotations:
dur = str(a['end'] - a['begin'])
begin = str(a['begin'])
- type_id, new_id = adder.add(a['media'], a['type'], a['type_title'], a['content']['data'], '', a['tags'], begin, dur, author, date)
+ # We test if the annotation has audio node
+ audio_src = ""
+ audio_href = ""
+ if a['content'].has_key('audio') :
+ if a['content']['audio'].has_key('src') :
+ audio_src = a['content']['audio']['src']
+ if a['content']['audio'].has_key('href') :
+ audio_href = a['content']['audio']['href']
+ type_id, new_id = adder.add(a['media'], a['type'], a['type_title'], a['content']['data'], '', a['tags'], begin, dur, author, date, None, "2194379", audio_src, audio_href)
if not new_id:
protect_models()
return rc.BAD_REQUEST
@@ -206,6 +219,8 @@
# We update the ids
a['type'] = type_id
a['id'] = new_id
+ if not a['content'].has_key('audio') :
+ a['content']['audio'] = {'src':audio_src, 'href':audio_href}
# We save if there were added annotation
if len(new_annotations)>0 :
--- a/src/ldt/ldt/ldt_utils/utils.py Thu Jun 07 11:43:48 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/utils.py Thu Jun 07 18:18:05 2012 +0200
@@ -171,7 +171,7 @@
self.to_add = True
# add( a['media'], a['type'], a['type_title, a[data], '', a['tags'], begin, dur, author, date)
- def add(self, media, cutting_id, cutting_title, title, text, tags_list, begin, dur, author, date, view_id="0", color="2194379"):
+ def add(self, media, cutting_id, cutting_title, title, text, tags_list, begin, dur, author, date, view_id="0", color="2194379", audio_scr="", audio_href=""):
"""
Add an annotation to a project. begin and dur must be strings. Default color is yellow.
"""
@@ -262,7 +262,8 @@
title_node = lxml.etree.SubElement(element, 'title')
title_node.text = title
audio = lxml.etree.SubElement(element, 'audio')
- audio.set('source', '')
+ audio.set('source', audio_scr)
+ audio.text = audio_href
tags = lxml.etree.SubElement(element, 'tags')
polemics = self.get_polemic_syntax(title)