d
This commit is contained in:
34
metadata.py
34
metadata.py
@@ -3015,6 +3015,40 @@ def process_tags_from_string(tags_str: str, expand_lists: bool = False) -> Set[s
|
||||
return tags_set
|
||||
|
||||
|
||||
def build_book_tags(
|
||||
*,
|
||||
title: Optional[str] = None,
|
||||
author: Optional[str] = None,
|
||||
isbn: Optional[str] = None,
|
||||
year: Optional[str] = None,
|
||||
source: Optional[str] = None,
|
||||
extra: Optional[Sequence[str]] = None,
|
||||
) -> List[str]:
|
||||
"""Build consistent book tags for downloads (LibGen, OpenLibrary, etc.)."""
|
||||
tags: List[str] = ["book"]
|
||||
|
||||
def _add(tag: Optional[str]) -> None:
|
||||
if tag and isinstance(tag, str) and tag.strip():
|
||||
tags.append(tag.strip())
|
||||
|
||||
_add(source)
|
||||
if title:
|
||||
_add(f"title:{title}")
|
||||
if author:
|
||||
_add(f"author:{author}")
|
||||
if isbn:
|
||||
_add(f"isbn:{isbn}")
|
||||
if year:
|
||||
_add(f"year:{year}")
|
||||
if extra:
|
||||
for tag in extra:
|
||||
_add(tag)
|
||||
|
||||
# Deduplicate while preserving order
|
||||
deduped = list(dict.fromkeys(tags))
|
||||
return deduped
|
||||
|
||||
|
||||
def fetch_openlibrary_metadata_tags(isbn: Optional[str] = None, olid: Optional[str] = None) -> List[str]:
|
||||
"""Fetch book metadata from OpenLibrary and return as tags.
|
||||
|
||||
|
||||
Reference in New Issue
Block a user