Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
Nextross authored Apr 9, 2022
0 parents commit ed937e0
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
Binary file added icon.ico
Binary file not shown.
47 changes: 47 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
import requests
import json
from notifypy import Notify
from time import sleep
from sys import exit

# sleep(10)


def json_to_dic(json_object):
dic = json.loads(json.dumps(json_object))
return dic


def todays_name_day():
time = 10
for attempt in range(1, 4):
try:
response = requests.get("https://svatky.adresa.info/json").json()[0]
break
except requests.exceptions.ConnectionError or requests.exceptions.InvalidURL:
notification.title = f"Nelze se připojit k serveru ({attempt}/3)"
notification.message = f"Zkusíme to znovu za {time} sekund"
notification.send()

sleep(time)
time += 5

if attempt != 3:
continue
else:
notification.title = f"Nepodařilo se připojit k serveru"
notification.message = f"Ukončování aplikace..."
notification.send()
exit()

response = json_to_dic(response)
name_day = response["name"]
day = response["date"]

notification.title = f"Dnes {day[:2].strip('0')}. {day[2:].strip('0')}"
notification.message = f"má svátek {name_day}"
notification.send()


notification = Notify(default_notification_application_name="Kdo má dnes svátek?", default_notification_icon="icon.ico")
todays_name_day()

0 comments on commit ed937e0

Please sign in to comment.