added media catalog mode, impooved cache

This commit is contained in:
sha
2025-12-29 19:47:55 +00:00
parent eedc32bf31
commit 50de7e1d4a
20 changed files with 900 additions and 106 deletions
+13 -30
View File
@@ -1,3 +1,5 @@
from renamer.constants import FRAME_CLASSES
class ResolutionFormatter:
"""Class for formatting video resolutions and frame classes"""
@@ -20,39 +22,20 @@ class ResolutionFormatter:
else:
return 'Unclassified'
if height == 4320:
return '4320p'
elif height >= 2160:
return '2160p'
elif height >= 1440:
return '1440p'
elif height >= 1080:
return '1080p'
elif height >= 720:
return '720p'
elif height >= 576:
return '576p'
elif height >= 480:
return '480p'
else:
return 'Unclassified'
# Find the closest frame class based on nominal height
closest_class = 'Unclassified'
min_diff = float('inf')
for frame_class, info in FRAME_CLASSES.items():
nominal_height = info['nominal_height']
diff = abs(height - nominal_height)
if diff < min_diff:
min_diff = diff
closest_class = frame_class
return closest_class
except (ValueError, IndexError):
return 'Unclassified'
@staticmethod
def format_resolution_p(height: int) -> str:
"""Format resolution as 2160p, 1080p, etc."""
if height >= 2160:
return '2160p'
elif height >= 1080:
return '1080p'
elif height >= 720:
return '720p'
elif height >= 480:
return '480p'
else:
return f'{height}p'
@staticmethod
def format_resolution_dimensions(resolution: tuple[int, int]) -> str:
"""Format resolution as WIDTHxHEIGHT"""