Add caption pair target routing
This commit is contained in:
@@ -10,6 +10,7 @@ class CaptionMetadataRouteRequest:
|
||||
row: dict[str, Any]
|
||||
detail_level: str
|
||||
keep_style: bool
|
||||
target: str = "auto"
|
||||
|
||||
|
||||
@dataclass(frozen=True)
|
||||
@@ -46,7 +47,7 @@ class CaptionMetadataRouteDependencies:
|
||||
natural_cast_descriptor_text: Callable[[str], str]
|
||||
cast_labels: Callable[[str], list[str]]
|
||||
natural_label_text: Callable[[Any, list[str]], str]
|
||||
metadata_to_prose: Callable[[dict[str, Any], str, bool], tuple[str, str]]
|
||||
metadata_to_prose: Callable[..., tuple[str, str]]
|
||||
|
||||
|
||||
def pronoun(subject: str) -> str:
|
||||
@@ -300,6 +301,7 @@ def insta_of_pair_from_row_result(
|
||||
row = request.row
|
||||
detail_level = request.detail_level
|
||||
keep_style = request.keep_style
|
||||
target = request.target if request.target in ("softcore", "hardcore") else "auto"
|
||||
if deps.clean_text(row.get("mode")).lower() != "insta/of":
|
||||
return None
|
||||
soft_row = row.get("softcore_row")
|
||||
@@ -315,8 +317,14 @@ def insta_of_pair_from_row_result(
|
||||
if soft_row.get("composition"):
|
||||
hard_row_for_text["composition"] = soft_row["composition"]
|
||||
|
||||
soft_text, _soft_method = deps.metadata_to_prose(soft_row, detail_level, keep_style)
|
||||
hard_text, _hard_method = deps.metadata_to_prose(hard_row_for_text, detail_level, keep_style)
|
||||
include_soft = target in ("auto", "softcore")
|
||||
include_hard = target in ("auto", "hardcore")
|
||||
soft_text = ""
|
||||
hard_text = ""
|
||||
if include_soft:
|
||||
soft_text, _soft_method = deps.metadata_to_prose(soft_row, detail_level, keep_style, "single")
|
||||
if include_hard:
|
||||
hard_text, _hard_method = deps.metadata_to_prose(hard_row_for_text, detail_level, keep_style, "single")
|
||||
descriptor = deps.clean_text(row.get("shared_descriptor"))
|
||||
options = row.get("options") if isinstance(row.get("options"), dict) else {}
|
||||
cast_descriptors = row.get("shared_cast_descriptors")
|
||||
@@ -335,8 +343,11 @@ def insta_of_pair_from_row_result(
|
||||
parts.append(f"A {descriptor}")
|
||||
if cast_descriptor_text and not same_soft_cast:
|
||||
parts.append(deps.natural_cast_descriptor_text(cast_descriptor_text))
|
||||
if same_soft_cast:
|
||||
parts.append("The softcore version keeps the same adult cast present together in a non-explicit teaser setup")
|
||||
if same_soft_cast and include_soft:
|
||||
if target == "auto":
|
||||
parts.append("The softcore version keeps the same adult cast present together in a non-explicit teaser setup")
|
||||
else:
|
||||
parts.append("The same adult cast is present together in a non-explicit teaser setup")
|
||||
partner_styling = row.get("softcore_partner_styling")
|
||||
if isinstance(partner_styling, dict):
|
||||
outfits = partner_styling.get("outfits")
|
||||
@@ -349,9 +360,9 @@ def insta_of_pair_from_row_result(
|
||||
if pose:
|
||||
parts.append(f"The shared softcore cast pose is {pose}")
|
||||
if soft_text:
|
||||
parts.append(f"Softcore version: {soft_text}")
|
||||
parts.append(f"Softcore version: {soft_text}" if target == "auto" else soft_text)
|
||||
if hard_text:
|
||||
parts.append(f"Hardcore version: {hard_text}")
|
||||
parts.append(f"Hardcore version: {hard_text}" if target == "auto" else hard_text)
|
||||
if not parts:
|
||||
return None
|
||||
return CaptionMetadataRoute(deps.join_sentences(parts), "metadata(insta_of_pair)")
|
||||
|
||||
Reference in New Issue
Block a user