From f7c7abffefaad81ec9ec85dc83d42a9f47198d96 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 1 May 2024 10:23:17 -0400 Subject: [PATCH 1/3] Use Blank Video File when Creating New Metadata Strips --- scripts-blender/addons/blender_kitsu/prefs.py | 14 ++++++++++++++ scripts-blender/addons/blender_kitsu/sqe/ops.py | 4 ++-- scripts-blender/addons/render_review/kitsu.py | 3 ++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/scripts-blender/addons/blender_kitsu/prefs.py b/scripts-blender/addons/blender_kitsu/prefs.py index 1d2b4fdf..9d15aabf 100644 --- a/scripts-blender/addons/blender_kitsu/prefs.py +++ b/scripts-blender/addons/blender_kitsu/prefs.py @@ -121,6 +121,20 @@ class KITSU_addon_preferences(bpy.types.AddonPreferences): how some of the operators work. """ + def get_metadatastrip_file(self) -> str: + res_dir = bkglobals.RES_DIR_PATH + return res_dir.joinpath("metastrip.mp4").as_posix() + + metadatastrip_file: bpy.props.StringProperty( # type: ignore + name="Metadata Strip File", + description=( + "Filepath to black .mp4 file that will be used as metastrip for shots in the sequence editor" + ), + default="", + subtype="FILE_PATH", + get=get_metadatastrip_file, + ) + def get_datadir(self) -> Path: """Returns a Path where persistent application data can be stored. diff --git a/scripts-blender/addons/blender_kitsu/sqe/ops.py b/scripts-blender/addons/blender_kitsu/sqe/ops.py index 3f1cba66..009849ea 100644 --- a/scripts-blender/addons/blender_kitsu/sqe/ops.py +++ b/scripts-blender/addons/blender_kitsu/sqe/ops.py @@ -1807,7 +1807,7 @@ class KITSU_OT_sqe_pull_edit(bpy.types.Operator): # Create new strip. strip = context.scene.sequence_editor.sequences.new_movie( shot.name, - "", + addon_prefs.metadatastrip_file, channel, frame_start, ) @@ -2012,7 +2012,7 @@ class KITSU_OT_sqe_create_metadata_strip(bpy.types.Operator): # on the first try, EDIT: seems to work maybe per python overlaps of sequences possible? metadata_strip = context.scene.sequence_editor.sequences.new_movie( f"{strip.name}{bkglobals.DELIMITER}metadata{bkglobals.SPACE_REPLACER}strip", - "", + addon_prefs.metadatastrip_file, strip.channel + 1, strip.frame_final_start, ) diff --git a/scripts-blender/addons/render_review/kitsu.py b/scripts-blender/addons/render_review/kitsu.py index bfd56359..20fd86c6 100644 --- a/scripts-blender/addons/render_review/kitsu.py +++ b/scripts-blender/addons/render_review/kitsu.py @@ -57,10 +57,11 @@ def create_metadata_strip( strip_range = range(strip.frame_final_start, strip.frame_final_end) channel = strip.channel + 1 + addon_prefs = prefs.addon_prefs_get(context) # Create new metadata strip. metadata_strip = context.scene.sequence_editor.sequences.new_movie( f"{strip.name}_metadata-strip", - "", + addon_prefs.metadatastrip_file, strip.channel + 1, strip.frame_final_start, ) -- 2.30.2 From fb9227fdf570a6cb16708f5bd51f420ef5714e9e Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 1 May 2024 10:47:25 -0400 Subject: [PATCH 2/3] Add Operator to Fix Missing Metadata Strip Media --- .../addons/blender_kitsu/sqe/ops.py | 27 +++++++++++++++++ .../addons/blender_kitsu/sqe/ui.py | 29 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/scripts-blender/addons/blender_kitsu/sqe/ops.py b/scripts-blender/addons/blender_kitsu/sqe/ops.py index 009849ea..0098e5f6 100644 --- a/scripts-blender/addons/blender_kitsu/sqe/ops.py +++ b/scripts-blender/addons/blender_kitsu/sqe/ops.py @@ -2059,6 +2059,32 @@ class KITSU_OT_sqe_create_metadata_strip(bpy.types.Operator): return {"FINISHED"} +class KITSU_OT_sqe_fix_metadata_strips(bpy.types.Operator): + + bl_idname = "kitsu.sqe_fix_metadata_strip" + bl_label = "Fix Metadata Strip Missing Media" + bl_description = "Fixes missing media error in metadata strips. " + bl_options = {"REGISTER", "UNDO"} + + def execute(self, context: Context): + addon_prefs = prefs.addon_prefs_get(context) + + if len(context.selected_sequences) == 0: + all_strips = context.scene.sequence_editor.sequences + else: + all_strips = context.selected_sequences + + offline_metadata_strips = [ + strip + for strip in all_strips + if strip.kitsu.shot_id != '' and not Path(strip.filepath).is_file() + ] + + for strip in offline_metadata_strips: + strip.filepath = addon_prefs.metadatastrip_file + return {"FINISHED"} + + class KITSU_OT_sqe_add_sequence_color(bpy.types.Operator): """ Adds sequence of active strip to scene.kitsu.sequence_colors collection property @@ -2761,6 +2787,7 @@ classes = [ KITSU_OT_sqe_pull_edit, KITSU_OT_sqe_init_strip_start_frame, KITSU_OT_sqe_create_metadata_strip, + KITSU_OT_sqe_fix_metadata_strips, KITSU_OT_sqe_add_sequence_color, KITSU_OT_sqe_scan_for_media_updates, KITSU_OT_sqe_change_strip_source, diff --git a/scripts-blender/addons/blender_kitsu/sqe/ui.py b/scripts-blender/addons/blender_kitsu/sqe/ui.py index 518179fd..83cefb96 100644 --- a/scripts-blender/addons/blender_kitsu/sqe/ui.py +++ b/scripts-blender/addons/blender_kitsu/sqe/ui.py @@ -46,6 +46,7 @@ from ..sqe.ops import ( KITSU_OT_sqe_pull_edit, KITSU_OT_sqe_init_strip_start_frame, KITSU_OT_sqe_create_metadata_strip, + KITSU_OT_sqe_fix_metadata_strips, KITSU_OT_sqe_add_sequence_color, KITSU_OT_sqe_scan_for_media_updates, KITSU_OT_sqe_change_strip_source, @@ -119,6 +120,9 @@ class KITSU_PT_sqe_shot_tools(bpy.types.Panel): if self.poll_metadata(context): self.draw_metadata(context) + if self.poll_offline_metadata(context): + self.draw_offline_metadata(context) + if self.poll_multi_edit(context): self.draw_multi_edit(context) @@ -353,6 +357,31 @@ class KITSU_PT_sqe_shot_tools(bpy.types.Panel): row.prop(strip.kitsu, "frame_start_offset", text="In") """ + def poll_offline_metadata(cls, context: bpy.types.Context) -> bool: + offline_metadata_strips = [ + strip + for strip in context.scene.sequence_editor.sequences + if strip.kitsu.shot_id != '' and not Path(strip.filepath).is_file() + ] + + return len(offline_metadata_strips) > 0 + + def draw_offline_metadata(self, context: bpy.types.Context) -> None: + # Create box. + layout = self.layout + box = layout.box() + box.label(text="Fix Metadata Strips", icon="ERROR") + offline_metadata_strips = [ + strip + for strip in context.selected_sequences + if strip.kitsu.shot_id != '' and not Path(strip.filepath).is_file() + ] + if len(offline_metadata_strips) == 0: + text = "Fix All Missing Media" + else: + text = f"Fix {len(offline_metadata_strips)} Missing Media" + box.operator(KITSU_OT_sqe_fix_metadata_strips.bl_idname, text=text) + @classmethod def poll_multi_edit(cls, context: bpy.types.Context) -> bool: if not prefs.session_auth(context): -- 2.30.2 From 8576b3248e9fb08450bf6e3c3e4a92f709490948 Mon Sep 17 00:00:00 2001 From: Nick Alberelli Date: Wed, 1 May 2024 10:57:27 -0400 Subject: [PATCH 3/3] Add Missing Metadata Media to Docs --- docs/media/addons/blender_kitsu/sqe_fix_metadata_media.jpg | 3 +++ scripts-blender/addons/blender_kitsu/README.md | 5 +++++ 2 files changed, 8 insertions(+) create mode 100644 docs/media/addons/blender_kitsu/sqe_fix_metadata_media.jpg diff --git a/docs/media/addons/blender_kitsu/sqe_fix_metadata_media.jpg b/docs/media/addons/blender_kitsu/sqe_fix_metadata_media.jpg new file mode 100644 index 00000000..4e52d1da --- /dev/null +++ b/docs/media/addons/blender_kitsu/sqe_fix_metadata_media.jpg @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0e857e8b50d7bca545110ea81fe2457ddee403c98cb9d7546c365debae41651d +size 5146 diff --git a/scripts-blender/addons/blender_kitsu/README.md b/scripts-blender/addons/blender_kitsu/README.md index d2f65a9f..10c613a8 100644 --- a/scripts-blender/addons/blender_kitsu/README.md +++ b/scripts-blender/addons/blender_kitsu/README.md @@ -151,6 +151,11 @@ If you linked in a sequence that has no `["data"]["color"]` attribute on Kitsu y All this information and more can be `pushed` to kitsu which bring us to the next panel.
+##### Missing Metadata Strip Media +If your scene contains any metadata strips that have "missing media" a **Fix Metadata Strips** box will appear in your Kitsu Panel. Simply select the metadata strips that have missing media, or none to fix all strips, and run the `Fix Missing Media` operator.
+ +![image info](/media/addons/blender_kitsu/sqe_fix_metadata_media.jpg) + ##### Push In the `Push` panel you will find all the operators that push data to Kitsu.
-- 2.30.2