From 48d8c740d0ecdd58ea1286725e4488fab20e88c0 Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Sat, 17 Jan 2026 15:09:51 +0100 Subject: [PATCH] Update tab_time_discovery.py --- tab_time_discovery.py | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/tab_time_discovery.py b/tab_time_discovery.py index 65e0f41..7108c3b 100644 --- a/tab_time_discovery.py +++ b/tab_time_discovery.py @@ -4,6 +4,7 @@ from engine import SorterEngine def render(path_t, quality, threshold, id_prefix): images = SorterEngine.get_images(path_t) + # Filter for files that haven't been matched yet unmatched = [f for f in images if not f.startswith("id")] if st.session_state.idx_time < len(unmatched): @@ -14,9 +15,11 @@ def render(path_t, quality, threshold, id_prefix): st.subheader(f"Discovery: {t_file} ({st.session_state.idx_time + 1}/{len(unmatched)})") st.image(SorterEngine.compress_for_web(t_path, quality)) - # Sibling scanning + # Multi-folder sibling matching parent = os.path.dirname(path_t) - siblings = [os.path.join(parent, d) for d in os.listdir(parent) if os.path.isdir(os.path.join(parent, d)) and os.path.abspath(os.path.join(parent, d)) != os.path.abspath(path_t)] + siblings = [os.path.join(parent, d) for d in os.listdir(parent) + if os.path.isdir(os.path.join(parent, d)) and + os.path.abspath(os.path.join(parent, d)) != os.path.abspath(path_t)] matches = [] for folder in siblings: @@ -24,20 +27,23 @@ def render(path_t, quality, threshold, id_prefix): c_path = os.path.join(folder, c_file) delta = abs(t_time - os.path.getmtime(c_path)) if delta <= threshold: - matches.append({'path': c_path, 'delta': delta}) + matches.append({'path': c_path, 'delta': delta, 'folder': os.path.basename(folder)}) - if not matches: st.warning("No matches found.") + if not matches: st.warning("No time-sync matches found in sibling folders.") + for m in sorted(matches, key=lambda x: x['delta']): with st.container(border=True): col1, col2 = st.columns([1, 2]) col1.image(SorterEngine.compress_for_web(m['path'], 20)) with col2: - st.write(f"Delta: {m['delta']:.1f}s") + st.write(f"**Folder:** {m['folder']} | **Δ:** {m['delta']:.1f}s") if st.button("MATCH", key=m['path']): - # Logic to move/rename + # Logic to move/rename would go here st.session_state.idx_time += 1 st.rerun() - if st.button("SKIP"): + + if st.button("SKIP", use_container_width=True): st.session_state.idx_time += 1 st.rerun() - else: st.success("All files reviewed.") \ No newline at end of file + else: + st.success("All images in the target folder have been reviewed.") \ No newline at end of file