Skip to main content

A library for watching RSS feeds and notifying when new entries are available

Project description

ScoutRSS

ScoutRSS is a Python library for monitoring RSS feeds and triggering callbacks when new entries are found. It uses feedparser for parsing and supports pluggable storage backends.

Installation

pip install scoutrss

With built-in scheduler support:

pip install scoutrss[scheduler]

With MongoDB storage support:

pip install scoutrss[mongo]

Usage

Basic

from scoutrss import ScoutRSS

def callback(entries):
    for entry in entries:
        print("New entry:", entry.title)

watcher = ScoutRSS("https://example.com/feed.xml", callback)
watcher.check()  # one-off check

With scheduler

watcher = ScoutRSS("https://example.com/feed.xml", callback)
watcher.listen(interval=60)   # background, non-blocking
watcher.listen(interval=60, blocking=True)  # blocks current thread
watcher.stop()

Storage backends

By default, state is persisted to scoutrss.data.json in the current directory. You can switch backends or use in-memory storage:

from scoutrss import ScoutRSS, FileStorage, MemoryStorage, MongoStorage

# Custom file path
watcher = ScoutRSS(url, callback, storage=FileStorage("data/feeds.json"))

# In-memory (no persistence, useful for testing)
watcher = ScoutRSS(url, callback, storage=MemoryStorage())

# MongoDB
from pymongo import MongoClient
collection = MongoClient()["mydb"]["rss"]
watcher = ScoutRSS(url, callback, storage=MongoStorage(collection))

Custom ID

By default the URL is used as the storage key. Override with id:

watcher = ScoutRSS(url, callback, id="my-feed")

Require confirmation

Set require_confirmation=True to only advance the timestamp if the callback returns True:

def callback(entries):
    success = process(entries)
    return success  # only update last_seen if True

watcher = ScoutRSS(url, callback, require_confirmation=True)

Custom scheduler

Pass an existing APScheduler instance to share it across multiple watchers:

from apscheduler.schedulers.background import BackgroundScheduler

scheduler = BackgroundScheduler()
scheduler.start()

watcher1 = ScoutRSS(url1, callback1)
watcher2 = ScoutRSS(url2, callback2)

watcher1.listen(interval=60, scheduler=scheduler)
watcher2.listen(interval=120, scheduler=scheduler)

Custom retry logic

Pass a custom check_fn to listen() to wrap check() with retry logic:

from tenacity import retry, stop_after_attempt, wait_exponential

@retry(stop=stop_after_attempt(3), wait=wait_exponential(min=1, max=10))
def check_with_retry():
    watcher.check()

watcher.listen(interval=60, check_fn=check_with_retry)

Custom storage adapter

Implement StorageAdapter to use any storage backend:

from scoutrss import StorageAdapter
from datetime import datetime

class RedisStorage(StorageAdapter):
    def __init__(self, client):
        self._client = client

    def get_last_seen(self, id: str) -> datetime | None:
        val = self._client.get(id)
        return datetime.fromisoformat(val) if val else None

    def set_last_seen(self, id: str, last_seen: datetime) -> None:
        self._client.set(id, last_seen.isoformat())

License

ScoutRSS is licensed under the GNU GPLv3 license.

Contributing

Contributions are welcome! See CONTRIBUTING.md for more information.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

scoutrss-0.2.0.tar.gz (48.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

scoutrss-0.2.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file scoutrss-0.2.0.tar.gz.

File metadata

  • Download URL: scoutrss-0.2.0.tar.gz
  • Upload date:
  • Size: 48.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scoutrss-0.2.0.tar.gz
Algorithm Hash digest
SHA256 70532a79f87300617ea5339a0092dc889dd4aef2d5c496d4c7fe19d356fc5935
MD5 37efa344a9343394e238868e4eb6fa0f
BLAKE2b-256 2ec383c2fcdc21384d0d7d2360ec8374b2f31dafc3ff08c999d49f1da929c87b

See more details on using hashes here.

Provenance

The following attestation bundles were made for scoutrss-0.2.0.tar.gz:

Publisher: publish.yml on viperadnan-git/scoutrss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file scoutrss-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: scoutrss-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for scoutrss-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 207958631793acee233d12209c0890d78638cafd54caf72919ff044701816799
MD5 3f5cfbd0d6fe4b142ff4c86e4407bc9e
BLAKE2b-256 c896b4b84024ea6fdd3658f91ddf862cab61e9d54b7899111f830426fc304977

See more details on using hashes here.

Provenance

The following attestation bundles were made for scoutrss-0.2.0-py3-none-any.whl:

Publisher: publish.yml on viperadnan-git/scoutrss

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page