{
"id": "133951921230000000",
"cat": "10",
"title": "חדירת כלי טיס עוין - האירוע הסתיים",
"data": [
"יונתן",
"קשת"
],
"desc": "באזורים הבאים בהמשך לדיווח על הפעלת התרעה על כניסת כלי טיס עוין לשמי ישראל - האירוע הסתיים."
}
import time
import os
from subprocess import Popen
import json
import urllib.parse
import urllib.request
datais = {
"id": "133951921230000000",
"cat": "10",
"title": "חדירת כלי טיס עוין - האירוע הסתיים",
"data": [
"יונתן",
"קשת"
],
"desc": "באזורים הבאים בהמשך לדיווח על הפעלת התרעה על כניסת כלי טיס עוין לשמי ישראל - האירוע הסתיים."
}
def PlaySong(song, volume=100):
Popen(("mpv",
song,
"--no-video",
"--af=loudnorm",
"--volume="+str(volume)))
def Get(url, data=None, headers={}, raw=False, timeout=10):
if data:
try:
data = json.dumps(data).encode("utf-8")
except:
try:
data = data.encode("utf-8")
except:
pass
req = urllib.request.Request(url, data=data, headers=headers)
f = urllib.request.urlopen(req, timeout=timeout)
if raw:
return f.read()
data = f.read().decode('utf-8-sig')
data = json.loads(data)
return data
YouCanExit = "ניתן לצאת"
Finished = "הסתיים"
EndOfWait = "סיום שהייה"
while True:
try:
data = Get("https://www.oref.org.il/WarningMessages/alert/alerts.json")
except Exception as e:
data = {}
if data:
Popen(['notify-send', data.get("title", "")])
if YouCanExit not in data.get("title", "") and Finished not in data.get("title", "") and EndOfWait not in data.get("title", ""):
PlaySong("alert.ogg")
time.sleep(5)