Skip to content

Commit

Permalink
Merge pull request #3 from bbtufty/nxbrew-url
Browse files Browse the repository at this point in the history
Make NXBrew URL a mandatory configurable
  • Loading branch information
bbtufty authored Nov 19, 2024
2 parents a5d86be + 4de0dec commit 612c3cd
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.0.2 (2024-11-19)
==================

- Make NXBrew URL a mandatory configurable

0.0.1 (2024-10-01)
==================

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ services:
container_name: nxbrew-watcher
network_mode: bridge
environment:
- NXBREW_URL=https://some_nxbrew_url.com
- NXBREW_DISCORD_URL=https://some/webhook/url #optional
- NXBREW_CADENCE=1 #optional
- NXBREW_LOG_LEVEL=INFO #optional
Expand All @@ -32,6 +33,7 @@ Environment variables

NXBrew-watcher pulls in a number of environment variables that can be configured. These are:

* `NXBREW_URL`: NXBrew URL. Must be set
* `NXBREW_DISCORD_URL`: Webhook URL for Discord to post updates (see [here](https://support.discord.com/hc/en-us/articles/228383668-Intro-to-Webhooks))
* `NXBREW_CADENCE`: Cadence to perform search on (in minutes). Defaults to 1.
* `NXBREW_LOG_LEVEL`: Level for log files. Defaults to INFO
6 changes: 5 additions & 1 deletion nxbrew_watcher/watcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@
from .utils import load_json, save_json, setup_logger, discord_push

# NXBrew variables
NXBREW_URL = "https://nxbrew.com/"
LATEST_ADDED_ID = "tab-recent-6"
LATEST_UPDATED_ID = "custom_html-6"

# Pull in environment variables
NXBREW_URL = os.getenv("NXBREW_URL", None)

CONFIG_DIR = os.getenv("CONFIG_DIR", os.getcwd())

DISCORD_URL = os.getenv("NXBREW_DISCORD_URL", None)
Expand Down Expand Up @@ -58,6 +59,9 @@ def __init__(
):
"""Scrape NXBrew for latest additions and updates"""

if NXBREW_URL is None:
raise ValueError("NXBREW_URL environment variable must be set")

self.cache_file = os.path.join(CONFIG_DIR, "nxbrew_cache.json")
if os.path.exists(self.cache_file):
self.cache = load_json(self.cache_file)
Expand Down

0 comments on commit 612c3cd

Please sign in to comment.