Skip to content
プロジェクト

概要

rred is a self-hosted feed cache that saves posts and images from listing pages and serves them as RSS, Atom and JSON.

デザイン・メディア

この数値の測り方

計測したスター増加

24時間
0
7日間
履歴を収集中
15日間
履歴を収集中
1か月
履歴を収集中

期間ごとの純増数です。期間は重複しており、日別の値ではありません。未計測の値は空欄です。スター数は注目度の指標であり、品質の保証ではありません。

rred

rred is a feature-rich, self-hosted feed cache with a command-line interface and an HTTP API. It loads listing pages in a browser, stores the posts and images in SQLite, and serves them as RSS, Atom and JSON.

Full documentation is in docs/: installation, configuration, command line, HTTP API, architecture, development and troubleshooting.

INSTALLATION

Docker

Requires Docker with Compose, or Podman. The quickest way is the interactive setup script. Run it in an empty directory: it asks a few questions, writes docker-compose.yml and config/ there and starts the published images:

mkdir rred && cd rred
curl -fsSL https://raw.githubusercontent.com/rredtech/rred/main/setup.sh | bash

See Installation to review the script first or pass options.

Or, from a clone of this repository, set it up by hand:

$EDITOR config/config.yaml
docker compose up -d --build
docker compose exec rred rred check
curl localhost:18765/r/homelab.json
Option How
Host port (default 18765) Edit ports and RRED_PUBLIC_BASE_URL in docker-compose.yml
arm64 Google Chrome has no arm64 build. Set BROWSER: chromium in docker-compose.yml
Image compression docker compose -f docker-compose.yml -f docker-compose.compress.yml up -d --build. See rred-compress. The image is built from that repo

Rootless Docker and Podman

No root is needed inside or outside the container: rred runs as uid 1000 and listens on an unprivileged port. Run every command as your normal user, without sudo.

Podman: the Podman-only lines are commented out in the compose files. Before the first start, uncomment x-podman and userns_mode: "keep-id:uid=1000,gid=1000" in docker-compose.yml, and userns_mode in docker-compose.compress.yml if you use the sidecar. This maps your user to the container's uid 1000. Then use podman compose in place of docker compose (Podman 4.3 or newer). On SELinux hosts, also switch the ./config mount to the :ro,z form shown in the file. If you change the mapping after the first start, files already in rred-data keep their old owner and rred can no longer write to them.

Rootless Docker: leave those lines commented out. Your host user appears as root in the container, so uid 1000 reads ./config through the "others" permissions: config.yaml and any cookies file must be world-readable (chmod 644, and 755 on config/). Cookies are login secrets, so on a shared machine also chmod 700 the project directory.

Both:

  • Run loginctl enable-linger $USER to keep containers running after logout and start them at boot. Podman also needs systemctl --user enable podman-restart.service. Some Podman versions restart only restart: always containers there, so change unless-stopped if rred does not come back after a reboot.
  • The compression sidecar sets CPU and memory limits. Rootless engines need cgroup v2 with the cpu and memory controllers delegated to your user. Otherwise remove cpus and mem_limit from docker-compose.compress.yml.

From source

Requires Python 3.11 or newer.

python -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/patchright install chromium
RRED_DATA_DIR=./data .venv/bin/rred -c config/config.yaml serve

USAGE AND OPTIONS

Commands

rred [-c CONFIG] [-v] COMMAND [ARGS]

serve                                  Run the API, scheduler, media downloader and pruner
fetch SUB [-s SORT]... [-n N]          Fetch a feed now
      [--no-media]
feed SUB [-s SORT] [-f rss|json]       Print a feed from the cache
     [--media links] [--reddit]
search QUERY [--sub SUB] [-s SORT]     Search Reddit posts live
subs list                              List tracked subs
subs add SUB [--sorts hot,new]         Track a sub on a schedule
         [--interval MIN]
subs remove SUB                        Stop tracking a sub
prune [--dry-run]                      Delete expired posts and unreferenced media
stats                                  Show cache statistics
check [--sub SUB]                      Report the last result of each fetch strategy

In Docker, prefix each command with docker compose exec rred. The native /api/ endpoints are documented in docs/api.md.

Reddit-compatible endpoints

The /r/... paths use the same URLs and formats as reddit.com, so an existing client only needs its host changed: https://www.reddit.com/r/homelab/.rss → http://<host>:18765/r/homelab/.rss.

URL Response
/r/{sub}/.rss, /r/{sub}.rss, /r/{sub}/{sort}/.rss Atom feed with Reddit's layout (thumbnail table, "submitted by", [link] [comments], media:thumbnail, t3_ ids)
/r/{sub}/.json, /r/{sub}.json, /r/{sub}/{sort}/.json {"kind":"Listing","data":{"after","dist","children":[{"kind":"t3","data":{…}}]}}
/r/{sub}/about.json {"kind":"t5","data":{…}}: title, description, icon, banner, id, NSFW
  • Query parameters: limit (default 25, max 100), after (t3_… or a bare id), t, and raw_json=1. Without raw_json=1, &, < and > are HTML-escaped in every string, as Reddit does.
  • Fields: the t3 objects carry 111 of the 111 keys real Reddit returned (checked against an archived r/pics/.json), with matching types.
  • Media fields: preview, thumbnail, gallery media_metadata and secure_media.reddit_video point at cached /media/… files when available.
  • Feed headers come from the subreddit header on the same listing page, so they cost no extra requests. The community icon (2–8 KB) is cached. The banner (45–180 KB) stays a link to the original CDN. Current pages show no subscriber or online counts, so subscribers / active_user_count are null. about.json adds weekly_active_users and weekly_contributions instead.
  • Errors come back as Reddit-style JSON: {"message": "…", "error": 404}.

Limits: only listing pages are supported (no comment pages, user pages or front page). Values not visible on a listing page are defaults: awards, subreddit_subscribers, num_crossposts, edited. selftext is plain text derived from the rendered HTML, not the original markdown. Media has one size, so preview.resolutions holds only the source image.

CONFIGURATION

See config/config.yaml, which documents every key.

Environment variables

Any key can be overridden from the environment with the RRED_ prefix. A double underscore (__) marks nesting, because single underscores are part of key names: RRED_CACHE__RETENTION_DAYS=7 sets cache.retention_days.

Media

  • By default rred does not download full-size originals. The listing links preview copies at 320, 640 and 1080 px wide, and rred takes the largest one no wider than media.max_width (default 1080).
  • With media.prefer_webp, the CDN returns those copies as WebP. Measured on real posts, this is about 80% smaller than the originals, with no CPU cost or extra dependency. Set max_width: 0 to keep originals.
  • The original image URL stays the image's identity, so ?media=links, the url fields and dedupe are unaffected.
  • JSON, RSS and Atom responses are gzip-compressed for clients that accept it. /media/ files are not re-compressed.
  • For further savings, run the compression sidecar.

Cache and cleanup

  • Each post is stored once, keyed by its ID, even when it appears in several sorts or subs. Score, comment count and flair are refreshed on every fetch.
  • Media is stored by SHA-256. A URL that was already downloaded is never fetched again. Failed downloads are retried after retry_failed_after_h.
  • cache.dedupe_reposts hides later posts whose image hash or link URL already appeared earlier in the same feed.
  • The pruner runs hourly and on rred prune. It:
    • deletes feed items not seen for retention_days;
    • trims each feed to max_items_per_feed;
    • deletes posts that no longer belong to any feed, and media no longer referenced;
    • evicts the oldest media once the cache exceeds max_total_gb (those feeds fall back to original links);
    • drops on-demand subs nobody requested for expire_days;
    • sweeps stray files.

Cookies

Export your cookies, in Netscape cookies.txt format or as Cookie-Editor JSON, to config/cookies.txt or config/cookies.json. The file is reloaded automatically when it changes. Both names are in .gitignore.

DEVELOPMENT

python -m venv .venv && .venv/bin/pip install -e '.[dev]'
.venv/bin/patchright install chromium
.venv/bin/pytest

All selectors live in src/rred/parser.py. tests/fixtures/listing.html mirrors the real markup, so markup changes show up as parser test failures.

TROUBLESHOOTING

Symptom Check
Fetches fail Run rred check to see the last result of each strategy
permission denied on /data under Podman userns_mode changed after first start. Recreate the volume or chown it
Parser returns no posts after a markup change Update the selectors in src/rred/parser.py. The parser tests show what broke
Healthcheck missing under Podman Podman drops HEALTHCHECK from OCI images. Use /healthz from your monitor

DISCLAIMER

rred is provided as is, without warranty. Everything you do with it is your own responsibility, including what you fetch, store and serve, and compliance with the terms of any site and any laws that apply to you.

関連プロジェクトを探す

読み込み中…