feed.sources
Documentation for eth_defi.feed.sources Python module.
Feed source mappings.
Load and validate YAML-defined mappings for RSS feeds, Twitter/X usernames, LinkedIn company identifiers, and feeder websites that should be tracked for vault-related post collection.
Functions
Write |
|
|
Load a single feeder YAML file and return its metadata as a plain dict. |
|
Load and validate all feed source mappings. |
|
Append |
|
Append |
|
Stamp RSS failure fields on a feeder YAML. |
|
Append |
|
Append |
Find the YAML file for a canonical feeder, searching by role priority. |
|
|
Resolve a feeder_id through the alias mapping. |
Classes
A feeder YAML that delegates feed sources to another feeder. |
|
A single logical source mapping for feed collection. |
- class FeederAlias
Bases:
objectA feeder YAML that delegates feed sources to another feeder.
Alias files contain only identity metadata (feeder-id, name, role) and a
canonical-feeder-idpointing to the feeder whose feed sources should be collected. They produce noTrackedPostSourceentries.
- class TrackedPostSource
Bases:
objectA single logical source mapping for feed collection.
- __init__(feeder_id, name, role, website, source_type, source_key, canonical_url, mapping_file)
- auto_disable_failed_linkedin_sources(summary, sources, disabled_at)
Write
linkedin-rss-hub-disabled-atto YAML for every all-503 LinkedIn failure.When all configured RSSHub bridges return HTTP 503 for a LinkedIn source, LinkedIn is gating that company page behind authentication. This function stamps the feeder YAML so future scan runs skip the source entirely rather than retrying.
- Parameters
summary (CollectorRunSummary) – Collector run result from
collect_posts().sources (collections.abc.Sequence[eth_defi.feed.sources.TrackedPostSource]) – Source list passed to the same
collect_posts()call.disabled_at (str) – ISO date string to stamp in the YAML, e.g.
2026-04-04.
- Returns
Number of YAML files updated.
- Return type
- load_feeder_metadata(yaml_path)
Load a single feeder YAML file and return its metadata as a plain dict.
Uses the shared feeder schema for validation, including slug format validation via
_validate_slug()and role validation via_validate_role(). Asserts thatfeeder-idmatches the filename stem to catch slug/filename mismatches.This function provides a public API for modules that need feeder metadata (slug, name, descriptions, website, twitter, linkedin, rss) without pulling in the full feed-collection machinery of
load_post_sources().- Parameters
yaml_path (pathlib.Path) – Path to a feeder YAML file.
- Returns
Dict with keys:
feeder-id,name,role,website,short_description,long_description,twitter,linkedin,rss, etc.- Return type
- load_post_sources(mappings_dir=PosixPath('/home/runner/work/web3-ethereum-defi/web3-ethereum-defi/eth_defi/data/feeds'))
Load and validate all feed source mappings.
- Returns
Tuple of
(sources, feeders_skipped, aliases)where feeders_skipped counts YAML files with all sources disabled (not aliases) and aliases lists feeders that delegate their sources to a canonical feeder viacanonical-feeder-id.- Parameters
mappings_dir (pathlib.Path) –
- Return type
tuple[list[eth_defi.feed.sources.TrackedPostSource], int, list[eth_defi.feed.sources.FeederAlias]]
- mark_linkedin_source_disabled(yaml_path, disabled_at)
Append
linkedin-rss-hub-disabled-atto a feeder YAML without rewriting it.Preserves existing file content including comments. The new field is appended as a trailing line so that YAML structure and indentation are not disturbed.
- Parameters
yaml_path (pathlib.Path) – Path to the feeder YAML file.
disabled_at (str) – ISO date string to stamp, e.g.
2026-04-04.
- Returns
Truewhen the file was updated,Falsewhen the field was already present.- Return type
- mark_rss_source_dead(yaml_path, dead_at)
Append
rss-dead-atto a feeder YAML without rewriting it.Used when an RSS feed is valid but has not published any new posts for a year or more.
- Parameters
yaml_path (pathlib.Path) – Path to the feeder YAML file.
dead_at (str) – ISO date string, e.g.
2026-04-06.
- Returns
Truewhen the file was updated,Falsewhen already present.- Return type
- mark_rss_source_failure(yaml_path, failure_at, status_code=None, exception_message=None)
Stamp RSS failure fields on a feeder YAML.
Records the most recent RSS failure so operators can see which feeds are broken. Overwrites any previous failure fields.
- Parameters
- Returns
Truewhen the file was updated.- Return type
- mark_twitter_handle_unknown(yaml_path, unknown_at)
Append
twitter-handle-resolved-unknown-atto a feeder YAML.Used when the X API cannot resolve a Twitter handle to a user ID, typically because the account has been suspended, deleted, or renamed.
- Parameters
yaml_path (pathlib.Path) – Path to the feeder YAML file.
unknown_at (str) – ISO date string, e.g.
2026-04-06.
- Returns
Truewhen the file was updated,Falsewhen already present.- Return type
- mark_twitter_source_dead(yaml_path, dead_at)
Append
twitter-dead-atto a feeder YAML without rewriting it.Used when a Twitter account has not posted for the configured death detection period.
- Parameters
yaml_path (pathlib.Path) – Path to the feeder YAML file.
dead_at (str) – ISO date string to stamp, e.g.
2026-04-04.
- Returns
Truewhen the file was updated,Falsewhen the field was already present.- Return type
- resolve_canonical_feeder_yaml(canonical_feeder_id, mappings_dir)
Find the YAML file for a canonical feeder, searching by role priority.
Searches subdirectories in priority order: stablecoins/, protocols/, curators/, vaults/. Returns the path to the first matching YAML file whose filename stem equals canonical_feeder_id.
- Parameters
canonical_feeder_id (str) – The feeder-id slug to look up.
mappings_dir (pathlib.Path) – Root directory containing role subdirectories (e.g.
eth_defi/data/feeds).
- Raises
FileNotFoundError – When no matching YAML file is found in any role subdirectory.
- Return type
- resolve_feeder_id(feeder_id, aliases)
Resolve a feeder_id through the alias mapping.
Returns the canonical feeder_id when the input is an alias, or the input unchanged when it is not an alias.
- Parameters
feeder_id (str) – Feeder-id to resolve.
aliases (collections.abc.Sequence[eth_defi.feed.sources.FeederAlias]) – Alias list returned by
load_post_sources().
- Return type