Jump to content

How to make a version reviewable via new api


raul1st2002

Recommended Posts

Hi,

I wonder how can I make an AssetVersion reviewable with the new API.

I read the forum and found the old api has a makeReviewable method:

ftrack.Review.makeReviewable(version, filePath)

But I cannot find a similar one in the new API. 

 

I also tried manually adding a custom component with a name of 'ftrackreview-image' (which I found in a reviewable version published using ftrack connect). That doesn't work.  

 

Is this possible to do this without import the old api?

 

Thank you for your help!

 

Ding

Link to comment
Share on other sites

  • 2 months later...

Hi

On 02/06/2016 at 9:17 AM, Mattias Lagergren said:

Hey, here is an example of how to encode media with our new api: http://ftrack-python-api.rtd.ftrack.com/en/stable/example/encode_media.html

I followed the instructions, but when I commit (which is doesn't do in the example), it gives me an error.

I think this is because the job hasn't finished. If I put an arbitrary `time.sleep(20)` then it works fine, because the job has already finished by then.

It doesn't mention in the example that you need to wait for the job to finish before committing the attaching of the component to the version, and adding the thumbnail.

How do I correctly wait for the job to finish?

Thanks

Phil

 

Link to comment
Share on other sites

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

 

Link to comment
Share on other sites

Aha, yes - correct - and the example is broken!

So what happens in the backend is that the service use will asynchronously encode the media. When that is done the new component will be added to the server location. When the example was written it was possible to set a component as thumbnail even though it did not exist in server location. That has changed and we're now verifying this.

We will discuss here and see what the best approach is and then update the example. Thank you for making us aware of this!

 

Link to comment
Share on other sites

  • 3 years later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...