How can I link published version with specific task?
0

2 posts in this topic

Hello folks,

I'm trying to write a snippet to publish a file and link it to specific task and can't get it to work - is the TypedContextLink right way to do it? I've been doing quite some trial and error and getting error messages I don't quite understand ... could you point me in the right direction, please? Cheers!!

 

import os

import ftrack_api

import ftrack_api.symbol

 

#INIT SESSION

session = ftrack_api.Session(

server_url=server_url,

api_key=api_key,

api_user=api_user

)

 

file_path = 'C:/Users/vit.sedlacek/test.mov'

asset_name = "aaaW"

 

asset_type = session.query(

'AssetType where name is "Upload"'

).one()

 

##------------------------------------------------------

##musim dostat task a pak task ID

project = session.query('Project where name is _PIPELINE').one()

sqs = session.query('Task where project.id is "{0}"'.format(project['id']))

 

#sqs.first()['name']

taskID = sqs.first()['id']

task = session.get('Task', taskID)

shot = task['parent']

 

shot2 = session.get(

'Shot', shot['id']

)

 

asset = session.create('Asset', {

'name': asset_name,

'type': asset_type,

'parent': shot

})

 

asset_version = session.create('AssetVersion', {

'asset':asset,

'task': shot,

'version': 110

})

 

session.create('TypedContextLink', {

'from': asset_version,

'to': task

})

 

component = asset_version.create_component(

path=file_path,

data={

'name': asset_name

},

location=session.get('Location', ftrack_api.symbol.SERVER_LOCATION_ID)

)

 

asset_version.encode_media(

component

)

 

session.commit()

 

 

 

Share this post


Link to post
Share on other sites

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
0