[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
Showing only changes of commit 85cac212a2 - Show all commits

View File

@ -24,7 +24,7 @@ import colorsys
import random
from pathlib import Path
from typing import Dict, List, Set, Optional, Tuple, Any
import datetime
import bpy
from blender_kitsu import gazu, cache, util, prefs, bkglobals
@ -40,7 +40,7 @@ from blender_kitsu.types import (
Task,
)
from blender_kitsu.playblast.core import override_render_path
from blender_kitsu.playblast.core import override_render_path, override_render_format
logger = LoggerFactory.getLogger()
@ -326,6 +326,14 @@ class KITSU_OT_sqe_push_new_edit(bpy.types.Operator):
comment: bpy.props.StringProperty(name="comment")
edit_entry: bpy.props.EnumProperty(name="Edit Entry", items=get_edit_entry_enum)
task: bpy.props.EnumProperty(name="Edit Tasks", items=get_edit_task_items)
render_dir: bpy.props.StringProperty(
name="Render Directory",
subtype="DIR_PATH",
)
render_name: bpy.props.StringProperty(
name="Render Name",
description="Name of Render file WITHOUT extension",
)
@classmethod
def poll(cls, context: bpy.types.Context) -> bool:
@ -335,6 +343,8 @@ class KITSU_OT_sqe_push_new_edit(bpy.types.Operator):
)
def invoke(self, context, event):
self.render_dir = context.scene.render.filepath.rsplit("\\", 1)[0]
self.render_name = bpy.path.basename(context.blend_data.filepath).replace('.blend','')
return context.window_manager.invoke_props_dialog(self)
def draw(self, context: bpy.types.Context) -> None:
@ -342,19 +352,33 @@ class KITSU_OT_sqe_push_new_edit(bpy.types.Operator):
layout.prop(self, "edit_entry")
layout.prop(self, "task")
layout.prop(self, "comment")
layout.prop(self, "render_dir")
layout.prop(self, "render_name")
def execute(self, context: bpy.types.Context) -> Set[str]:
render_path = f"{context.scene.kitsu.playblast_dir}{self.name}.mp4" # TODO FIX RENDER PATH/FILENAME
with override_render_path(self, context, render_path):
bpy.ops.render.opengl(animation=True, sequencer=True)
# Build render_path
render_dir = bpy.path.abspath(self.render_dir)
render_name = f"{self.render_name.replace('.','_')}.mp4"
render_path = Path(render_dir).joinpath(render_name)
# Build Comment
time = str(datetime.datetime.now())
message = f"{self.comment}\n\n\nFile: {render_name} \n\nSubmitted on: {time}"
# Render Sequence to .mp4
with override_render_path(self, context, render_path.as_posix()):
with override_render_format(self, context):
bpy.ops.render.opengl(animation=True, sequencer=True)
# Submit to Kitsu Edit Task
gazu.edit.add_comment_on_edit_task(
self.task,
render_path,
self.comment
message
)
self.report(
{"INFO"},
f"Submitted new comment '{self.name}'"
f"Submitted new comment for render'{self.render_name}'"
)
return {"FINISHED"}