summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorYuval Adam <_@yuv.al>2023-10-12 12:13:00 +0200
committerYuval Adam <_@yuv.al>2023-10-12 12:13:00 +0200
commitcd7d0d7ba3c6ba53e66c6169f1cac8e55ef39d1b (patch)
tree658936efb07f3b6259f5455fd22a0ce70cd1a7fc
parent8a17a42de3e6bc64f855131ec0360f78211cdd2b (diff)
Add --mirror flag and release v1.6.0
-rw-r--r--README.md8
-rw-r--r--alarmpy/alarmpy.py8
-rw-r--r--setup.py2
3 files changed, 13 insertions, 5 deletions
diff --git a/README.md b/README.md
index bfd6f11..4124c25 100644
--- a/README.md
+++ b/README.md
@@ -56,10 +56,16 @@ $ alarmpy
- In case of RTL issues in the terminal use `--reverse` to output all names in reverse.
- Use `--highlight abc` in order to highlight any alarm which contains the string `abc`.
-### Proxy
+### Proxy and Mirror Servers
The unofficial API is limited for use for Israeli-originating IPs only. In order to use alarmpy from outside Israel, users must route traffic through an Israeli exit point. The `HTTPS_PROXY` environment variable is supported for this use case.
+Alternatively, a well-known mirror URL can be used:
+
+```bash
+$ alarmpy --mirror http://alarmpy.yuv.al/alerts.json
+```
+
### Advanced
Advanced flags can be set as described in the usage:
diff --git a/alarmpy/alarmpy.py b/alarmpy/alarmpy.py
index 29890b9..f20b98d 100644
--- a/alarmpy/alarmpy.py
+++ b/alarmpy/alarmpy.py
@@ -16,7 +16,6 @@ except ImportError:
class Alarm:
-
URL = "https://www.oref.org.il/WarningMessages/alert/alerts.json"
HEADERS = {
@@ -30,6 +29,7 @@ class Alarm:
language="he",
highlight=None,
reverse=False,
+ mirror="",
polling_delay=1,
routine_delay=60 * 5,
alarm_id=False,
@@ -43,6 +43,7 @@ class Alarm:
mqtt_filter=None,
**_kwargs,
):
+ self.url = mirror or self.URL
self.language = language
self.highlight = highlight
self.reverse = reverse
@@ -118,11 +119,11 @@ class Alarm:
def fetch(self):
try:
- res = self.session.get(self.URL, headers=self.HEADERS, timeout=1)
+ res = self.session.get(self.url, headers=self.HEADERS, timeout=1)
if not res.ok:
if "Access Denied" in res.text:
self.output_error(
- "API endpoint has denied access. This might be due to geolocation limitations, please try running from an Israeli-based IP or proxy."
+ "API endpoint has denied access. This might be due to geolocation limitations, please try running from an Israeli-based IP or proxy, or use the --mirror flag"
)
exit(1)
else:
@@ -269,6 +270,7 @@ class Alarm:
is_flag=True,
help="Reverse Hebrew/Arabic output for terminals with RTL bugs",
)
+@click.option("--mirror", default="", help="A mirror host for fetching events")
@click.option("--polling-delay", default=1, help="Polling delay in seconds")
@click.option(
"--routine-delay", default=60 * 5, help="Routine message delay in seconds"
diff --git a/setup.py b/setup.py
index 24cc5b1..9e624b5 100644
--- a/setup.py
+++ b/setup.py
@@ -5,7 +5,7 @@ with open("README.md", "r", encoding="utf-8") as fh:
setuptools.setup(
name="alarmpy",
- version="1.5.4",
+ version="1.6.0",
author="Yuval Adam",
author_email="_@yuv.al",
description="Pikud Ha'oref Alarm Tracking",