From d2195142dd5881256977bf40a7fcb02d05fcdf51 Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Sat, 24 Jun 2023 06:53:41 -0700 Subject: [PATCH] Add NO_VIDEO filter --- README.md | 1 + intake-reddit/intake_reddit/core.py | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/README.md b/README.md index f20afb6..df4864b 100644 --- a/README.md +++ b/README.md @@ -29,6 +29,7 @@ Supported `env`: - `MIN_SCORE`: Skip posts with scores below this number. - `TAGS`: Comma-separated list of tags to add to all items. - `AUTHOR_BLOCKLIST`: Comma-separated list of usernames. Posts by these users will be skipped. +- `NO_VIDEO`: Set to a truthy value to filter out v.redd.it links. ## intake-hackernews diff --git a/intake-reddit/intake_reddit/core.py b/intake-reddit/intake_reddit/core.py index 9b13a6b..94d4fdd 100644 --- a/intake-reddit/intake_reddit/core.py +++ b/intake-reddit/intake_reddit/core.py @@ -81,6 +81,7 @@ def main(): min_score = int(os.environ.get("MIN_SCORE", 0)) tags = [tag for tag in os.environ.get("TAGS", "").split(",") if tag] author_blocklist = [author for author in os.environ.get("AUTHOR_BLOCKLIST", "").split(",") if author] + no_video = os.environ.get("NO_VIDEO", False) stderr("filter nsfw =", bool(filter_nsfw)) stderr("tag nsfw =", bool(tag_nsfw)) stderr("filter spoiler =", bool(filter_spoiler)) @@ -88,6 +89,7 @@ def main(): stderr("min score =", min_score) stderr("tags =", ", ".join(tags)) stderr("author blocklist =", ", ".join(author_blocklist)) + stderr("no video =", bool(no_video)) for post in info["data"]["children"]: post_data = post["data"] @@ -123,6 +125,11 @@ def main(): if post_author in author_blocklist: continue + # v.redd.it filter + if post_url := post_data.get("url"): + if "v.redd" in post_url and no_video: + continue + # Title if post_title := post_data.get("title"): sub_prefixed = post_data.get("subreddit_name_prefixed") or f"r/{sub_name}"