diff options
| -rw-r--r-- | README.md | 8 | ||||
| -rw-r--r-- | alarmpy/alarmpy.py | 8 | ||||
| -rw-r--r-- | setup.py | 2 |
3 files changed, 13 insertions, 5 deletions
@@ -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" @@ -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", |
