feat: Add order extraction from filename and integrate into proposed name formatting

This commit is contained in:
sha
2025-12-26 20:42:52 +00:00
parent 2dce807984
commit b21308c7b8
6 changed files with 56 additions and 1 deletions
+3
View File
@@ -10,6 +10,9 @@ class DefaultExtractor:
def extract_source(self):
return None
def extract_order(self):
return None
def extract_resolution(self):
return None
+29
View File
@@ -73,6 +73,13 @@ class FilenameExtractor:
# Remove bracketed prefixes like [01.1], [1], etc.
title = re.sub(r'^\s*\[[^\]]+\]\s*', '', title)
# Remove order number prefixes like 01., 1., 1.1 followed by space/underscore
title = re.sub(r'^\s*(\d+(?:\.\d+)?)\.(?=\s|_|$)', '', title)
title = re.sub(r'^\s*(\d+(?:\.\d+)?)(?=\s|_)', '', title)
# Clean up any remaining leading separators
title = title.lstrip('_ \t')
# Clean up title: remove leading/trailing brackets and dots
title = title.strip('[](). ')
@@ -114,6 +121,28 @@ class FilenameExtractor:
return src
return None
def extract_order(self) -> str | None:
"""Extract collection order number from filename (at the beginning)"""
# Look for order patterns at the start of filename
# Patterns: [01], [01.1], 01., 1., 1.1 followed by space or underscore
# Check for bracketed patterns: [01], [01.1], etc.
bracket_match = re.match(r'^\[(\d+(?:\.\d+)?)\]', self.file_name)
if bracket_match:
return bracket_match.group(1)
# Check for dot patterns: 01., 1., 1.1 followed by space, underscore, or end of string
dot_match = re.match(r'^(\d+(?:\.\d+)?)\.(?=\s|_|$)', self.file_name)
if dot_match:
return dot_match.group(1)
# Check for number followed by space or underscore (like "1.1 " at start)
space_match = re.match(r'^(\d+(?:\.\d+)?)(?=\s|_)', self.file_name)
if space_match:
return space_match.group(1)
return None
def extract_frame_class(self) -> str | None:
"""Extract frame class from filename (480p, 720p, 1080p, 2160p, etc.)"""
# First check for specific numeric resolutions