Merge with acafed2ba9601bc6900cfcf957fc1bdf24aefa05
authorymh <ymh.work@gmail.com>
Thu, 07 Jun 2012 18:44:08 +0200
changeset 657 e161a1664cac
parent 656 9d42c1d77bcd (current diff)
parent 655 acafed2ba960 (diff)
child 658 5f22830ffcd7
Merge with acafed2ba9601bc6900cfcf957fc1bdf24aefa05
--- a/src/ldt/ldt/api/ldt/handlers.py	Thu Jun 07 16:47:41 2012 +0200
+++ b/src/ldt/ldt/api/ldt/handlers.py	Thu Jun 07 18:44:08 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 16:47:41 2012 +0200
+++ b/src/ldt/ldt/ldt_utils/utils.py	Thu Jun 07 18:44:08 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)