text
stringlengths
0
828
self.tags.append(tag)
self.thumbnail_url = data['thumbnailURL']
self.video_still_url = data['videoStillURL']"
827,"def get_custom_metadata(self):
""""""
Fetches custom metadta for an already exisiting Video.
""""""
if self.id is not None:
data = self.connection.get_item(
'find_video_by_id',
video_id=self.id,
video_fields=""customFields""
)
for key in data.get(""customFields"", {}).keys():
val = data[""customFields""].get(key)
if val is not None:
self.add_custom_metadata(key, val)"
828,"def add_custom_metadata(self, key, value, meta_type=None):
""""""
Add custom metadata to the Video. meta_type is required for XML API.
""""""
self.metadata.append({'key': key, 'value': value, 'type': meta_type})"
829,"def add_asset(self, filename, asset_type, display_name,
encoding_rate=None, frame_width=None, frame_height=None,
encode_to=None, encode_multiple=False,
h264_preserve_as_rendition=False, h264_no_processing=False):
""""""
Add an asset to the Video object.
""""""
m = hashlib.md5()
fp = file(filename, 'rb')
bits = fp.read(262144) ## 256KB
while bits:
m.update(bits)
bits = fp.read(262144)
fp.close()
hash_code = m.hexdigest()
refid = ""%s-%s"" % (os.path.basename(filename), hash_code)
asset = {
'filename': filename,
'type': asset_type,
'size': os.path.getsize(filename),
'refid': refid,
'hash-code': hash_code}
if encoding_rate:
asset.update({'encoding-rate': encoding_rate})
if frame_width:
asset.update({'frame-width': frame_width})
if frame_height:
asset.update({'frame-height': frame_height})
if display_name:
asset.update({'display-name': display_name})
if encode_to:
asset.update({'encode-to': encode_to})
asset.update({'encode-multiple': encode_multiple})
if encode_multiple and h264_preserve_as_rendition:
asset.update({
'h264-preserve-as-rendition': h264_preserve_as_rendition})
else:
if h264_no_processing:
asset.update({'h264-no-processing': h264_no_processing})
self.assets.append(asset)"
830,"def save(self, create_multiple_renditions=True,
preserve_source_rendition=True,
encode_to=enums.EncodeToEnum.FLV):
""""""
Creates or updates the video
""""""
if is_ftp_connection(self.connection) and len(self.assets) > 0:
self.connection.post(xml=self.to_xml(), assets=self.assets)
elif not self.id and self._filename:
self.id = self.connection.post('create_video', self._filename,
create_multiple_renditions=create_multiple_renditions,
preserve_source_rendition=preserve_source_rendition,
encode_to=encode_to,
video=self._to_dict())
elif not self.id and len(self.renditions) > 0:
self.id = self.connection.post('create_video',
video=self._to_dict())
elif self.id:
data = self.connection.post('update_video', video=self._to_dict())
if data:
self._load(data)"
831,"def delete(self, cascade=False, delete_shares=False):
""""""
Deletes the video.
""""""
if self.id:
self.connection.post('delete_video', video_id=self.id,
cascade=cascade, delete_shares=delete_shares)
self.id = None"
832,"def get_upload_status(self):
""""""
Get the status of the video that has been uploaded.
""""""
if self.id:
return self.connection.post('get_upload_status', video_id=self.id)"