Tag search

This commit is contained in:
2026-07-26 13:13:38 -07:00
parent 62c06b6254
commit 79c975dd28
5 changed files with 110 additions and 0 deletions
+23
View File
@@ -117,3 +117,26 @@ def parse_indices(indices_str: str) -> List[int]:
except ValueError:
raise ToolError(f"Invalid index format: {part}")
return indices
def format_count(count_str: str) -> str:
"""Formats large numbers into a human-readable string (e.g., 1.2M, 218k)."""
try:
count = int(count_str)
if count >= 1_000_000:
return f"{count / 1_000_000:.1f}M".replace(".0", "")
if count >= 1_000:
return f"{count / 1_000:.0f}k"
return str(count)
except (ValueError, TypeError):
return "0"
def get_type_suffix(type_val: str) -> str:
"""Returns the human-readable suffix for the tag type."""
mapping = {
"0": "", # General
"1": " [Artist]",
"3": " [Copyright]",
"4": " [Character]",
"5": " [Meta]"
}
return mapping.get(str(type_val), f" [Type {type_val}]")