Skip to content

API Reference parrot_tools.rss.storage

github-actions[bot] edited this page Dec 2, 2026 · 4 revisions

parrot_tools.rss.storage

View source

Disk storage for archived RSS articles.

Layout::

{base_dir}/{feed_slug}/{item_id}/page.html     raw fetched HTML
{base_dir}/{feed_slug}/{item_id}/content.txt   extracted main text
{base_dir}/{feed_slug}/{item_id}/item.json     FeedItemMetadata dump

Alias FeedItemMetadata

Re-exported from parrot_tools.rss.models.FeedItemMetadata.

Attribute HTML_FILENAME

Attribute META_FILENAME

Class RSSStorage

Filesystem archive for fetched feed items.

All blocking I/O is dispatched through asyncio.to_thread in the async methods; the sync helpers are cheap path/metadata operations.

Parameter Type Default Description
base_dir Union[str, Path] Directory under which all feed content is archived. Created if missing.

Method RSSStorage.item_dir

Return the directory for a feed item (not created).

item_dir(feed_slug: str, item_id: str) -> Path

Parameter Type Default Description
feed_slug str
item_id str

Returns: Path

Method RSSStorage.has_item

Check whether an item is already archived (dedup check).

has_item(feed_slug: str, item_id: str) -> bool

Parameter Type Default Description
feed_slug str
item_id str

Returns: bool

Method RSSStorage.save_item

Persist an item's content and metadata to disk.

Sets html_path/text_path on the metadata (when the corresponding content is non-empty) before writing item.json.

save_item(meta: FeedItemMetadata, html: str, text: str) -> FeedItemMetadata

Parameter Type Default Description
meta FeedItemMetadata Item metadata to persist.
html str Raw page HTML.
text str Extracted main text.

Returns: FeedItemMetadata — The updated metadata (paths filled in).

Method RSSStorage.load_metadata

Load archived metadata for an item, or None when absent/corrupt.

load_metadata(feed_slug: str, item_id: str) -> Optional[FeedItemMetadata]

Parameter Type Default Description
feed_slug str
item_id str

Returns: Optional[FeedItemMetadata]

Method RSSStorage.find_item

Locate an item directory by id across all feeds.

find_item(item_id: str) -> Optional[Path]

Parameter Type Default Description
item_id str 16-hex item identifier.

Returns: Optional[Path] — The item directory, or None when not archived.

Method RSSStorage.list_saved

List archived item metadata, newest first.

list_saved(feed_slug: Optional[str] = None, limit: int = 50) -> List[Dict[str, Any]]

Parameter Type Default Description
feed_slug Optional[str] None Restrict to a single feed when provided.
limit int 50 Maximum number of records returned.

Returns: List[Dict[str, Any]] — Metadata dicts (FeedItemMetadata shape) sorted by archive-file mtime, descending.

Method RSSStorage.resolve_content_path

Resolve an item reference to a readable content file.

resolve_content_path(ref: str, fmt: str = 'text') -> Path

Parameter Type Default Description
ref str A 16-hex item_id, an item directory path, or a direct path to an archived file.
fmt str 'text' "text" or "html" — which representation to read when the ref is an item id or directory.

Returns: Path — Path to the content file, guaranteed to live under base_dir.

Raises:

  • ValueError — On unknown format, unknown item id, missing file, or any path escaping the storage root (traversal/symlink guard).

Method RSSStorage.read_content

Read archived content for an item reference.

read_content(ref: str, fmt: str = 'text') -> str

Parameter Type Default Description
ref str Item id or path (see :meth:resolve_content_path).
fmt str 'text' "text" or "html".

Returns: str — The file content.

Raises:

  • ValueError — Propagated from :meth:resolve_content_path.

Attribute TEXT_FILENAME

Alias is_item_id

Re-exported from parrot_tools.rss.models.is_item_id.

Architecture

Clients

Bots & Agents

Memory

Knowledge

Tools & Toolkits

Flows

Experts

Skills

Stores & Loaders

MCP & A2A

Server & APIs

Integrations

Outputs & A2UI

Prompts

Security

Operations

Migration

SDD Tooling

LLM Wiki

Deployment

Decisions

API Reference

Clone this wiki locally