upload to kitsu
parent
d2caf90ea2
commit
299c240385
|
@ -98,6 +98,8 @@ def get_task_status_items(self, context):
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
|
|
||||||
status_items = [('CURRENT', 'Current', '')]
|
status_items = [('CURRENT', 'Current', '')]
|
||||||
|
|
||||||
|
if project:
|
||||||
status_items += [(t.name, t.name, '') for t in project.task_statuses]
|
status_items += [(t.name, t.name, '') for t in project.task_statuses]
|
||||||
return status_items
|
return status_items
|
||||||
|
|
||||||
|
@ -105,6 +107,9 @@ def get_task_type_items(self, context):
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
|
|
||||||
|
if not project:
|
||||||
|
return [('NONE', 'None', '')]
|
||||||
|
|
||||||
return [(t.name, t.name, '') for t in project.task_types]
|
return [(t.name, t.name, '') for t in project.task_types]
|
||||||
|
|
||||||
class VSETB_OT_upload_to_tracker(Operator):
|
class VSETB_OT_upload_to_tracker(Operator):
|
||||||
|
@ -158,7 +163,7 @@ class VSETB_OT_upload_to_tracker(Operator):
|
||||||
#self.report({'ERROR'}, f'Export not implemented yet.')
|
#self.report({'ERROR'}, f'Export not implemented yet.')
|
||||||
prefs = get_addon_prefs()
|
prefs = get_addon_prefs()
|
||||||
settings = get_scene_settings()
|
settings = get_scene_settings()
|
||||||
#project = settings.active_project
|
project = settings.active_project
|
||||||
tracker = prefs.tracker
|
tracker = prefs.tracker
|
||||||
|
|
||||||
status = self.status
|
status = self.status
|
||||||
|
@ -170,6 +175,10 @@ class VSETB_OT_upload_to_tracker(Operator):
|
||||||
shot_name = strip.name
|
shot_name = strip.name
|
||||||
sequence = tracker.get_sequence(sequence_name)
|
sequence = tracker.get_sequence(sequence_name)
|
||||||
|
|
||||||
|
|
||||||
|
metadata = strip.vsetb_strip_settings.metadata.to_dict()
|
||||||
|
print(metadata)
|
||||||
|
|
||||||
if not sequence:
|
if not sequence:
|
||||||
self.report({"INFO"}, f'Create sequence {sequence_name} in Kitsu')
|
self.report({"INFO"}, f'Create sequence {sequence_name} in Kitsu')
|
||||||
sequence = tracker.new_sequence(sequence_name)
|
sequence = tracker.new_sequence(sequence_name)
|
||||||
|
@ -180,16 +189,29 @@ class VSETB_OT_upload_to_tracker(Operator):
|
||||||
shot = tracker.new_shot(shot_name, sequence=sequence)
|
shot = tracker.new_shot(shot_name, sequence=sequence)
|
||||||
|
|
||||||
task = tracker.get_task(self.task, entity=shot)
|
task = tracker.get_task(self.task, entity=shot)
|
||||||
|
if not task:
|
||||||
|
task = tracker.new_task(shot, task_type=self.task)
|
||||||
|
|
||||||
print(task)
|
# print('\n', 'task comment')
|
||||||
tracker.new_comment(task, comment=self.comment, status=status)
|
# print(task['last_comment'])
|
||||||
#status = tracker.get_task(shot, self.task)
|
|
||||||
# if self.add_preview:
|
|
||||||
# strip_movie_path = Path(get_strip_render_path(strip, template))
|
|
||||||
# if path.exists():
|
|
||||||
|
|
||||||
# else:
|
preview = None
|
||||||
# self.report({"WARNING"}, f"{strip_movie_path} not exist, skipped")
|
if self.add_preview:
|
||||||
|
preview = Path(get_strip_render_path(strip, project.render_template))
|
||||||
|
if not preview.exists():
|
||||||
|
preview = None
|
||||||
|
|
||||||
|
elif task['last_comment'].get('previews'):
|
||||||
|
if self.preview_mode == 'REPLACE':
|
||||||
|
tracker.remove_comment(task['last_comment'])
|
||||||
|
elif self.preview_mode == 'ONLY_NEW':
|
||||||
|
preview = None
|
||||||
|
|
||||||
|
if status != 'CURRENT' or preview:
|
||||||
|
tracker.new_comment(task, comment=self.comment, status=status, preview=preview)
|
||||||
|
|
||||||
|
if self.custom_data:
|
||||||
|
tracker.update_data(shot, strip.vsetb_strip_settings.metadata.to_dict())
|
||||||
|
|
||||||
|
|
||||||
return {"FINISHED"}
|
return {"FINISHED"}
|
||||||
|
@ -445,6 +467,8 @@ class VSETB_OT_load_projects(Operator):
|
||||||
prefs = get_addon_prefs()
|
prefs = get_addon_prefs()
|
||||||
tracker = prefs.tracker
|
tracker = prefs.tracker
|
||||||
|
|
||||||
|
old_project_name = settings.project_name.replace(' ', '_').upper()
|
||||||
|
|
||||||
settings.projects.clear()
|
settings.projects.clear()
|
||||||
tracker.connect()
|
tracker.connect()
|
||||||
|
|
||||||
|
@ -479,10 +503,19 @@ class VSETB_OT_load_projects(Operator):
|
||||||
asset_type = project.asset_types.add()
|
asset_type = project.asset_types.add()
|
||||||
asset_type.name = asset_type_data['name']
|
asset_type.name = asset_type_data['name']
|
||||||
|
|
||||||
if settings.active_project:
|
for project in settings.projects:
|
||||||
settings.active_project.set_strip_metadata()
|
print(project.name, project.name.replace(' ', '_').upper(), old_project_name)
|
||||||
|
if project.name.replace(' ', '_').upper() == old_project_name:
|
||||||
|
|
||||||
bpy.ops.vse_toolbox.load_assets()
|
print('Restore Project Name')
|
||||||
|
settings.project_name = project.name
|
||||||
|
#else:
|
||||||
|
# print('Could Not restore Project Name')
|
||||||
|
|
||||||
|
#if settings.active_project:
|
||||||
|
# settings.active_project.set_strip_metadata()
|
||||||
|
|
||||||
|
#bpy.ops.vse_toolbox.load_assets()
|
||||||
|
|
||||||
return {'FINISHED'}
|
return {'FINISHED'}
|
||||||
|
|
||||||
|
|
|
@ -23,17 +23,17 @@ def get_episodes_items(self, context):
|
||||||
|
|
||||||
project = settings.active_project
|
project = settings.active_project
|
||||||
if not project:
|
if not project:
|
||||||
return [('NONE', 'None', '', 0)]
|
return [('/', '/', '', 0)]
|
||||||
|
|
||||||
episodes = project.episodes
|
episodes = project.episodes
|
||||||
if not episodes:
|
if not episodes:
|
||||||
return [('NONE', 'None', '', 0)]
|
return [('/', '/', '', 0)]
|
||||||
|
|
||||||
return [(e, e, '', i) for i, e in enumerate(episodes.keys())]
|
return [(e, e, '', i) for i, e in enumerate(episodes.keys())]
|
||||||
|
|
||||||
def get_project_items(self, context):
|
def get_project_items(self, context):
|
||||||
if not self.projects:
|
if not self.projects:
|
||||||
return [('NONE', 'None', '', 0)]
|
return [('/', '/', '', 0)]
|
||||||
|
|
||||||
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
|
return [(p, p, '', i) for i, p in enumerate(self.projects.keys())]
|
||||||
|
|
||||||
|
@ -113,6 +113,8 @@ class TaskStatus(PropertyGroup):
|
||||||
class Metadata(PropertyGroup):
|
class Metadata(PropertyGroup):
|
||||||
__annotations__ = {}
|
__annotations__ = {}
|
||||||
|
|
||||||
|
def to_dict(self):
|
||||||
|
return {p.name: getattr(self, p.identifier) for p in self.bl_rna.properties.keys() if p.name != 'RNA'}
|
||||||
|
|
||||||
class Episode(PropertyGroup):
|
class Episode(PropertyGroup):
|
||||||
id : StringProperty(default='')
|
id : StringProperty(default='')
|
||||||
|
@ -169,7 +171,7 @@ class Project(PropertyGroup):
|
||||||
for metadata_type in self.metadata_types:
|
for metadata_type in self.metadata_types:
|
||||||
prop_name = metadata_type.name
|
prop_name = metadata_type.name
|
||||||
if metadata_type.get('choices'):
|
if metadata_type.get('choices'):
|
||||||
prop = bpy.props.EnumProperty(items=[(c, c.replace(' ', '_').upper(), '') for c in metadata_type['choices']])
|
prop = bpy.props.EnumProperty(items=[(c, c.replace(' ', '_').upper(), '') for c in ['/'] + metadata_type['choices']])
|
||||||
else:
|
else:
|
||||||
prop = bpy.props.StringProperty()
|
prop = bpy.props.StringProperty()
|
||||||
|
|
||||||
|
|
|
@ -116,7 +116,10 @@ class Kitsu(Tracker):
|
||||||
return gazu.shot.all_episodes_for_project(project)
|
return gazu.shot.all_episodes_for_project(project)
|
||||||
|
|
||||||
def get_task_type(self, task_type=None):
|
def get_task_type(self, task_type=None):
|
||||||
print('get_task_type', task_type)
|
task_type_id = self.get_id(task_type)
|
||||||
|
if task_type_id:
|
||||||
|
return task_type_id
|
||||||
|
|
||||||
return gazu.task.get_task_type_by_name(task_type)
|
return gazu.task.get_task_type_by_name(task_type)
|
||||||
|
|
||||||
def get_shot_task_types(self, project=None):
|
def get_shot_task_types(self, project=None):
|
||||||
|
@ -192,17 +195,32 @@ class Kitsu(Tracker):
|
||||||
entity = self.get_id(entity)
|
entity = self.get_id(entity)
|
||||||
|
|
||||||
task_type = self.get_task_type(task)
|
task_type = self.get_task_type(task)
|
||||||
|
|
||||||
print('task_type', task_type)
|
|
||||||
print('task_type', task_type)
|
|
||||||
|
|
||||||
task = gazu.task.get_task_by_name(entity, task_type)
|
task = gazu.task.get_task_by_name(entity, task_type)
|
||||||
|
|
||||||
|
if not task:
|
||||||
|
return
|
||||||
#task = gazu.task.get_task(task['id'])
|
#task = gazu.task.get_task(task['id'])
|
||||||
|
|
||||||
task['last_comment'] = self.get_last_comment(task)
|
task['last_comment'] = self.get_last_comment(task)
|
||||||
|
|
||||||
return task
|
return task
|
||||||
|
|
||||||
|
def new_preview(self, task, comment, preview, set_main_preview=False):
|
||||||
|
#print('new_preview', task, comment, preview, set_main_preview)
|
||||||
|
|
||||||
|
task = self.get_id(task)
|
||||||
|
comment = self.get_id(comment)
|
||||||
|
|
||||||
|
preview_data = gazu.task.add_preview(
|
||||||
|
task=task,
|
||||||
|
comment=comment,
|
||||||
|
preview_file_path=preview )
|
||||||
|
|
||||||
|
if set_main_preview:
|
||||||
|
gazu.task.set_main_preview(preview_data)
|
||||||
|
|
||||||
|
return preview_data
|
||||||
|
|
||||||
def new_comment(self, task, status=None, comment='', preview=None, set_main_preview=False):
|
def new_comment(self, task, status=None, comment='', preview=None, set_main_preview=False):
|
||||||
#task = self.get_task(task)
|
#task = self.get_task(task)
|
||||||
|
|
||||||
|
@ -213,26 +231,24 @@ class Kitsu(Tracker):
|
||||||
else:
|
else:
|
||||||
status = self.get_task_status(status)
|
status = self.get_task_status(status)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
comment = gazu.task.add_comment(
|
comment = gazu.task.add_comment(
|
||||||
task=task,
|
task=task,
|
||||||
task_status=status,
|
task_status=status,
|
||||||
comment=comment )
|
comment=comment )
|
||||||
|
|
||||||
if preview:
|
if preview:
|
||||||
logging.info(f'Adding Preview to Kitsu {preview}')
|
#logging.info(f'Adding Preview to Kitsu {preview}')
|
||||||
preview = self.add_preview(
|
preview = self.new_preview(
|
||||||
task=task,
|
task=task,
|
||||||
comment=comment,
|
comment=comment,
|
||||||
preview=str(preview) )
|
preview=str(preview),
|
||||||
|
set_main_preview=set_main_preview )
|
||||||
if set_main_preview:
|
|
||||||
gazu.task.set_main_preview(preview)
|
|
||||||
|
|
||||||
|
|
||||||
return comment
|
return comment
|
||||||
|
|
||||||
|
def remove_comment(self, comment):
|
||||||
|
return gazu.task.remove_comment(comment)
|
||||||
|
|
||||||
def download_preview(self, preview_id, filepath):
|
def download_preview(self, preview_id, filepath):
|
||||||
if isinstance(filepath, str):
|
if isinstance(filepath, str):
|
||||||
filepath = Path(filepath)
|
filepath = Path(filepath)
|
||||||
|
@ -243,6 +259,12 @@ class Kitsu(Tracker):
|
||||||
filepath.parent.mkdir(parents=True, exist_ok=True)
|
filepath.parent.mkdir(parents=True, exist_ok=True)
|
||||||
gazu.files.download_preview_file_thumbnail(preview_id, filepath.as_posix())
|
gazu.files.download_preview_file_thumbnail(preview_id, filepath.as_posix())
|
||||||
|
|
||||||
|
def new_task(self, entity, task_type, status=None, project=None):
|
||||||
|
task_type = self.get_task_type(task_type)
|
||||||
|
if status:
|
||||||
|
status = self.get_task_status(status)
|
||||||
|
return gazu.task.new_task(entity, task_type=task_type, task_status=status)
|
||||||
|
|
||||||
def new_sequence(self, sequence, episode=None, project=None):
|
def new_sequence(self, sequence, episode=None, project=None):
|
||||||
project = self.get_project(project)
|
project = self.get_project(project)
|
||||||
|
|
||||||
|
@ -254,7 +276,7 @@ class Kitsu(Tracker):
|
||||||
return gazu.shot.new_sequence(**params)
|
return gazu.shot.new_sequence(**params)
|
||||||
|
|
||||||
def new_shot(self, shot, sequence, nb_frames=None, frame_in=None,
|
def new_shot(self, shot, sequence, nb_frames=None, frame_in=None,
|
||||||
frame_out=None, description='', custom_data=None, project=None):
|
frame_out=None, description='', custom_data=None, with_tasks=True, project=None):
|
||||||
|
|
||||||
project = self.get_project(project)
|
project = self.get_project(project)
|
||||||
sequence = self.get_sequence(sequence)
|
sequence = self.get_sequence(sequence)
|
||||||
|
@ -273,11 +295,41 @@ class Kitsu(Tracker):
|
||||||
params["nb_frames"] = nb_frames
|
params["nb_frames"] = nb_frames
|
||||||
|
|
||||||
shot = self.get_shot(shot=shot, sequence=sequence)
|
shot = self.get_shot(shot=shot, sequence=sequence)
|
||||||
if shot:
|
if not shot:
|
||||||
return shot
|
|
||||||
else:
|
|
||||||
path = f"data/projects/{self.get_id(project)}/shots"
|
path = f"data/projects/{self.get_id(project)}/shots"
|
||||||
return gazu.client.post(path, params)
|
shot = gazu.client.post(path, params)
|
||||||
|
|
||||||
|
if with_tasks:
|
||||||
|
for task_type in self.get_shot_task_types(project=project):
|
||||||
|
self.new_task(shot, task_type)
|
||||||
|
|
||||||
|
return shot
|
||||||
|
|
||||||
|
def update_data(self, entity, data, name=None, description=None, frames=None, clear=False):
|
||||||
|
if isinstance(entity, dict):
|
||||||
|
entity_id = entity['id']
|
||||||
|
else:
|
||||||
|
entity_id = self.get_id(entity)
|
||||||
|
entity = gazu.client.fetch_one('entities', entity_id)
|
||||||
|
|
||||||
|
if data.get('custom_data'):
|
||||||
|
data['data'] = data.pop('custom_data')
|
||||||
|
|
||||||
|
if name:
|
||||||
|
entity['name'] = name
|
||||||
|
if description:
|
||||||
|
entity['description'] = description
|
||||||
|
if frames:
|
||||||
|
entity['nb_frames'] = frames
|
||||||
|
|
||||||
|
if clear or not entity['data']:
|
||||||
|
entity['data'] = data
|
||||||
|
else:
|
||||||
|
entity['data'].update(data)
|
||||||
|
|
||||||
|
entity_data = gazu.client.put(f"data/entities/{entity_id}", entity)
|
||||||
|
|
||||||
|
return entity_data['data']
|
||||||
|
|
||||||
def draw_prefs(self, layout):
|
def draw_prefs(self, layout):
|
||||||
layout.prop(self, 'url', text='Url')
|
layout.prop(self, 'url', text='Url')
|
||||||
|
|
|
@ -124,6 +124,7 @@ def set_channels():
|
||||||
scn.sequence_editor.channels[i].name = c.title()
|
scn.sequence_editor.channels[i].name = c.title()
|
||||||
|
|
||||||
def get_strip_render_path(strip, template):
|
def get_strip_render_path(strip, template):
|
||||||
|
scn = bpy.context.scene
|
||||||
return template.format(strip_name=strip.name, ext=Path(scn.render.frame_path()).suffix)
|
return template.format(strip_name=strip.name, ext=Path(scn.render.frame_path()).suffix)
|
||||||
|
|
||||||
def render_strips(strips, template):
|
def render_strips(strips, template):
|
||||||
|
|
Loading…
Reference in New Issue