Skip to content

Commit 5459678

Browse files
refactor: Improve video metadata handling and cluster ID validation in UI components
1 parent 81a1cd5 commit 5459678

File tree

4 files changed

+14
-17
lines changed

4 files changed

+14
-17
lines changed

src/core/metadata_processor.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,15 @@ def _init_result_dict() -> Dict[str, Any]:
337337
os.path.basename(operational_path),
338338
)
339339
video_metadata = _build_basic_video_metadata(operational_path)
340+
if isinstance(video_metadata, dict):
341+
if (
342+
video_metadata.get("file_path") != cache_key_path
343+
and "operational_path" not in video_metadata
344+
):
345+
video_metadata["operational_path"] = video_metadata.get(
346+
"file_path"
347+
)
348+
video_metadata["file_path"] = cache_key_path
340349
results[cache_key_path]["raw_metadata"] = video_metadata
341350
if exif_disk_cache:
342351
exif_disk_cache.set(cache_key_path, video_metadata)

src/core/similarity_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def _get_raw_dimensions(image_path: str) -> Tuple[int, int] | None:
3535
getattr(sizes, "height", 0) or getattr(sizes, "iheight", 0) or 0
3636
)
3737
flip = int(getattr(sizes, "flip", 0) or 0)
38-
if flip in {5, 6}:
38+
if flip in {5, 6, 7, 8}:
3939
width, height = height, width
4040

4141
if width > 0 and height > 0:

src/ui/ui_components.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,10 @@ def _is_cluster_drop_valid(self, event) -> bool:
120120
return False
121121

122122
item_data = item.data(Qt.ItemDataRole.UserRole)
123-
return isinstance(item_data, str) and item_data.startswith("cluster_header_")
123+
if not (isinstance(item_data, str) and item_data.startswith("cluster_header_")):
124+
return False
125+
126+
return self._get_cluster_id_from_index(proxy_index) is not None
124127

125128
def _get_cluster_id_from_index(self, proxy_index) -> Optional[int]:
126129
"""Extract cluster ID from a cluster header item."""

todo.md

Lines changed: 0 additions & 15 deletions
This file was deleted.

0 commit comments

Comments
 (0)