7 media : { |
7 media : { |
8 serialized_name : "medias", |
8 serialized_name : "medias", |
9 model_name : "media", |
9 model_name : "media", |
10 deserializer : function(_data, _source) { |
10 deserializer : function(_data, _source) { |
11 var _res = new IriSP.Model.Media(_data.id, _source); |
11 var _res = new IriSP.Model.Media(_data.id, _source); |
12 _res.url = _data.href; |
12 _res.video = _data.url; |
13 _res.title = _data.meta.title; |
13 _res.title = _data.meta.title; |
14 _res.description = _data.meta.synopsis; |
14 _res.description = _data.meta.synopsis; |
15 _res.setDuration(_data.meta.duration); |
15 _res.setDuration(_data.meta.duration); |
16 return _res; |
16 return _res; |
17 }, |
17 }, |
18 serializer : function(_data, _source) { |
18 serializer : function(_data, _source) { |
19 return { |
19 return { |
20 id : _source.unNamespace(_data.id), |
20 id : _source.unNamespace(_data.id), |
21 url : _data.url, |
21 url : _data.video, |
22 meta : { |
22 meta : { |
23 title : _data.title, |
23 title : _data.title, |
24 synopsis : _data.description, |
24 synopsis : _data.description, |
25 duration : _data.duration.milliseconds |
25 duration : _data.duration.milliseconds |
26 } |
26 } |
95 .replace(/[úùûü]/g,'u') |
95 .replace(/[úùûü]/g,'u') |
96 .replace(/ÿ/g,'y') |
96 .replace(/ÿ/g,'y') |
97 .replace(/[^A-Za-z0-9_]/g,''), |
97 .replace(/[^A-Za-z0-9_]/g,''), |
98 _tag = new IriSP.Model.Tag(_id, _source); |
98 _tag = new IriSP.Model.Tag(_id, _source); |
99 _tag.title = _t; |
99 _tag.title = _t; |
100 _source.contents.tag.addElement(_tag); |
100 _source.contents.tag.push(_tag); |
101 return _id; |
101 return _id; |
102 } |
102 } |
103 })); |
103 })); |
104 _res.setBegin(_data.begin); |
104 _res.setBegin(_data.begin); |
105 _res.setEnd(_data.end); |
105 _res.setEnd(_data.end); |
141 id : _nsls[_i], |
141 id : _nsls[_i], |
142 url : _source.directory.namespaces[_nsls[_i]] |
142 url : _source.directory.namespaces[_nsls[_i]] |
143 }) |
143 }) |
144 } |
144 } |
145 } |
145 } |
146 _source.each(function(_list, _typename) { |
146 _source.forEach(function(_list, _typename) { |
147 if (typeof _this.types[_typename] !== "undefined") { |
147 if (typeof _this.types[_typename] !== "undefined") { |
148 _res[_this.types[_typename].serialized_name] = _list.map(function(_el) { |
148 _res[_this.types[_typename].serialized_name] = _list.map(function(_el) { |
149 return _this.types[_typename].serializer(_el, _source); |
149 return _this.types[_typename].serializer(_el, _source); |
150 }); |
150 }); |
151 } |
151 } |
152 }); |
152 }); |
153 return _res; |
153 return _res; |
154 }, |
154 }, |
155 deSerialize : function(_data, _source) { |
155 deSerialize : function(_data, _source) { |
156 if (typeof _data.imports !== "undefined") { |
156 if (typeof _data.imports !== "undefined") { |
157 IriSP._(_data.imports).each(function(_import) { |
157 IriSP._(_data.imports).forEach(function(_import) { |
158 _source.directory.namespaces[_import.id] = _import.url; |
158 _source.directory.namespaces[_import.id] = _import.url; |
159 }) |
159 }) |
160 } |
160 } |
161 IriSP._(this.types).each(function(_type, _typename) { |
161 IriSP._(this.types).forEach(function(_type, _typename) { |
162 var _listdata = _data[_type.serialized_name]; |
162 var _listdata = _data[_type.serialized_name]; |
163 if (typeof _listdata !== "undefined") { |
163 if (typeof _listdata !== "undefined") { |
164 var _list = new IriSP.Model.List(_source.directory); |
164 var _list = new IriSP.Model.List(_source.directory); |
165 if (_listdata.hasOwnProperty("length")) { |
165 if (_listdata.hasOwnProperty("length")) { |
166 var _l = _listdata.length; |
166 var _l = _listdata.length; |
167 for (var _i = 0; _i < _l; _i++) { |
167 for (var _i = 0; _i < _l; _i++) { |
168 _list.addElement(_type.deserializer(_listdata[_i], _source)); |
168 _list.push(_type.deserializer(_listdata[_i], _source)); |
169 } |
169 } |
170 } else { |
170 } else { |
171 _list.addElement(_type.deserializer(_listdata, _source)); |
171 _list.push(_type.deserializer(_listdata, _source)); |
172 } |
172 } |
173 _source.addList(_typename, _list); |
173 _source.addList(_typename, _list); |
174 } |
174 } |
175 }); |
175 }); |
176 |
176 |
177 if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") { |
177 if (typeof _data.meta !== "undefined" && typeof _data.meta.main_media !== "undefined" && typeof _data.meta.main_media["id-ref"] !== "undefined") { |
178 _source.setCurrentMediaId(_data.meta.main_media["id-ref"]); |
178 _source.setCurrentMediaId(_data.meta.id); |
179 } |
179 } |
180 _source.setDefaultCurrentMedia(); |
180 _source.setDefaultCurrentMedia(); |
181 } |
181 } |
182 } |
182 } |