| author | verrierj |
| Mon, 19 Sep 2011 10:32:44 +0200 | |
| changeset 179 | 03007a7c14ca |
| parent 176 | a88714473302 |
| child 182 | b7add86c2772 |
| permissions | -rw-r--r-- |
| 114 | 1 |
from copy import deepcopy |
| 19 | 2 |
from django.conf import settings |
| 176 | 3 |
from ldt.indexation import get_searcher, get_query_parser, get_results_list |
| 19 | 4 |
import datetime |
| 0 | 5 |
import django.core.urlresolvers |
| 19 | 6 |
import lxml.etree |
| 0 | 7 |
import urllib |
| 19 | 8 |
import uuid |
| 0 | 9 |
|
10 |
__BOOLEAN_DICT = { |
|
11 |
'false':False, |
|
12 |
'true':True, |
|
13 |
'0':False, |
|
14 |
'1':True, |
|
15 |
't': True, |
|
16 |
'f':False |
|
17 |
} |
|
18 |
||
| 19 | 19 |
def reduce_text_node(element_node, xpath_str=None): |
20 |
node_list = [] |
|
21 |
if xpath_str is not None: |
|
22 |
node_list = element_node.xpath(xpath_str, smart_strings=False) |
|
23 |
else: |
|
24 |
node_list = [element_node.text] |
|
| 63 | 25 |
return reduce(lambda t, s: t + s, node_list , "") |
| 0 | 26 |
|
27 |
def boolean_convert(bool): |
|
28 |
if bool is None: |
|
29 |
return False |
|
30 |
if bool is True or bool is False: |
|
31 |
return bool |
|
32 |
key = str(bool).lower() |
|
33 |
return __BOOLEAN_DICT.get(key, False) |
|
34 |
||
35 |
def generate_uuid(): |
|
36 |
return unicode(uuid.uuid1()) |
|
37 |
||
38 |
class LdtSearch(object): |
|
39 |
||
40 |
def query(self, field, query): |
|
| 95 | 41 |
indexSearcher = get_searcher() |
| 176 | 42 |
hits = get_results_list(field, query) |
| 0 | 43 |
|
44 |
res = [] |
|
| 176 | 45 |
for hit in hits: |
| 0 | 46 |
doc = indexSearcher.doc(hit.doc) |
|
97
10f69a5bd9e1
correct propagation of project id on indexation
ymh <ymh.work@gmail.com>
parents:
95
diff
changeset
|
47 |
res.append({"iri_id":doc.get("iri_id"), "ensemble_id":doc.get("ensemble_id"), "decoupage_id":doc.get("decoupage_id"), "element_id":doc.get("element_id"), "project_id":doc.get("project_id")}) |
| 0 | 48 |
indexSearcher.close() |
49 |
return res |
|
50 |
||
|
167
fe00e7302efe
Change class and functions names to follow PEP8 formatting standards
verrierj
parents:
134
diff
changeset
|
51 |
def query_all(self, query): |
| 0 | 52 |
return self.query("all", query) |
| 176 | 53 |
|
| 0 | 54 |
|
55 |
class LdtUtils(object): |
|
56 |
||
|
167
fe00e7302efe
Change class and functions names to follow PEP8 formatting standards
verrierj
parents:
134
diff
changeset
|
57 |
def generate_ldt(self, contentList, title=u"", author=u"IRI Web", web_url=u"", startSegment=None, projects=None): |
| 0 | 58 |
|
59 |
iri = lxml.etree.Element(u'iri') |
|
60 |
doc = lxml.etree.ElementTree(iri) |
|
61 |
||
62 |
project = lxml.etree.SubElement(iri, u'project') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
63 |
project.set(u"id", unicode(str(uuid.uuid1()))) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
64 |
project.set(u"title", unicode(title)) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
65 |
project.set(u"user", author) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
66 |
project.set(u"abstract", u"") |
| 0 | 67 |
|
68 |
medias = lxml.etree.SubElement(iri, u"medias") |
|
69 |
for content in contentList: |
|
70 |
videopath = unicode(settings.STREAM_URL) |
|
| 115 | 71 |
if content.videopath != None : |
| 0 | 72 |
videopath = unicode(content.videopath) |
73 |
media = lxml.etree.SubElement(medias, "media") |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
74 |
media.set(u"id", content.iri_id) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
75 |
media.set(u"src", content.iri_url(web_url)) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
76 |
media.set(u"video", videopath) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
77 |
media.set(u"pict", u"") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
78 |
media.set(u"extra", u"") |
| 0 | 79 |
|
| 114 | 80 |
if projects is None: |
81 |
projects = [] |
|
82 |
annotations_nodes = {} |
|
| 115 | 83 |
for project in projects: |
| 114 | 84 |
ldtdoc = lxml.etree.fromstring(project.ldt.encode("utf-8")) |
85 |
res = ldtdoc.xpath("/iri/annotations/content") |
|
86 |
||
87 |
for content in res: |
|
88 |
contentid = content.get("id") |
|
89 |
if annotations_nodes.has_key(contentid): |
|
90 |
contentnode = annotations_nodes[contentid] |
|
91 |
else: |
|
92 |
contentnode = {"id":contentid, "ensembles":[]} |
|
93 |
annotations_nodes[contentid] = contentnode |
|
94 |
for ens in content: |
|
95 |
if ens.tag.endswith("ensemble"): |
|
96 |
contentnode["ensembles"].append(deepcopy(ens)) |
|
97 |
||
98 |
annotations = lxml.etree.SubElement(iri, "annotations") |
|
99 |
if len(annotations_nodes) > 0: |
|
100 |
for content in contentList: |
|
101 |
if content.iri_id in annotations_nodes: |
|
| 115 | 102 |
contentnode = annotations_nodes[content.iri_id] |
| 114 | 103 |
if contentnode is not None: |
| 115 | 104 |
content_node = lxml.etree.SubElement(annotations, "content") |
105 |
content_node.set("id", contentnode["id"]) |
|
106 |
content_node.text = u"" |
|
107 |
for ens in contentnode["ensembles"]: |
|
108 |
content_node.append(ens) |
|
| 0 | 109 |
|
110 |
||
111 |
displays = lxml.etree.SubElement(iri, "displays") |
|
112 |
if len(contentList) > 0: |
|
113 |
display = lxml.etree.SubElement(displays, "display") |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
114 |
display.set(u"id", u"0") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
115 |
display.set(u"title", u"generated") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
116 |
display.set(u"idsel", contentList[0].iri_id) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
117 |
display.set(u"tc", u"0") |
| 0 | 118 |
for content in contentList: |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
119 |
contentd = lxml.etree.SubElement(display, "content") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
120 |
contentd.set(u"id", content.iri_id) |
| 0 | 121 |
filepath = urllib.urlopen(content.iri_url()) |
122 |
||
123 |
udoc = lxml.etree.parse(filepath) |
|
124 |
res = udoc.xpath("/iri/body/ensembles/ensemble/decoupage") |
|
125 |
for decoupagenode in res: |
|
126 |
decoupage_id = decoupagenode.get(u"id") |
|
127 |
ensemble_id = decoupagenode.getparent().get(u"id") |
|
128 |
decoupage_id = decoupagenode.get(u"id") |
|
129 |
ensemble_id = decoupagenode.getparent().get(u"id") |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
130 |
decoupage = lxml.etree.SubElement(contentd, "decoupage") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
131 |
decoupage.set(u"id", decoupage_id) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
132 |
decoupage.set(u"idens", ensemble_id) |
| 0 | 133 |
if startSegment is not None: |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
134 |
activeSegment = lxml.etree.SubElement(display, "activeSegment") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
135 |
idas = lxml.etree.SubElement(activeSegment, "id") |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
136 |
idas.set(u"idctt", startSegment["idcontent"]) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
137 |
idas.set(u"idens" , startSegment["idgroup"]) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
138 |
idas.set(u"idcut", startSegment["idcutting"]) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
139 |
idas.set(u"idseg", startSegment["idsegment"]) |
| 0 | 140 |
|
| 19 | 141 |
lxml.etree.SubElement(iri, "edits") |
|
112
9886ab183b09
add permalink + corrcetion config with static and media path. update urls
ymh <ymh.work@gmail.com>
parents:
97
diff
changeset
|
142 |
return doc |
| 0 | 143 |
|
144 |
||
|
167
fe00e7302efe
Change class and functions names to follow PEP8 formatting standards
verrierj
parents:
134
diff
changeset
|
145 |
def generate_init(self, url, method, search=None): |
| 0 | 146 |
|
147 |
iri = lxml.etree.Element('iri') |
|
148 |
||
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
149 |
elementFiles = lxml.etree.SubElement(iri, 'files') |
| 0 | 150 |
elementInit = lxml.etree.SubElement(elementFiles, 'init') |
151 |
elementfile = lxml.etree.SubElement(elementInit, 'file') |
|
152 |
||
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
153 |
elementfile.set('src', settings.WEB_URL + django.core.urlresolvers.reverse(method, args=url)) |
| 0 | 154 |
if(search): |
|
69
784ebba76424
enhance new media/content creation with url : external stream, local stream using STREAM_URL or youtube http.
cavaliet
parents:
63
diff
changeset
|
155 |
elementfile.set("segsel", settings.WEB_URL + django.core.urlresolvers.reverse(search, args=url)) |
| 0 | 156 |
|
| 19 | 157 |
lxml.etree.SubElement(elementFiles, 'recent') |
158 |
lxml.etree.SubElement(elementFiles, 'library') |
|
| 0 | 159 |
|
160 |
return iri |
|
161 |
||
162 |
||
163 |
||
164 |
def create_ldt(project, user): |
|
165 |
"""create xml""" |
|
166 |
||
167 |
||
168 |
contentList = project.contents.all() |
|
169 |
||
170 |
# create a dom |
|
171 |
iri = lxml.etree.Element('iri') |
|
172 |
doc = lxml.etree.ElementTree(iri) |
|
173 |
||
174 |
#node project |
|
175 |
elementProject = lxml.etree.SubElement(iri, 'project') |
|
176 |
||
| 179 | 177 |
elementProject.set('abstract', project.description) |
| 0 | 178 |
elementProject.set('title', project.title) |
179 |
elementProject.set('user', user.username) |
|
180 |
elementProject.set('id', project.ldt_id) |
|
181 |
||
182 |
#node medias |
|
183 |
elementMedias = lxml.etree.SubElement(iri, 'medias') |
|
184 |
||
185 |
idsel = None |
|
186 |
for content in contentList: |
|
187 |
if not idsel: |
|
188 |
idsel = content.iri_id |
|
189 |
elementMedia = lxml.etree.SubElement(elementMedias, 'media') |
|
190 |
elementMedia.set('id', content.iri_id) |
|
191 |
elementMedia.set('src', content.iri_url()) |
|
|
69
784ebba76424
enhance new media/content creation with url : external stream, local stream using STREAM_URL or youtube http.
cavaliet
parents:
63
diff
changeset
|
192 |
|
|
784ebba76424
enhance new media/content creation with url : external stream, local stream using STREAM_URL or youtube http.
cavaliet
parents:
63
diff
changeset
|
193 |
if content.videopath != None : |
| 0 | 194 |
elementMedia.set('video', content.videopath) |
195 |
else: |
|
196 |
elementMedia.set('video', settings.STREAM_URL) |
|
197 |
elementMedia.set('pict', "") |
|
198 |
elementMedia.set('extra', "") |
|
199 |
||
200 |
if not idsel: |
|
201 |
idsel = "" |
|
202 |
||
203 |
#node annotations |
|
| 19 | 204 |
lxml.etree.SubElement(iri, 'annotations') |
| 0 | 205 |
|
206 |
#node displays |
|
207 |
elementDisplays = lxml.etree.SubElement(iri, 'displays') |
|
208 |
elementDisplay = lxml.etree.SubElement(elementDisplays, 'display') |
|
209 |
elementDisplay.set('id', '0') |
|
210 |
elementDisplay.set('title', 'Init view') |
|
211 |
elementDisplay.set('idsel', idsel) |
|
212 |
elementDisplay.set('tc', '0') |
|
213 |
elementDisplay.set('zoom', '0') |
|
214 |
elementDisplay.set('scroll', '0') |
|
215 |
elementDisplay.set('infoBAB', '') |
|
216 |
||
217 |
||
218 |
#node content |
|
219 |
for content in contentList: |
|
220 |
elementContent = lxml.etree.SubElement(elementDisplay, 'content') |
|
221 |
elementContent.set('id', content.iri_id) |
|
222 |
||
223 |
if not 'http' in content.iriurl: |
|
224 |
#eg: "iiiielizabethrosse/ENMI08-III_elizabethrosse.iri" |
|
225 |
url = content.iri_url() |
|
226 |
else: |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
227 |
url = content.iriurl |
| 0 | 228 |
file = urllib.urlopen(url) |
229 |
doc = lxml.etree.parse(file) |
|
230 |
res = doc.xpath("/iri/body/ensembles/ensemble/decoupage") |
|
231 |
||
232 |
#node decoupage |
|
233 |
for decoupagenode in res: |
|
234 |
decoupage_id = decoupagenode.get(u"id") |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
235 |
parent = decoupagenode.getparent() |
| 0 | 236 |
ensemble_id = parent.get(u"id") |
237 |
elementDecoupage = lxml.etree.SubElement(elementContent, 'decoupage') |
|
238 |
elementDecoupage.set('idens', ensemble_id) |
|
239 |
elementDecoupage.set('id', decoupage_id) |
|
240 |
||
241 |
#node edits |
|
| 19 | 242 |
lxml.etree.SubElement(iri, 'edits') |
| 0 | 243 |
|
244 |
#write dom in Project.ldt |
|
245 |
project.ldt = lxml.etree.tostring(iri, pretty_print=True) |
|
246 |
||
247 |
#save Project |
|
248 |
project.save() |
|
249 |
return project |
|
250 |
||
251 |
||
252 |
def copy_ldt(project, new_project, user): |
|
253 |
new_project.ldt_id = str(uuid.uuid1()) |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
254 |
new_project.created_by = user.username |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
255 |
new_project.changed_by = user.username |
| 0 | 256 |
new_project.state = 1 |
257 |
|
|
258 |
|
|
259 |
"""create xml""" |
|
260 |
||
261 |
ldt = lxml.etree.fromstring(project.ldt.encode("utf-8")) |
|
262 |
res = ldt.xpath("/iri/project") |
|
263 |
for elementProject in res: |
|
| 179 | 264 |
elementProject.set('abstract', project.description) |
| 0 | 265 |
elementProject.set('title', new_project.title) |
266 |
elementProject.set('user', user.username) |
|
267 |
elementProject.set('id', new_project.ldt_id) |
|
268 |
||
269 |
new_project.ldt = lxml.etree.tostring(ldt, pretty_print=True) |
|
270 |
||
271 |
#save Project |
|
272 |
new_project.save() |
|
273 |
return new_project |
|
274 |
||
275 |
def create_empty_iri(file, content, username): |
|
276 |
||
277 |
iri = lxml.etree.Element('iri') |
|
278 |
doc = lxml.etree.ElementTree(iri) |
|
279 |
||
280 |
head = lxml.etree.SubElement(iri, 'head') |
|
281 |
meta_id = lxml.etree.SubElement(head, 'meta') |
|
282 |
meta_id.set(u'name', u'id') |
|
283 |
meta_id.set(u'content', unicode(content.iri_id)) |
|
284 |
meta_title = lxml.etree.SubElement(head, 'meta') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
285 |
meta_title.set(u'name', u'title') |
| 0 | 286 |
meta_title.set(u'content', unicode(content.title)) |
287 |
meta_abstract = lxml.etree.SubElement(head, 'meta') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
288 |
meta_abstract.set(u'name', u'abstract') |
| 0 | 289 |
meta_abstract.set(u'content', unicode(content.description)) |
290 |
meta_author = lxml.etree.SubElement(head, 'meta') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
291 |
meta_author.set(u'name', u'author') |
| 0 | 292 |
meta_author.set(u'content', unicode(username)) |
293 |
meta_contributor = lxml.etree.SubElement(head, 'meta') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
294 |
meta_contributor.set(u'name', u'contributor') |
| 0 | 295 |
meta_contributor.set(u'content', unicode(username)) |
296 |
meta_date = lxml.etree.SubElement(head, 'meta') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
297 |
meta_date.set(u'name', u'date') |
| 0 | 298 |
meta_date.set(u'content', unicode(datetime.date.today().isoformat())) |
299 |
meta_copyright = lxml.etree.SubElement(head, 'meta') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
300 |
meta_copyright.set(u'name', u'copyright') |
| 0 | 301 |
meta_copyright.set(u'content', u'IRI') |
302 |
meta_type = lxml.etree.SubElement(head, 'meta') |
|
303 |
meta_type.set(u'name', u'type') |
|
304 |
meta_type.set(u'content', u'video') |
|
305 |
||
306 |
body = lxml.etree.SubElement(iri, 'body') |
|
| 19 | 307 |
lxml.etree.SubElement(body, 'ensembles') |
308 |
lxml.etree.SubElement(body, 'links') |
|
| 0 | 309 |
|
310 |
medias = lxml.etree.SubElement(body, 'medias') |
|
311 |
||
312 |
media_video = lxml.etree.SubElement(medias, 'media') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
313 |
media_video.set(u'id', u'video') |
| 0 | 314 |
video = lxml.etree.SubElement(media_video, 'video') |
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
315 |
video.set(u'src', unicode(content.stream_src)) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
316 |
video.set(u'id', unicode(content.iri_id)) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
317 |
video.set(u'dur', unicode(content.duration)) |
|
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
318 |
video.set(u'begin', u'0') |
| 0 | 319 |
|
320 |
media_tool = lxml.etree.SubElement(medias, 'media') |
|
|
13
97ab7b3191cf
add api to update project, uses psiton
ymh <ymh.work@gmail.com>
parents:
0
diff
changeset
|
321 |
media_tool.set(u'id', u'tool') |
| 19 | 322 |
lxml.etree.SubElement(media_tool, 'tool') |
| 0 | 323 |
|
| 19 | 324 |
lxml.etree.SubElement(body, 'display') |
| 0 | 325 |
|
326 |
doc.write(file, pretty_print=True) |
|
327 |
||
328 |
||
329 |
def update_iri(filepath, content, username): |
|
330 |
||
331 |
# open xml |
|
332 |
doc = lxml.etree.parse(filepath) |
|
333 |
||
334 |
res = doc.xpath("/iri/head/meta") |
|
335 |
# update meta |
|
336 |
||
337 |
for meta_node in res: |
|
338 |
meta_name = meta_node.get("name") |
|
339 |
content_attr = None |
|
340 |
if meta_name == u'id': |
|
341 |
content_attr = unicode(content.iri_id) |
|
342 |
elif meta_name == u'title': |
|
343 |
content_attr = unicode(content.title) |
|
344 |
elif meta_name == u'abstract': |
|
345 |
content_attr = unicode(content.description) |
|
346 |
elif meta_name == u'contributor': |
|
347 |
content_attr = unicode(username) |
|
348 |
elif meta_name == u"date": |
|
349 |
content_attr = unicode(datetime.date.today().isoformat()) |
|
350 |
if content_attr is not None: |
|
351 |
meta_node.set(u"content", content_attr) |
|
352 |
||
353 |
res = doc.xpath("/iri/body/medias/media[@id='video']/video") |
|
354 |
||
355 |
if len(res) > 0: |
|
356 |
video_node = res[0] |
|
357 |
video_node.set(u'src', unicode(content.stream_src)) |
|
358 |
video_node.set(u'dur', unicode(content.duration)) |
|
359 |
video_node.set(u'id', unicode(content.iri_id)) |
|
360 |
# update video |
|
361 |
||
362 |
f = open(filepath, "w") |
|
363 |
try: |
|
364 |
doc.write(f, encoding="UTF-8", pretty_print=True, xml_declaration=True) |
|
365 |
finally: |
|
366 |
f.close() |