refactor: enhance scan type detection logic and add test case for interlaced 1080i frame class

This commit is contained in:
sHa
2026-01-05 08:51:43 +00:00
parent ab2f67b780
commit ad39632e91
5 changed files with 34 additions and 4 deletions

BIN
dist/renamer-0.8.8-py3-none-any.whl vendored Normal file

Binary file not shown.

View File

@@ -1,6 +1,6 @@
[project]
name = "renamer"
version = "0.8.7"
version = "0.8.8"
description = "Terminal-based media file renamer and metadata viewer"
readme = "README.md"
requires-python = ">=3.11"

View File

@@ -78,9 +78,21 @@ class MediaInfoExtractor:
if not height or not width:
return None
# Check if interlaced
# Check if interlaced - try multiple attributes
# PyMediaInfo may use different attribute names depending on version
scan_type_attr = getattr(self.video_tracks[0], 'scan_type', None)
interlaced = getattr(self.video_tracks[0], 'interlaced', None)
scan_type = 'i' if interlaced == 'Yes' else 'p'
# Determine scan type from available attributes
# Check scan_type first (e.g., "Interlaced", "Progressive", "MBAFF")
if scan_type_attr and isinstance(scan_type_attr, str):
scan_type = 'i' if 'interlaced' in scan_type_attr.lower() else 'p'
# Then check interlaced flag (e.g., "Yes", "No")
elif interlaced and isinstance(interlaced, str):
scan_type = 'i' if interlaced.lower() in ['yes', 'true', '1'] else 'p'
else:
# Default to progressive if no information available
scan_type = 'p'
# Calculate effective height for frame class determination
aspect_ratio = 16 / 9

View File

@@ -2,6 +2,24 @@
"description": "Comprehensive test dataset for filename metadata extraction",
"version": "2.0",
"test_cases": [
{
"filename": "Le Jaguar.(1996).[1080i,3ukr,fra].mkv",
"expected": {
"order": null,
"title": "Le Jaguar",
"year": "1996",
"source": null,
"frame_class": "1080i",
"hdr": null,
"movie_db": null,
"special_info": null,
"audio_langs": "3ukr,fra",
"extension": "mkv"
},
"testname": "edge-frameclass-001",
"category": "edge_cases",
"description": "Interlaced 1080i frame class"
},
{
"filename": "Dumbo.1941.BluRay.1080p.DD5.1.AVC.REMUX.mkv",
"expected": {

2
uv.lock generated
View File

@@ -462,7 +462,7 @@ wheels = [
[[package]]
name = "renamer"
version = "0.8.7"
version = "0.8.8"
source = { editable = "." }
dependencies = [
{ name = "langcodes" },