Open Media strip

pull/6/head
florentin.luce 2024-04-25 16:19:25 +02:00
parent a335b28fb1
commit 83268e9ec7
2 changed files with 32 additions and 17 deletions

View File

@ -296,39 +296,54 @@ class VSETB_OT_next_shot(Operator):
return {"FINISHED"} return {"FINISHED"}
class VSETB_OT_open_shot_folder(Operator): class VSETB_OT_open_strip_folder(Operator):
bl_idname = "vse_toolbox.open_shot_folder" bl_idname = "vse_toolbox.open_strip_folder"
bl_label = "Open Shot Folder" bl_label = "Open Strip Folder"
bl_description = "Open Shot Folder" bl_description = "Open selected strip folder"
bl_options = {"REGISTER", "UNDO"} bl_options = {"REGISTER", "UNDO"}
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
settings = get_scene_settings() strip = context.active_sequence_strip
project = settings.active_project if not strip:
if not project.templates.get('shot_dir'): cls.poll_message_set('No active')
cls.poll_message_set('No shot_dir template setted')
return return
strip = context.active_sequence_strip if not any(p in get_channel_name(strip) for p in ('Shots', 'Sequences', 'Movie', 'Video', 'Audio', 'Sound')):
if not strip or get_channel_name(strip) != 'Shots': cls.poll_message_set('Only for Shots, Sequences, Movie and Audio strips')
cls.poll_message_set('No shot strip active')
return return
return True return True
def execute(self, context): def execute(self, context):
tpl_by_channel = {
'Shots': 'shot_dir',
'Sequences': 'sequence_dir'
}
strip = context.active_sequence_strip strip = context.active_sequence_strip
settings = get_scene_settings() settings = get_scene_settings()
project = settings.active_project project = settings.active_project
strip_settings = get_strip_settings() strip_settings = get_strip_settings()
format_data = {**settings.format_data, **project.format_data, **strip_settings.format_data} format_data = {**settings.format_data, **project.format_data, **strip_settings.format_data}
channel_name = get_channel_name(strip)
shot_folder_template = expandvars(project.templates['shot_dir'].value) if strip.type in ('MOVIE', 'IMAGE'):
shot_folder_path = shot_folder_template.format(**format_data) path = Path(strip.filepath)
bpy.ops.wm.path_open(filepath=shot_folder_path)
elif strip.type in ('SOUND'):
path = Path(strip.sound.filepath)
else:
folder_template = expandvars(project.templates[tpl_by_channel[channel_name]].value)
path = Path(folder_template.format(**format_data))
if not path.is_dir():
path = path.parent
bpy.ops.wm.path_open(filepath=str(path))
return {"FINISHED"} return {"FINISHED"}
@ -513,7 +528,7 @@ classes = (
VSETB_OT_show_waveform, VSETB_OT_show_waveform,
VSETB_OT_previous_shot, VSETB_OT_previous_shot,
VSETB_OT_next_shot, VSETB_OT_next_shot,
VSETB_OT_open_shot_folder, VSETB_OT_open_strip_folder,
VSETB_OT_collect_files, VSETB_OT_collect_files,
WM_OT_split_view WM_OT_split_view
) )

View File

@ -446,7 +446,7 @@ class VSETB_MT_main_menu(Menu):
op.filepath = str(REVIEW_TEMPLATE_BLEND) op.filepath = str(REVIEW_TEMPLATE_BLEND)
layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT") layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT")
layout.operator('vse_toolbox.open_shot_folder', text='Open Shot Folder', icon='FILE_FOLDER') layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER')
layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL') layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL')
def draw_vse_toolbox_menu(self, context): def draw_vse_toolbox_menu(self, context):