From 9becd5a06dd32609dd0f274a5c3c86e9086f082d Mon Sep 17 00:00:00 2001 From: Ethanfel Date: Mon, 4 May 2026 11:32:39 +0200 Subject: [PATCH] fix: filter timeline markers by current export folder Subprofile exports (folder_suffix) created markers that interleaved with main folder markers, shifting their numbering. Now get_markers and _get_markers_for accept an export_folder parameter and use SQL LIKE to only return markers whose output_path is in that folder. Co-Authored-By: Claude Opus 4.6 --- core/db.py | 35 ++++++++++++++++++++++++----------- main.py | 13 +++++++++---- 2 files changed, 33 insertions(+), 15 deletions(-) diff --git a/core/db.py b/core/db.py index dfe2cee..773d35d 100644 --- a/core/db.py +++ b/core/db.py @@ -358,14 +358,25 @@ class ProcessedDB: self._con.commit() return paths - def _get_markers_for(self, match: str, profile: str = "default") -> list[tuple[float, int, str, float]]: - rows = self._con.execute( - "SELECT start_time, output_path, clip_duration, clip_count, spread" - " FROM processed" - " WHERE filename = ? AND profile = ? AND scan_export = 0" - " ORDER BY start_time", - (match, profile), - ).fetchall() + def _get_markers_for(self, match: str, profile: str = "default", + export_folder: str = "") -> list[tuple[float, int, str, float]]: + if export_folder: + rows = self._con.execute( + "SELECT start_time, output_path, clip_duration, clip_count, spread" + " FROM processed" + " WHERE filename = ? AND profile = ? AND scan_export = 0" + " AND output_path LIKE ?" + " ORDER BY start_time", + (match, profile, export_folder.rstrip("/") + "/%"), + ).fetchall() + else: + rows = self._con.execute( + "SELECT start_time, output_path, clip_duration, clip_count, spread" + " FROM processed" + " WHERE filename = ? AND profile = ? AND scan_export = 0" + " ORDER BY start_time", + (match, profile), + ).fetchall() seen_times: dict[float, tuple[float, int, str, float]] = {} n = 0 for t, p, dur, cnt, spr in rows: @@ -375,13 +386,15 @@ class ProcessedDB: seen_times[t] = (t, n, p, span) return list(seen_times.values()) - def get_markers(self, filename: str, profile: str = "default") -> list[tuple[float, int, str, float]]: + def get_markers(self, filename: str, profile: str = "default", + export_folder: str = "") -> list[tuple[float, int, str, float]]: """Return [(start_time, marker_number, output_path, clip_span), ...] for exact filename match, sorted by start_time. Empty list if no match. - Excludes scan exports (shown via scan panel instead).""" + Excludes scan exports (shown via scan panel instead). + If export_folder is set, only markers in that folder are returned.""" if not self._enabled: return [] - return self._get_markers_for(filename, profile) + return self._get_markers_for(filename, profile, export_folder) def get_manual_export_groups(self, filename: str, profile: str = "default" ) -> list[dict]: diff --git a/main.py b/main.py index cc23f62..4471999 100755 --- a/main.py +++ b/main.py @@ -46,15 +46,18 @@ class _DBWorker(QThread): """Runs ProcessedDB fuzzy-match lookup off the main thread.""" result = pyqtSignal(str, object, list) # (queried_filename, match|None, markers) - def __init__(self, db: "ProcessedDB", filename: str, profile: str = "default"): + def __init__(self, db: "ProcessedDB", filename: str, profile: str = "default", + export_folder: str = ""): super().__init__() self._db = db self._filename = filename self._profile = profile + self._export_folder = export_folder def run(self): try: - markers = self._db._get_markers_for(self._filename, self._profile) + markers = self._db._get_markers_for( + self._filename, self._profile, self._export_folder) except Exception: markers = [] self.result.emit(self._filename, self._filename if markers else None, markers) @@ -4193,7 +4196,8 @@ class MainWindow(QMainWindow): # Run DB fuzzy match off the main thread — can be slow on large databases. filename = os.path.basename(self._file_path) - self._db_worker = _DBWorker(self._db, filename, self._profile) + self._db_worker = _DBWorker(self._db, filename, self._profile, + self._txt_folder.text()) self._db_worker.result.connect(self._on_db_result) self._db_worker.start() @@ -4209,7 +4213,8 @@ class MainWindow(QMainWindow): def _refresh_markers(self) -> None: filename = os.path.basename(self._file_path) - markers = self._db.get_markers(filename, self._profile) + markers = self._db.get_markers(filename, self._profile, + self._txt_folder.text()) self._timeline.set_markers(markers) def _refresh_playlist_checks(self) -> None: