[Blender_Kitsu] Publish VSE Edit as Revision on Kitsu #7
@ -2396,6 +2396,14 @@ class KITSU_OT_sqe_change_strip_source(bpy.types.Operator):
|
||||
util.ui_redraw()
|
||||
return {"FINISHED"}
|
||||
|
||||
def set_entity_data(entity, key: str, value: int):
|
||||
if get_entity_data(entity, key) is not None:
|
||||
entity['data'][key] = value
|
||||
return entity
|
||||
|
||||
def get_entity_data(entity, key: str):
|
||||
if entity.get("data").get(key) is not None:
|
||||
return entity.get("data").get(key)
|
||||
|
||||
def get_dict_len(items:dict):
|
||||
try:
|
||||
@ -2426,13 +2434,15 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
|
||||
tasks = gazu.task.all_tasks_for_edit(self.edit_entry)
|
||||
return [(item.get("id"), item.get("name"), f'Created at: "{item.get("created_at")}" {item.get("description")}') for item in tasks]
|
||||
|
||||
comment: bpy.props.StringProperty(name="comment")
|
||||
edit_entry: bpy.props.EnumProperty(name="Edit Entry", items=get_edit_entry_items)
|
||||
task: bpy.props.EnumProperty(name="Edit Tasks", items=get_edit_task_items)
|
||||
comment: bpy.props.StringProperty(name="Comment")
|
||||
edit_entry: bpy.props.EnumProperty(name="Edit", items=get_edit_entry_items)
|
||||
task: bpy.props.EnumProperty(name="Edit", items=get_edit_task_items)
|
||||
render_dir: bpy.props.StringProperty(
|
||||
name="Render Directory",
|
||||
name="Folder",
|
||||
subtype="DIR_PATH",
|
||||
)
|
||||
use_frame_start: bpy.props.BoolProperty(name="Submit update to 'frame_start'.", default=False)
|
||||
frame_start: bpy.props.IntProperty(name="Frame Start", description="Send an integerfor the 'frame_start' value of the current Kitsu Edit. \nThis is used by Watchtower to pad the edit in the timeline.", default=0)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context: bpy.types.Context) -> bool:
|
||||
@ -2447,6 +2457,11 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
|
||||
if not os.path.isdir(Path(dir_path)):
|
||||
dir_path = Path(dir_path).parent
|
||||
self.render_dir = str(dir_path)
|
||||
|
||||
#'frame_start' is optionally property appearring on all edit_entries for a project if it exists
|
||||
server_frame_start = get_entity_data(gazu.edit.get_edit(self.edit_entry), 'frame_start')
|
||||
self.frame_start = server_frame_start
|
||||
self.use_frame_start = bool(server_frame_start is not None)
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def draw(self, context: bpy.types.Context) -> None:
|
||||
@ -2457,6 +2472,11 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
|
||||
layout.prop(self, "comment")
|
||||
layout.prop(self, "render_dir")
|
||||
|
||||
# Only set `frame_start` if exists on current project
|
||||
if self.use_frame_start:
|
||||
layout.prop(self, "frame_start")
|
||||
|
||||
|
||||
def execute(self, context: bpy.types.Context) -> Set[str]:
|
||||
if self.task == "":
|
||||
self.report({"ERROR"}, "Selected edit doesn't have any task associated with it .")
|
||||
@ -2486,9 +2506,15 @@ class KITSU_OT_vse_publish_edit_revision(bpy.types.Operator):
|
||||
bpy.ops.render.opengl(animation=True, sequencer=True)
|
||||
|
||||
# Create comment with video
|
||||
task_entity = gazu.task.get_task(self.task,)
|
||||
new_comment = gazu.task.add_comment(task_entity, task_entity["task_status"])
|
||||
uploaded_preview = gazu.task.add_preview(task_entity, new_comment, render_path)
|
||||
task_entity = gazu.task.get_task(self.task)
|
||||
new_comment = gazu.task.add_comment(task_entity, task_entity["task_status"], self.comment)
|
||||
new_preview = gazu.task.add_preview(task_entity, new_comment, render_path)
|
||||
|
||||
# Update edit_entry's frame_start if 'frame_start' is found on server
|
||||
if self.use_frame_start:
|
||||
edit_entity_update = set_entity_data(edit_entry, 'frame_start', self.frame_start)
|
||||
updated_edit_entity = gazu.entity.update_entity(edit_entity_update) #TODO add a generic function to update entites
|
||||
|
||||
|
||||
self.report(
|
||||
{"INFO"},
|
||||
|
Loading…
Reference in New Issue
Block a user