From 23093a72e7089ac87a15b0b9954c9f12b7c1743e Mon Sep 17 00:00:00 2001 From: "florentin.luce" Date: Thu, 19 Dec 2024 16:15:34 +0100 Subject: [PATCH] update media operator --- operators/sequencer.py | 31 ++++++++++++++++++++++++++++++- ui/panels.py | 4 +++- 2 files changed, 33 insertions(+), 2 deletions(-) diff --git a/operators/sequencer.py b/operators/sequencer.py index 8800922..b2b5ef6 100644 --- a/operators/sequencer.py +++ b/operators/sequencer.py @@ -10,7 +10,7 @@ from vse_toolbox.sequencer_utils import (get_strips, rename_strips, set_channels create_shot_strip) from vse_toolbox import auto_splitter -from vse_toolbox.bl_utils import get_scene_settings, get_strip_settings +from vse_toolbox.bl_utils import get_scene_settings, get_strip_settings, get_addon_prefs from shutil import copy2 @@ -695,6 +695,34 @@ class VSETB_OT_merge_shot_strips(Operator): return {"FINISHED"} +class VSETB_OT_update_media(Operator): + bl_idname = "vse_toolbox.update_media" + bl_label = "Update Media" + bl_description = "Update selected source" + bl_options = {"REGISTER", "UNDO"} + + @classmethod + def poll(cls, context): + if context.active_sequence_strip .type not in ('MOVIE', 'SOUND'): + cls.poll_message_set('No active AUDIO or MOVIE strips') + return + + prefs = get_addon_prefs() + if prefs.tracker: + return True + + def execute(self, context): + for strip in context.selected_sequences: + current_movie = Path(abspath(bpy.path.abspath(strip.filepath))) + latest_file = sorted(list(current_movie.parent.glob('*.*')))[-1] + + if latest_file != current_movie: + print(latest_file) + strip.filepath = str(latest_file) + + return {'FINISHED'} + + addon_keymaps = [] def register_keymaps(): addon = bpy.context.window_manager.keyconfigs.addon @@ -739,6 +767,7 @@ classes = ( VSETB_OT_insert_channel, VSETB_OT_remove_channel, VSETB_OT_merge_shot_strips, + VSETB_OT_update_media, WM_OT_split_view, ) diff --git a/ui/panels.py b/ui/panels.py index c4e3172..494e115 100644 --- a/ui/panels.py +++ b/ui/panels.py @@ -447,8 +447,10 @@ class VSETB_MT_main_menu(Menu): op.filepath = str(REVIEW_TEMPLATE_BLEND) layout.operator("wm.split_view", icon="ARROW_LEFTRIGHT") - layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER') + layout.separator() + layout.operator('vse_toolbox.update_media', text='Update Media', icon='FILE_REFRESH') layout.operator('vse_toolbox.open_shot_on_tracker', text='Open Shot on Tracker', icon='URL') + layout.operator('vse_toolbox.open_strip_folder', text='Open Strip Folder', icon='FILE_FOLDER') layout.separator() layout.operator('vse_toolbox.insert_channel', text='Insert Channel', icon='TRIA_UP_BAR') layout.operator('vse_toolbox.remove_channel', text='Remove Channel', icon='TRIA_DOWN_BAR')