text stringlengths 0 828 |
|---|
if len(self.renditions) > 0: |
data['renditions'] = [] |
for r in self.renditions: |
data['renditions'].append(r.to_dict()) |
if len(self.metadata) > 0: |
data['customFields'] = {} |
for meta in self.metadata: |
data['customFields'][meta['key']] = meta['value'] |
[data.pop(key) for key in data.keys() if data[key] == None] |
return data" |
825,"def to_xml(self): |
# pylint: disable=R0912 |
"""""" |
Converts object into an XML string. |
"""""" |
xml = '' |
for asset in self.assets: |
xml += '<asset filename=""%s"" ' % \ |
os.path.basename(asset['filename']) |
xml += ' refid=""%(refid)s""' % asset |
xml += ' size=""%(size)s""' % asset |
xml += ' hash-code=""%s""' % asset['hash-code'] |
xml += ' type=""%(type)s""' % asset |
if asset.get('encoding-rate', None): |
xml += ' encoding-rate=""%s""' % asset['encoding-rate'] |
if asset.get('frame-width', None): |
xml += ' frame-width=""%s""' % asset['frame-width'] |
if asset.get('frame-height', None): |
xml += ' frame-height=""%s""' % asset['frame-height'] |
if asset.get('display-name', None): |
xml += ' display-name=""%s""' % asset['display-name'] |
if asset.get('encode-to', None): |
xml += ' encode-to=""%s""' % asset['encode-to'] |
if asset.get('encode-multiple', None): |
xml += ' encode-multiple=""%s""' % asset['encode-multiple'] |
if asset.get('h264-preserve-as-rendition', None): |
xml += ' h264-preserve-as-rendition=""%s""' % \ |
asset['h264-preserve-as-rendition'] |
if asset.get('h264-no-processing', None): |
xml += ' h264-no-processing=""%s""' % asset['h264-no-processing'] |
xml += ' />\n' |
xml += '<title name=""%(name)s"" refid=""%(referenceId)s"" active=""TRUE"" ' |
if self.start_date: |
xml += 'start-date=""%(start_date)s"" ' |
if self.end_date: |
xml += 'end-date=""%(end_date)s"" ' |
for asset in self.assets: |
if asset.get('encoding-rate', None) == None: |
choice = enums.AssetTypeEnum |
if asset.get('type', None) == choice.VIDEO_FULL: |
xml += 'video-full-refid=""%s"" ' % asset.get('refid') |
if asset.get('type', None) == choice.THUMBNAIL: |
xml += 'thumbnail-refid=""%s"" ' % asset.get('refid') |
if asset.get('type', None) == choice.VIDEO_STILL: |
xml += 'video-still-refid=""%s"" ' % asset.get('refid') |
if asset.get('type', None) == choice.FLV_BUMPER: |
xml += 'flash-prebumper-refid=""%s"" ' % asset.get('refid') |
xml += '>\n' |
if self.short_description: |
xml += '<short-description><![CDATA[%(shortDescription)s]]>' |
xml += '</short-description>\n' |
if self.long_description: |
xml += '<long-description><![CDATA[%(longDescription)s]]>' |
xml += '</long-description>\n' |
for tag in self.tags: |
xml += '<tag><![CDATA[%s]]></tag>\n' % tag |
for asset in self.assets: |
if asset.get('encoding-rate', None): |
xml += '<rendition-refid>%s</rendition-refid>\n' % \ |
asset['refid'] |
for meta in self.metadata: |
xml += '<custom-%s-value name=""%s"">%s</custom-%s-value>' % \ |
(meta['type'], meta['key'], meta['value'], meta['type']) |
xml += '</title>' |
xml = xml % self._to_dict() |
return xml" |
826,"def _load(self, data): |
"""""" |
Deserialize a dictionary of data into a ``pybrightcove.video.Video`` |
object. |
"""""" |
self.raw_data = data |
self.creation_date = _convert_tstamp(data['creationDate']) |
self.economics = data['economics'] |
self.id = data['id'] |
self.last_modified_date = _convert_tstamp(data['lastModifiedDate']) |
self.length = data['length'] |
self.link_text = data['linkText'] |
self.link_url = data['linkURL'] |
self.long_description = data['longDescription'] |
self.name = data['name'] |
self.plays_total = data['playsTotal'] |
self.plays_trailing_week = data['playsTrailingWeek'] |
self.published_date = _convert_tstamp(data['publishedDate']) |
self.start_date = _convert_tstamp(data.get('startDate', None)) |
self.end_date = _convert_tstamp(data.get('endDate', None)) |
self.reference_id = data['referenceId'] |
self.short_description = data['shortDescription'] |
self.tags = [] |
for tag in data['tags']: |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.