j
This commit is contained in:
@@ -87,6 +87,7 @@ class Get_Metadata(Cmdlet):
|
||||
url: list[str],
|
||||
hash_value: Optional[str],
|
||||
pages: Optional[int] = None,
|
||||
tag: Optional[List[str]] = None,
|
||||
) -> Dict[str,
|
||||
Any]:
|
||||
"""Build a table row dict with metadata fields."""
|
||||
@@ -142,6 +143,7 @@ class Get_Metadata(Cmdlet):
|
||||
"imported": imported_label,
|
||||
"hash": hash_value,
|
||||
"url": url,
|
||||
"tag": tag or [],
|
||||
"columns": columns,
|
||||
}
|
||||
|
||||
@@ -220,16 +222,30 @@ class Get_Metadata(Cmdlet):
|
||||
|
||||
# Extract title from tags if available
|
||||
title = get_field(result, "title") or file_hash[:16]
|
||||
if not get_field(result, "title"):
|
||||
# Try to get title from tags
|
||||
try:
|
||||
tags, _ = backend.get_tag(file_hash)
|
||||
for tag in tags:
|
||||
if tag.lower().startswith("title:"):
|
||||
title = tag.split(":", 1)[1]
|
||||
break
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Get tags from input result
|
||||
item_tags = get_field(result, "tag") or get_field(result, "tags") or []
|
||||
if not isinstance(item_tags, list):
|
||||
item_tags = [str(item_tags)]
|
||||
else:
|
||||
item_tags = [str(t) for t in item_tags]
|
||||
|
||||
# Try to enrich tags and title from backend
|
||||
try:
|
||||
backend_tags, _ = backend.get_tag(file_hash)
|
||||
if backend_tags:
|
||||
for t in backend_tags:
|
||||
ts = str(t)
|
||||
if ts not in item_tags:
|
||||
item_tags.append(ts)
|
||||
|
||||
# Also check for title tag if we don't have a title yet
|
||||
if not get_field(result, "title") and ts.lower().startswith("title:"):
|
||||
parts = ts.split(":", 1)
|
||||
if len(parts) > 1:
|
||||
title = parts[1].strip()
|
||||
except Exception:
|
||||
pass
|
||||
|
||||
# Extract metadata fields
|
||||
mime_type = metadata.get("mime") or metadata.get("ext", "")
|
||||
@@ -292,6 +308,7 @@ class Get_Metadata(Cmdlet):
|
||||
url=url,
|
||||
hash_value=file_hash,
|
||||
pages=pages,
|
||||
tag=item_tags,
|
||||
)
|
||||
|
||||
table_title = f"get-metadata: {title}" if title else "get-metadata"
|
||||
|
||||
Reference in New Issue
Block a user