feat: Bump version to 0.2.7, enhance frame class extraction logic for better matching
This commit is contained in:
BIN
dist/renamer-0.2.7-py3-none-any.whl
vendored
Normal file
BIN
dist/renamer-0.2.7-py3-none-any.whl
vendored
Normal file
Binary file not shown.
@@ -1,6 +1,6 @@
|
|||||||
[project]
|
[project]
|
||||||
name = "renamer"
|
name = "renamer"
|
||||||
version = "0.2.6"
|
version = "0.2.7"
|
||||||
description = "Terminal-based media file renamer and metadata viewer"
|
description = "Terminal-based media file renamer and metadata viewer"
|
||||||
readme = "README.md"
|
readme = "README.md"
|
||||||
requires-python = ">=3.11"
|
requires-python = ">=3.11"
|
||||||
|
|||||||
@@ -22,10 +22,27 @@ class MediaInfoExtractor:
|
|||||||
self.sub_tracks = []
|
self.sub_tracks = []
|
||||||
|
|
||||||
def _get_frame_class_from_height(self, height: int) -> str | None:
|
def _get_frame_class_from_height(self, height: int) -> str | None:
|
||||||
"""Get frame class from video height using FRAME_CLASSES constant"""
|
"""Get frame class from video height, finding closest match if exact not found"""
|
||||||
|
if not height:
|
||||||
|
return None
|
||||||
|
|
||||||
|
# First try exact match
|
||||||
for frame_class, info in FRAME_CLASSES.items():
|
for frame_class, info in FRAME_CLASSES.items():
|
||||||
if height == info['nominal_height']:
|
if height == info['nominal_height']:
|
||||||
return frame_class
|
return frame_class
|
||||||
|
|
||||||
|
# If no exact match, find closest
|
||||||
|
closest = None
|
||||||
|
min_diff = float('inf')
|
||||||
|
for frame_class, info in FRAME_CLASSES.items():
|
||||||
|
diff = abs(height - info['nominal_height'])
|
||||||
|
if diff < min_diff:
|
||||||
|
min_diff = diff
|
||||||
|
closest = frame_class
|
||||||
|
|
||||||
|
# Only return if difference is reasonable (within 50 pixels)
|
||||||
|
if min_diff <= 50:
|
||||||
|
return closest
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def extract_duration(self) -> float | None:
|
def extract_duration(self) -> float | None:
|
||||||
|
|||||||
Reference in New Issue
Block a user