Update tab_time_discovery.py

This commit is contained in:
2026-01-17 15:09:51 +01:00
parent a31840e701
commit 48d8c740d0

View File

@@ -4,6 +4,7 @@ from engine import SorterEngine
def render(path_t, quality, threshold, id_prefix): def render(path_t, quality, threshold, id_prefix):
images = SorterEngine.get_images(path_t) 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")] unmatched = [f for f in images if not f.startswith("id")]
if st.session_state.idx_time < len(unmatched): 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.subheader(f"Discovery: {t_file} ({st.session_state.idx_time + 1}/{len(unmatched)})")
st.image(SorterEngine.compress_for_web(t_path, quality)) st.image(SorterEngine.compress_for_web(t_path, quality))
# Sibling scanning # Multi-folder sibling matching
parent = os.path.dirname(path_t) 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 = [] matches = []
for folder in siblings: for folder in siblings:
@@ -24,20 +27,23 @@ def render(path_t, quality, threshold, id_prefix):
c_path = os.path.join(folder, c_file) c_path = os.path.join(folder, c_file)
delta = abs(t_time - os.path.getmtime(c_path)) delta = abs(t_time - os.path.getmtime(c_path))
if delta <= threshold: 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 time-sync matches found in sibling folders.")
if not matches: st.warning("No matches found.")
for m in sorted(matches, key=lambda x: x['delta']): for m in sorted(matches, key=lambda x: x['delta']):
with st.container(border=True): with st.container(border=True):
col1, col2 = st.columns([1, 2]) col1, col2 = st.columns([1, 2])
col1.image(SorterEngine.compress_for_web(m['path'], 20)) col1.image(SorterEngine.compress_for_web(m['path'], 20))
with col2: 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']): 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.session_state.idx_time += 1
st.rerun() st.rerun()
if st.button("SKIP"):
if st.button("SKIP", use_container_width=True):
st.session_state.idx_time += 1 st.session_state.idx_time += 1
st.rerun() st.rerun()
else: st.success("All files reviewed.") else:
st.success("All images in the target folder have been reviewed.")