Fix: Missing Metadata Strip Media #288

Merged
Nick Alberelli merged 3 commits from TinyNick/blender-studio-pipeline:fix/metadatastrip-missing-media into main 2024-05-01 17:18:34 +02:00
2 changed files with 56 additions and 0 deletions
Showing only changes of commit fb9227fdf5 - Show all commits

View File

@ -2059,6 +2059,32 @@ class KITSU_OT_sqe_create_metadata_strip(bpy.types.Operator):
return {"FINISHED"} 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): class KITSU_OT_sqe_add_sequence_color(bpy.types.Operator):
""" """
Adds sequence of active strip to scene.kitsu.sequence_colors collection property 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_pull_edit,
KITSU_OT_sqe_init_strip_start_frame, KITSU_OT_sqe_init_strip_start_frame,
KITSU_OT_sqe_create_metadata_strip, KITSU_OT_sqe_create_metadata_strip,
KITSU_OT_sqe_fix_metadata_strips,
KITSU_OT_sqe_add_sequence_color, KITSU_OT_sqe_add_sequence_color,
KITSU_OT_sqe_scan_for_media_updates, KITSU_OT_sqe_scan_for_media_updates,
KITSU_OT_sqe_change_strip_source, KITSU_OT_sqe_change_strip_source,

View File

@ -46,6 +46,7 @@ from ..sqe.ops import (
KITSU_OT_sqe_pull_edit, KITSU_OT_sqe_pull_edit,
KITSU_OT_sqe_init_strip_start_frame, KITSU_OT_sqe_init_strip_start_frame,
KITSU_OT_sqe_create_metadata_strip, KITSU_OT_sqe_create_metadata_strip,
KITSU_OT_sqe_fix_metadata_strips,
KITSU_OT_sqe_add_sequence_color, KITSU_OT_sqe_add_sequence_color,
KITSU_OT_sqe_scan_for_media_updates, KITSU_OT_sqe_scan_for_media_updates,
KITSU_OT_sqe_change_strip_source, KITSU_OT_sqe_change_strip_source,
@ -119,6 +120,9 @@ class KITSU_PT_sqe_shot_tools(bpy.types.Panel):
if self.poll_metadata(context): if self.poll_metadata(context):
self.draw_metadata(context) self.draw_metadata(context)
if self.poll_offline_metadata(context):
self.draw_offline_metadata(context)
if self.poll_multi_edit(context): if self.poll_multi_edit(context):
self.draw_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") 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 @classmethod
def poll_multi_edit(cls, context: bpy.types.Context) -> bool: def poll_multi_edit(cls, context: bpy.types.Context) -> bool:
if not prefs.session_auth(context): if not prefs.session_auth(context):