Yes Sorry:
versionID = "4f1d2286-4f9c-4406-b1a4-b918dbfeb987"
filename = "L:\\script_library\\temporary_files\\1470830134.mov"
version = session.get('AssetVersion', versionID)
job = session.encode_media(filename)
job_data = json.loads(job['data'])
for output in job_data['output']:
component = session.get('FileComponent', output['component_id'])
# Add component to version.
component['version_id'] = version['id']
# Add thumbnail to the version.
if output['format'] == 'image/jpeg':
version['thumbnail_id'] = output['component_id']
session.commit()
produces the following error for me:
Traceback (most recent call last):
File "C:/Users/Philips/Documents/source_code/test_project/ftrack/make_playable_media.py", line 36, in <module>
session.commit()
File "L:\script_library\pipeline\libs\3rd_party\production\ftrack_api\session.py", line 1159, in commit
result = self._call(batch)
File "L:\script_library\pipeline\libs\3rd_party\production\ftrack_api\session.py", line 1528, in _call
raise ftrack_api.exception.ServerError(error_message)
ftrack_api.exception.ServerError: Server reported error: ValidationError(FileComponent with id u'734a28f2-5fa3-11e6-b665-22000ab8015b' was not found in an a valid location, please make sure it is present in the ftrack.server location.)
I've got around it for the time being by adding the following at the end, but this doesn't seem like a good solution:
retry = True
while retry:
try:
session.commit()
retry = False
except:
pass