Blender 5.0 compat + STB XML import + sequence/stamps improvements
- Fix Blender 5.0 API: active_sequence_strip → active_strip, bracket property access on AddonPreferences, _RestrictContext during register() - Fix new_effect() frame_end → length for Blender 5.0 - Fix OTIO adapter kwargs (rate/ignore_timecode_mismatch only for cmx_3600) - Fix OTIO global_start_time RationalTime → int conversion - Add Import STB XML operator with movie strip import and XML patching for Storyboard Pro transitions missing <alignment> - Add Create Sequence Strip operator (select shots → create sequence) - Improve Set Stamps: channel at top, no conflict with existing strips, use raw strip names in templates - TVSHOW episode fixes: sequence loading, episode creation - Kitsu: new_asset, new_episode, admin_connect fix, gazu version pin - Fix escape warnings in file_utils regex patterns - Guard handler registration against duplicates Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
+137
-41
@@ -35,7 +35,7 @@ class VSETB_OT_rename(Operator):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
settings = get_scene_settings()
|
||||
strip = context.active_sequence_strip
|
||||
strip = context.active_strip
|
||||
return settings.active_project and get_channel_name(strip) in ('Shots', 'Sequences')
|
||||
|
||||
def invoke(self, context, event):
|
||||
@@ -54,7 +54,7 @@ class VSETB_OT_rename(Operator):
|
||||
sequence = str(project.sequence_start_number).zfill(project.sequence_padding)
|
||||
shot = str(project.shot_start_number).zfill(project.shot_padding)
|
||||
|
||||
strip = context.active_sequence_strip
|
||||
strip = context.active_strip
|
||||
channel_name = get_channel_name(strip)
|
||||
|
||||
col = layout.column()
|
||||
@@ -89,7 +89,7 @@ class VSETB_OT_rename(Operator):
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
strip = context.active_sequence_strip
|
||||
strip = context.active_strip
|
||||
channel_name = get_channel_name(strip)
|
||||
|
||||
strips = get_strips(channel=channel_name, selected_only=self.selected_only)
|
||||
@@ -208,15 +208,15 @@ class VSETB_OT_scene_cut_detection(Operator):
|
||||
self.destination_channel_name = 'Shots'
|
||||
|
||||
# Select active channel by default
|
||||
if (strip := context.active_sequence_strip) and get_channel_name(strip) != 'Shots':
|
||||
if (strip := context.active_strip) and get_channel_name(strip) != 'Shots':
|
||||
self.source_channel_name = get_channel_name(strip)
|
||||
|
||||
self.frame_start = context.scene.frame_start
|
||||
self.frame_end = context.scene.frame_end
|
||||
|
||||
if context.selected_sequences:
|
||||
self.frame_start = min([s.frame_final_start for s in context.selected_sequences])
|
||||
self.frame_end = max([s.frame_final_end for s in context.selected_sequences])
|
||||
if context.selected_strips:
|
||||
self.frame_start = min([s.frame_final_start for s in context.selected_strips])
|
||||
self.frame_end = max([s.frame_final_end for s in context.selected_strips])
|
||||
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
@@ -318,12 +318,22 @@ class VSETB_OT_set_stamps(Operator):
|
||||
scn = context.scene
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
#strip_settings = get_strip_settings()
|
||||
channel_index = get_channel_index('Stamps')
|
||||
|
||||
# Remove existing stamps
|
||||
for strip in get_strips('Stamps'):
|
||||
if strip.type == 'META':
|
||||
scn.sequence_editor.sequences.remove(strip)
|
||||
scn.sequence_editor.strips.remove(strip)
|
||||
|
||||
# Ensure a Stamps channel exists at the top
|
||||
stamps_channel = get_channel_index('Stamps')
|
||||
if stamps_channel == 0:
|
||||
# Find the highest used channel and place Stamps above it
|
||||
all_strips = list(scn.sequence_editor.strips)
|
||||
max_channel = max((s.channel for s in all_strips), default=0)
|
||||
stamps_channel = max_channel + 1
|
||||
channels = scn.sequence_editor.channels
|
||||
if stamps_channel < len(channels):
|
||||
channels[stamps_channel].name = 'Stamps'
|
||||
|
||||
bpy.ops.sequencer.select_all(action='DESELECT')
|
||||
|
||||
@@ -336,7 +346,9 @@ class VSETB_OT_set_stamps(Operator):
|
||||
|
||||
crop_x = int(width * 0.4)
|
||||
crop_max_y = int(height - font_size*2)
|
||||
#crop_min_y = int(scn.render.resolution_y * 0.01)
|
||||
|
||||
# Use temporary high channels for text strips before meta grouping
|
||||
tmp_base = stamps_channel + 1
|
||||
|
||||
stamp_params = dict(start=scn.frame_start, end=scn.frame_end,
|
||||
font_size=font_size, y=margin, box_margin=box_margin, select=True, box_color=(0, 0, 0, 0.5))
|
||||
@@ -344,33 +356,32 @@ class VSETB_OT_set_stamps(Operator):
|
||||
# Project Name
|
||||
project_text = '{project}'
|
||||
if project.type == 'TVSHOW':
|
||||
project_text = '{project} / ep{episode}'
|
||||
project_strip_stamp = new_text_strip('project_stamp', channel=1, **stamp_params,
|
||||
text=project_text, x=0.01, align_x='LEFT', align_y='BOTTOM')
|
||||
project_text = '{project} / ep {episode}'
|
||||
project_strip_stamp = new_text_strip('project_stamp', channel=tmp_base, **stamp_params,
|
||||
text=project_text, x=0.01, anchor_x='LEFT', anchor_y='BOTTOM')
|
||||
|
||||
project_strip_stamp.crop.max_x = crop_x * 2
|
||||
project_strip_stamp.crop.max_y = crop_max_y
|
||||
|
||||
# Shot Name
|
||||
|
||||
shot_strip_stamp = new_text_strip('shot_stamp', channel=2, **stamp_params,
|
||||
text='sq{sequence} / sh{shot}', align_y='BOTTOM')
|
||||
shot_strip_stamp = new_text_strip('shot_stamp', channel=tmp_base + 1, **stamp_params,
|
||||
text='{sequence_strip} / {strip}', anchor_y='BOTTOM')
|
||||
|
||||
shot_strip_stamp.crop.min_x = crop_x
|
||||
shot_strip_stamp.crop.max_x = crop_x
|
||||
shot_strip_stamp.crop.max_y = crop_max_y
|
||||
|
||||
# Frame
|
||||
frame_strip_stamp = new_text_strip('frame_stamp', channel=3, **stamp_params,
|
||||
text='{shot_frame} / {shot_duration} {timecode}', x=0.99, align_x='RIGHT', align_y='BOTTOM')
|
||||
frame_strip_stamp = new_text_strip('frame_stamp', channel=tmp_base + 2, **stamp_params,
|
||||
text='{shot_frame} / {shot_duration} {timecode}', x=0.99, anchor_x='RIGHT', anchor_y='BOTTOM')
|
||||
|
||||
frame_strip_stamp.crop.min_x = crop_x *2
|
||||
frame_strip_stamp.crop.max_y = crop_max_y
|
||||
|
||||
bpy.ops.sequencer.meta_make()
|
||||
stamps_strip = context.active_sequence_strip
|
||||
stamps_strip = context.active_strip
|
||||
stamps_strip.name = 'Stamps'
|
||||
stamps_strip.channel = channel_index
|
||||
stamps_strip.channel = stamps_channel
|
||||
|
||||
#stamps_strip = scn.sequence_editor.sequences.new_meta('Stamps', scn.frame_start, scn.frame_end)
|
||||
#stamps_strip.channel = get_channel_index('Stamps')
|
||||
@@ -397,7 +408,7 @@ class VSETB_OT_previous_shot(Operator):
|
||||
active_strip_index = strips.index(active_strip)
|
||||
next_shot = strips[active_strip_index - 1]
|
||||
context.scene.frame_set(next_shot.frame_final_start)
|
||||
|
||||
|
||||
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||
next_shot.select = True
|
||||
context.scene.sequence_editor.active_strip = next_shot
|
||||
@@ -424,10 +435,10 @@ class VSETB_OT_next_shot(Operator):
|
||||
active_strip_index = strips.index(active_strip)
|
||||
next_shot = strips[active_strip_index + 1]
|
||||
context.scene.frame_set(next_shot.frame_final_start)
|
||||
|
||||
|
||||
bpy.ops.sequencer.select_all(action="DESELECT")
|
||||
next_shot.select = True
|
||||
context.active_sequence_strip = next_shot
|
||||
context.scene.sequence_editor.active_strip = next_shot
|
||||
|
||||
return {"FINISHED"}
|
||||
|
||||
@@ -440,7 +451,7 @@ class VSETB_OT_open_strip_folder(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
strip = context.active_sequence_strip
|
||||
strip = context.active_strip
|
||||
if not strip:
|
||||
cls.poll_message_set('No active')
|
||||
return
|
||||
@@ -458,7 +469,7 @@ class VSETB_OT_open_strip_folder(Operator):
|
||||
'Sequences': 'sequence_dir'
|
||||
}
|
||||
|
||||
strip = context.active_sequence_strip
|
||||
strip = context.active_strip
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
@@ -501,12 +512,12 @@ class VSETB_OT_collect_files(Operator):
|
||||
cls.poll_message_set('Save the blend to collect files')
|
||||
|
||||
def execute(self, context):
|
||||
strip = context.active_sequence_strip
|
||||
strip = context.active_strip
|
||||
settings = get_scene_settings()
|
||||
project = settings.active_project
|
||||
|
||||
|
||||
strips = [s for s in context.scene.sequence_editor.sequences_all if s.type in ('MOVIE', 'SOUND')]
|
||||
strips = [s for s in context.scene.sequence_editor.strips_all if s.type in ('MOVIE', 'SOUND')]
|
||||
context.window_manager.progress_begin(0, len(strips))
|
||||
|
||||
for i, strip in enumerate(strips):
|
||||
@@ -556,18 +567,18 @@ class VSETB_OT_insert_channel(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.active_sequence_strip
|
||||
return context.active_strip
|
||||
|
||||
def execute(self, context):
|
||||
scn = context.scene
|
||||
channel_index = context.active_sequence_strip.channel
|
||||
channel_index = context.active_strip.channel
|
||||
|
||||
strips = list(scn.sequence_editor.sequences)
|
||||
strips = list(scn.sequence_editor.strips)
|
||||
|
||||
for strip in sorted(strips, key=lambda x: x.channel, reverse=True):
|
||||
if strip.channel >= channel_index:
|
||||
strip.channel += 1
|
||||
|
||||
|
||||
channels = {i: (c.name, c.lock, c.mute) for i, c in enumerate(scn.sequence_editor.channels)}
|
||||
for i in sorted(channels.keys()):
|
||||
channel = scn.sequence_editor.channels[i]
|
||||
@@ -599,16 +610,16 @@ class VSETB_OT_remove_channel(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
return context.active_sequence_strip
|
||||
return context.active_strip
|
||||
|
||||
def execute(self, context):
|
||||
scn = context.scene
|
||||
channel_index = context.active_sequence_strip.channel
|
||||
channel_index = context.active_strip.channel
|
||||
|
||||
if [s for s in scn.sequence_editor.sequences if s.channel == channel_index-1]:
|
||||
if [s for s in scn.sequence_editor.strips if s.channel == channel_index-1]:
|
||||
self.report({"WARNING"}, "Channel Bellow not empty")
|
||||
|
||||
strips = list(scn.sequence_editor.sequences)
|
||||
strips = list(scn.sequence_editor.strips)
|
||||
|
||||
for strip in sorted(strips, key=lambda x: x.channel):
|
||||
if strip.channel >= channel_index:
|
||||
@@ -709,7 +720,7 @@ class VSETB_OT_merge_shot_strips(Operator):
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
|
||||
selected_strips = bpy.context.selected_sequences
|
||||
selected_strips = bpy.context.selected_strips
|
||||
if len(selected_strips) <= 1:
|
||||
return False
|
||||
|
||||
@@ -717,16 +728,100 @@ class VSETB_OT_merge_shot_strips(Operator):
|
||||
|
||||
def execute(self, context):
|
||||
|
||||
selected_strips = bpy.context.selected_sequences
|
||||
selected_strips = bpy.context.selected_strips
|
||||
last_frame = selected_strips[-1].frame_final_end
|
||||
|
||||
for i in range(1, len(selected_strips)):
|
||||
context.scene.sequence_editor.sequences.remove(selected_strips[i])
|
||||
context.scene.sequence_editor.strips.remove(selected_strips[i])
|
||||
|
||||
selected_strips[0].frame_final_end = last_frame
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class VSETB_OT_create_sequence_strip(Operator):
|
||||
"""Create a sequence strip spanning the selected shot strips."""
|
||||
|
||||
bl_idname = "vse_toolbox.create_sequence_strip"
|
||||
bl_label = "Create Sequence Strip"
|
||||
bl_options = {"REGISTER", "UNDO"}
|
||||
|
||||
sequence_name: StringProperty(
|
||||
name="Sequence Name",
|
||||
description="Name of the sequence (e.g. SC010)",
|
||||
default="SC010",
|
||||
)
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
selected = context.selected_strips
|
||||
if not selected:
|
||||
cls.poll_message_set('No strips selected')
|
||||
return False
|
||||
if not any(get_channel_name(s) == 'Shots' for s in selected):
|
||||
cls.poll_message_set('Select strips on the Shots channel')
|
||||
return False
|
||||
return True
|
||||
|
||||
def invoke(self, context, event):
|
||||
return context.window_manager.invoke_props_dialog(self)
|
||||
|
||||
def execute(self, context):
|
||||
shot_strips = sorted(
|
||||
[s for s in context.selected_strips if get_channel_name(s) == 'Shots'],
|
||||
key=lambda s: s.frame_final_start,
|
||||
)
|
||||
|
||||
if not shot_strips:
|
||||
self.report({'ERROR'}, "No shot strips selected")
|
||||
return {'CANCELLED'}
|
||||
|
||||
scn = context.scene
|
||||
seq_channel = get_channel_index('Sequences')
|
||||
if seq_channel == 0:
|
||||
# Insert a Sequences channel below the Shots channel
|
||||
shots_channel = get_channel_index('Shots')
|
||||
if not shots_channel:
|
||||
self.report({'ERROR'}, "No 'Shots' channel found")
|
||||
return {'CANCELLED'}
|
||||
|
||||
seq_channel = shots_channel
|
||||
# Push all strips at or above this channel up by one
|
||||
all_strips = list(scn.sequence_editor.strips)
|
||||
for s in sorted(all_strips, key=lambda x: x.channel, reverse=True):
|
||||
if s.channel >= seq_channel:
|
||||
s.channel += 1
|
||||
|
||||
# Shift channel names up
|
||||
channels = scn.sequence_editor.channels
|
||||
chan_data = {i: (c.name, c.lock, c.mute) for i, c in enumerate(channels)}
|
||||
for i in sorted(chan_data.keys(), reverse=True):
|
||||
if i >= seq_channel:
|
||||
prev = chan_data[i]
|
||||
ch = channels[i + 1] if (i + 1) < len(channels) else None
|
||||
if ch:
|
||||
ch.name, ch.lock, ch.mute = prev
|
||||
|
||||
channels[seq_channel].name = 'Sequences'
|
||||
channels[seq_channel].lock = False
|
||||
channels[seq_channel].mute = False
|
||||
|
||||
frame_start = shot_strips[0].frame_final_start
|
||||
frame_end = shot_strips[-1].frame_final_end
|
||||
|
||||
strip = scn.sequence_editor.strips.new_effect(
|
||||
name=self.sequence_name,
|
||||
type='COLOR',
|
||||
channel=seq_channel,
|
||||
frame_start=frame_start,
|
||||
length=frame_end - frame_start,
|
||||
)
|
||||
strip.blend_alpha = 0
|
||||
strip.color_tag = 'COLOR_07' # Purple
|
||||
|
||||
self.report({'INFO'}, f"Created sequence '{self.sequence_name}' ({len(shot_strips)} shots)")
|
||||
return {"FINISHED"}
|
||||
|
||||
|
||||
class VSETB_OT_update_media(Operator):
|
||||
bl_idname = "vse_toolbox.update_media"
|
||||
bl_label = "Update Media"
|
||||
@@ -735,7 +830,7 @@ class VSETB_OT_update_media(Operator):
|
||||
|
||||
@classmethod
|
||||
def poll(cls, context):
|
||||
if not (strip := context.active_sequence_strip) or strip.type not in ('MOVIE', 'SOUND'):
|
||||
if not (strip := context.active_strip) or strip.type not in ('MOVIE', 'SOUND'):
|
||||
cls.poll_message_set('No active AUDIO or MOVIE strips')
|
||||
return
|
||||
|
||||
@@ -744,7 +839,7 @@ class VSETB_OT_update_media(Operator):
|
||||
return True
|
||||
|
||||
def execute(self, context):
|
||||
for strip in context.selected_sequences:
|
||||
for strip in context.selected_strips:
|
||||
current_movie = Path(abspath(bpy.path.abspath(strip.filepath)))
|
||||
pattern_name = re.sub(r'[^\s._\?]+', '*', current_movie.name)
|
||||
|
||||
@@ -801,6 +896,7 @@ classes = (
|
||||
VSETB_OT_insert_channel,
|
||||
VSETB_OT_remove_channel,
|
||||
VSETB_OT_merge_shot_strips,
|
||||
VSETB_OT_create_sequence_strip,
|
||||
VSETB_OT_update_media,
|
||||
WM_OT_split_view,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user