rss
#
Description#
A plugin for parsing and subscribing to RSS feeds.
Configuration#
rss:
# [Optional]
# List of feeds to monitor for updates, as URLs.
# OPML URLs/local files are also supported.
# subscriptions: # type=Optional[Collection[str]]
# [Optional]
# How often we should check for updates (default: 300 seconds).
# poll_seconds: 300 # type=int
# [Optional]
# Custom user agent to use for the requests.
# user_agent: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36 # type=str
# [Optional]
# How often the `RunnablePlugin.loop <https://docs.platypush.tech/platypush/plugins/.html#platypush.plugins.RunnablePlugin.loop>`_ function should be
# executed (default: 15 seconds). *NOTE*: For back-compatibility
# reasons, the `poll_seconds` argument is also supported, but it's
# deprecated.
# poll_interval: 15 # type=Optional[float]
# [Optional]
# How long we should wait for any running
# threads/processes to stop before exiting (default: 5 seconds).
# stop_timeout: 5 # type=Optional[float]
# [Optional]
# If set to True then the plugin will not monitor
# for new events. This is useful if you want to run a plugin in
# stateless mode and only leverage its actions, without triggering any
# events. Defaults to False.
# disable_monitor: False # type=bool
Dependencies#
pip
pip install feedparser defusedxml
Alpine
apk add py3-defusedxml py3-feedparser
Debian
apt install python3-defusedxml python3-feedparser
Fedora
yum install python-defusedxml python-feedparser
Arch Linux
pacman -S python-defusedxml python-feedparser
Triggered events#
Actions#
Module reference#
- class platypush.plugins.rss.RssPlugin(subscriptions: Collection[str] | None = None, poll_seconds: int = 300, user_agent: str = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', **kwargs)[source]#
Bases:
RunnablePlugin
A plugin for parsing and subscribing to RSS feeds.
- __init__(subscriptions: Collection[str] | None = None, poll_seconds: int = 300, user_agent: str = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/62.0.3202.94 Safari/537.36', **kwargs)[source]#
- Parameters:
subscriptions – List of feeds to monitor for updates, as URLs. OPML URLs/local files are also supported.
poll_seconds – How often we should check for updates (default: 300 seconds).
user_agent – Custom user agent to use for the requests.
- export_to_opml() str [source]#
Export the list of subscriptions into OPML format.
- Returns:
The list of subscriptions as a string in OPML format.
- get_latest_entries(limit: int = 20)[source]#
Get the latest entries from the subscribed feeds, sorted by descending published date.
- Parameters:
limit – Maximum number of entries to return (default: 20).
- Returns:
[ { "author": "Feed entry author", "content": "Feed entry content", "feed_title": "Feed title", "feed_url": "https://some-website/rss", "id": "1234", "published": "2020-01-01T00:00:00+00:00", "summary": "Feed entry summary", "tags": "Feed entry tags", "title": "Feed entry title", "url": "https://some-website/articles/1234" } ]
- parse_feed(url: str)[source]#
Parse a feed URL.
- Parameters:
url – Feed URL.
- Returns:
[ { "author": "Feed entry author", "content": "Feed entry content", "feed_title": "Feed title", "feed_url": "https://some-website/rss", "id": "1234", "published": "2020-01-01T00:00:00+00:00", "summary": "Feed entry summary", "tags": "Feed entry tags", "title": "Feed entry title", "url": "https://some-website/articles/1234" } ]
- start()#
Start the plugin.
- wait_stop(timeout=None)#
Wait until a stop event is received.