Jump to content

How can I link published version with specific task?


vitek

Recommended Posts

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()

 

 

 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...