[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 def add_comment_on_edit_task(task_id:str,
rendered_filepath = None, comment=""
default = raw.default_client
def new_edit(
project,
name=None,
description = "",
rendered_filepath = None,
data={},
client=default,
): ):
""" """
Create a new edit within project. Comment Full Edit Render on Edit Task
Args: Args:
project (str / dict): The project dict or the project ID. #TODO
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.
Returns: Returns:
Created edit. Comment on Edit Task.
""" """
project = normalize_model_parameter(project) task_entity = gazu.task.get_task(task_id)
path = f"data/projects/{project['id']}/edits" new_comment = gazu.task.add_comment(task_entity, task_entity["task_status"], comment)
data = {"name": name, "description": description,} uploaded_preview = gazu.task.add_preview(task_entity, new_comment, rendered_filepath)
new_edit = raw.post(path, data, client=client) return new_comment
upload_path = f"{path}/{new_edit['id']}"
raw.upload(upload_path, rendered_filepath, client=client)
return new_edit

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): class KITSU_OT_sqe_push_new_edit(bpy.types.Operator):
bl_idname = "kitsu.sqe_push_new_edit" bl_idname = "kitsu.sqe_push_new_edit_comment"
bl_label = "Submit New Kitsu Edit" bl_label = "Submit New Kitsu Edit Comment"
bl_description = "Creates a new edit on Kitsu server." bl_description = "Creates a new edit comment on Edit task via ID."
name: bpy.props.StringProperty(name="Edit Name") comment: bpy.props.StringProperty(name="comment")
description: bpy.props.StringProperty(name="Description") 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 @classmethod
def poll(cls, context: bpy.types.Context) -> bool: 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: def draw(self, context: bpy.types.Context) -> None:
layout = self.layout layout = self.layout
layout.prop(self, "name") layout.prop(self, "task_id")
layout.prop(self, "description") layout.prop(self, "comment")
def execute(self, context: bpy.types.Context) -> Set[str]: 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 RENDER PATH/FILENAME
render_path = f"{context.scene.kitsu.playblast_dir}{self.name}.mp4" # TODO FIX SAVES RENDER NEXT TO SHOT FILE
with override_render_settings(self, context, render_path): with override_render_settings(self, context, render_path):
bpy.ops.render.opengl(animation=True, sequencer=True) bpy.ops.render.opengl(animation=True, sequencer=True)
gazu.edit.new_edit(
project_active.id, gazu.edit.add_comment_on_edit_task(
self.name, self.task_id,
self.description, render_path,
Path(render_path), self.comment
context.scene.frame_start, )
) #TODO This fails to upload returns 500 Code
self.report( self.report(
{"INFO"}, {"INFO"},
f"Submitted new edit '{self.name}'" f"Submitted new comment '{self.name}'"
) )
return {"FINISHED"} return {"FINISHED"}