[Blender_Kitsu] Publish VSE Edit as Revision on Kitsu #7

Merged
Nick Alberelli merged 28 commits from :feature/upload_render_to_kitsu into master 2023-04-17 19:02:15 +02:00
2 changed files with 28 additions and 44 deletions
Showing only changes of commit 16fe6f7058 - Show all commits

View File

@ -1,36 +1,19 @@
from . import client as raw
from blender_kitsu import gazu
from .helpers import normalize_model_parameter
default = raw.default_client
def new_edit(
project,
name=None,
description = "",
rendered_filepath = None,
data={},
client=default,
def add_comment_on_edit_task(task_id:str,
rendered_filepath = None, comment=""
):
"""
Create a new edit within project.
Comment Full Edit Render on Edit Task
Args:
project (str / dict): The project dict or the project ID.
sequence (str / dict): The sequence dict or the sequence ID.
name (str): The name of the edit to create.
description (str): The name of the edit to create.
data (dict): Free field to set metadata of any kind.
#TODO
Returns:
Created edit.
Comment on Edit Task.
"""
project = normalize_model_parameter(project)
path = f"data/projects/{project['id']}/edits"
data = {"name": name, "description": description,}
new_edit = raw.post(path, data, client=client)
upload_path = f"{path}/{new_edit['id']}"
raw.upload(upload_path, rendered_filepath, client=client)
return new_edit
task_entity = gazu.task.get_task(task_id)
new_comment = gazu.task.add_comment(task_entity, task_entity["task_status"], comment)
uploaded_preview = gazu.task.add_preview(task_entity, new_comment, rendered_filepath)
return new_comment

View File

@ -311,12 +311,15 @@ class KITSU_OT_sqe_push_new_shot(bpy.types.Operator):
class KITSU_OT_sqe_push_new_edit(bpy.types.Operator):
bl_idname = "kitsu.sqe_push_new_edit"
bl_label = "Submit New Kitsu Edit"
bl_description = "Creates a new edit on Kitsu server."
bl_idname = "kitsu.sqe_push_new_edit_comment"
bl_label = "Submit New Kitsu Edit Comment"
bl_description = "Creates a new edit comment on Edit task via ID."
name: bpy.props.StringProperty(name="Edit Name")
description: bpy.props.StringProperty(name="Description")
comment: bpy.props.StringProperty(name="comment")
task_id: bpy.props.StringProperty( #TODO Make an Enum (allow user to select both [Edit>Task])
name="Task ID",
default='6dec9e11-34c0-408a-b828-6a3c638e191f' #TODO Remove temporary default for testing
)
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
@ -330,24 +333,22 @@ class KITSU_OT_sqe_push_new_edit(bpy.types.Operator):
def draw(self, context: bpy.types.Context) -> None:
layout = self.layout
layout.prop(self, "name")
layout.prop(self, "description")
layout.prop(self, "task_id")
layout.prop(self, "comment")
def execute(self, context: bpy.types.Context) -> Set[str]:
project_active = cache.project_active_get()
render_path = f"{context.scene.kitsu.playblast_dir}{self.name}.mp4" # TODO FIX SAVES RENDER NEXT TO SHOT FILE
render_path = f"{context.scene.kitsu.playblast_dir}{self.name}.mp4" # TODO FIX RENDER PATH/FILENAME
with override_render_settings(self, context, render_path):
bpy.ops.render.opengl(animation=True, sequencer=True)
gazu.edit.new_edit(
project_active.id,
self.name,
self.description,
Path(render_path),
context.scene.frame_start,
) #TODO This fails to upload returns 500 Code
gazu.edit.add_comment_on_edit_task(
self.task_id,
render_path,
self.comment
)
self.report(
{"INFO"},
f"Submitted new edit '{self.name}'"
f"Submitted new comment '{self.name}'"
)
return {"FINISHED"}