Add NO_VIDEO filter

This commit is contained in:
Tim Van Baak 2023-06-24 06:53:41 -07:00
parent 333285bb79
commit d2195142dd
2 changed files with 8 additions and 0 deletions

View File

@ -29,6 +29,7 @@ Supported `env`:
- `MIN_SCORE`: Skip posts with scores below this number. - `MIN_SCORE`: Skip posts with scores below this number.
- `TAGS`: Comma-separated list of tags to add to all items. - `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. - `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 ## intake-hackernews

View File

@ -81,6 +81,7 @@ def main():
min_score = int(os.environ.get("MIN_SCORE", 0)) min_score = int(os.environ.get("MIN_SCORE", 0))
tags = [tag for tag in os.environ.get("TAGS", "").split(",") if tag] 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] 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("filter nsfw =", bool(filter_nsfw))
stderr("tag nsfw =", bool(tag_nsfw)) stderr("tag nsfw =", bool(tag_nsfw))
stderr("filter spoiler =", bool(filter_spoiler)) stderr("filter spoiler =", bool(filter_spoiler))
@ -88,6 +89,7 @@ def main():
stderr("min score =", min_score) stderr("min score =", min_score)
stderr("tags =", ", ".join(tags)) stderr("tags =", ", ".join(tags))
stderr("author blocklist =", ", ".join(author_blocklist)) stderr("author blocklist =", ", ".join(author_blocklist))
stderr("no video =", bool(no_video))
for post in info["data"]["children"]: for post in info["data"]["children"]:
post_data = post["data"] post_data = post["data"]
@ -123,6 +125,11 @@ def main():
if post_author in author_blocklist: if post_author in author_blocklist:
continue continue
# v.redd.it filter
if post_url := post_data.get("url"):
if "v.redd" in post_url and no_video:
continue
# Title # Title
if post_title := post_data.get("title"): if post_title := post_data.get("title"):
sub_prefixed = post_data.get("subreddit_name_prefixed") or f"r/{sub_name}" sub_prefixed = post_data.get("subreddit_name_prefixed") or f"r/{sub_name}"