yb.content

Target-agnostic publication content: prepare it once, publish anywhere.

A PublicationContent bundles everything a publication needs that is not specific to a destination — title, description, keywords, chapters, languages, and the media/transcript/thumbnail assets. Platform adapters (yb.youtube, yb.podcast) consume it and map it to their own schema.

The heavy lifting (transcription, chapter detection, thumbnail rendering) is delegated to the mixing package; the copywriting (title/description/ keywords) is LLM-backed via aix and pluggable.

Functions

format_chapter_lines(chapters)

Render chapters as M:SS Title lines (the shared text convention).

generate_metadata(transcript, *[, language, ...])

Generate platform-neutral title/description/keywords from a transcript.

prepare_content(media, *[, language, ...])

Build a PublicationContent for media (destination-agnostic).

Classes

ContentMetadata(title, description[, keywords])

Platform-neutral copy: a title, a description, and keywords.

PublicationContent(media[, title, ...])

Everything needed to publish a piece of media, destination-agnostic.

class yb.content.ContentMetadata(title, description, keywords=<factory>)[source]

Bases: object

Platform-neutral copy: a title, a description, and keywords.

class yb.content.PublicationContent(media, title='', description='', keywords=<factory>, chapters=<factory>, language=None, audio_language=None, srt_path=None, thumbnail=None, duration=None)[source]

Bases: object

Everything needed to publish a piece of media, destination-agnostic.

media

Path to the audio/video file.

title

Headline/title.

description

Long-form description / show notes body.

keywords

Topical keywords/tags.

chapters

Ordered chapter markers (mixing.chapters.Chapter).

language

BCP-47 code of the metadata text (e.g. "en").

audio_language

BCP-47 code of the spoken audio (e.g. "fr").

srt_path

Path to the SRT subtitle/caption file, if any.

thumbnail

Path to a thumbnail/cover image, if any.

duration

Media duration in seconds, if known.

description_with_chapters()[source]

Description with a chapters block appended (if any chapters).

Return type:

str

yb.content.format_chapter_lines(chapters)[source]

Render chapters as M:SS Title lines (the shared text convention).

Uses H:MM:SS when any chapter is at or beyond one hour. This is the text format both YouTube descriptions and podcast show notes accept.

Return type:

str

yb.content.generate_metadata(transcript, *, language='English', brand=None, extra_context=None, model=None)[source]

Generate platform-neutral title/description/keywords from a transcript.

LLM-backed via aix. Pass a ready ContentMetadata to prepare_content() instead if you want to skip generation.

Raises:

ImportError – aix is not importable.

Return type:

ContentMetadata

yb.content.prepare_content(media, *, language='English', language_code=None, audio_language_code=None, brand=None, extra_context=None, transcript=None, with_chapters=True, with_thumbnail=False, thumbnail_text=None, metadata=None, model=None, transcribe_kwargs=None, chapters_kwargs=None)[source]

Build a PublicationContent for media (destination-agnostic).

Ensures a persisted SRT next to the media (transcribing once via mixing if needed), writes LLM metadata, detects chapters (default on, auto-skipped for clips too short to host them), and optionally renders a thumbnail. Any precomputed pieces (transcript, metadata) are reused instead of recomputed.

Parameters:
  • media (str | Path) – Audio or video file.

  • language (str) – Human-readable language to write metadata in.

  • audio_language_code (str | None) – BCP-47 codes for the metadata text and the spoken audio.

  • brand (str | None) – Product/brand name to keep verbatim in the copy.

  • extra_context (str | None) – Extra guidance for the copywriter (audience, CTA…).

  • transcript (str | None) – SRT text to use as-is (skips transcription).

  • with_chapters (bool) – Detect chapters (default True).

  • with_thumbnail (bool) – Render a thumbnail image (default False).

  • thumbnail_text (str | None) – Overlay text for the thumbnail (defaults to the title).

  • metadata (ContentMetadata | None) – Precomputed ContentMetadata to reuse.

  • model (str | None) – LLM model override.

  • chapters_kwargs (dict | None) – Forwarded to the mixing calls.

Return type:

PublicationContent

Returns:

A populated PublicationContent.