feat: add frame class extraction and formatting for media files

This commit is contained in:
sha
2025-12-25 05:13:56 +00:00
parent 4e7cf94d58
commit 37efdf60d3
7 changed files with 224 additions and 61 deletions
+18 -6
View File
@@ -1,6 +1,7 @@
import pytest
from pathlib import Path
from ..extractors.filename_extractor import FilenameExtractor
from ..constants import FRAME_CLASSES
def load_test_filenames():
@@ -17,6 +18,9 @@ def test_extract_title(filename):
"""Test title extraction from filename"""
file_path = Path(filename)
title = FilenameExtractor.extract_title(file_path)
# Print filename and extracted title clearly
print(f"\nFilename: \033[1;36m{filename}\033[0m")
print(f"Extracted title: \033[1;32m{title}\033[0m")
# For now, just check it's not None and is string
assert isinstance(title, str) or title is None
@@ -39,15 +43,23 @@ def test_extract_source(filename):
"""Test source extraction from filename"""
file_path = Path(filename)
source = FilenameExtractor.extract_source(file_path)
# Print filename and extracted source clearly
print(f"\nFilename: \033[1;36m{filename}\033[0m")
print(f"Extracted source: \033[1;32m{source}\033[0m")
# Source should be None or string
assert isinstance(source, str) or source is None
@pytest.mark.parametrize("filename", load_test_filenames())
def test_extract_resolution(filename):
"""Test resolution extraction from filename"""
def test_extract_frame_class(filename):
"""Test frame class extraction from filename"""
file_path = Path(filename)
resolution = FilenameExtractor.extract_resolution(file_path)
# Resolution should be None or string like '2160p'
if resolution:
assert 'p' in resolution or 'i' in resolution
frame_class = FilenameExtractor.extract_frame_class(file_path)
# Print filename and extracted frame class clearly
print(f"\nFilename: \033[1;36m{filename}\033[0m")
print(f"Extracted frame_class: \033[1;32m{frame_class}\033[0m")
# Frame class should be a string
assert isinstance(frame_class, str)
# Should be one of the valid frame classes or 'Unclassified'
valid_classes = set(FRAME_CLASSES.keys()) | {'Unclassified'}
assert frame_class in valid_classes