From 16b3da352f816115d0b5d461886afc90f097fd5a Mon Sep 17 00:00:00 2001 From: Alex Meyer Date: Wed, 22 Jan 2020 21:46:04 -0800 Subject: [PATCH] first push --- .gitignore | 1 + __pycache__/config.cpython-37.pyc | Bin 0 -> 468 bytes config.py | 4 ++++ snow_notify.py | 36 ++++++++++++++++++++++++++++++ 4 files changed, 41 insertions(+) create mode 100644 .gitignore create mode 100644 __pycache__/config.cpython-37.pyc create mode 100644 config.py create mode 100644 snow_notify.py diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5bc2625 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +_pycache_ \ No newline at end of file diff --git a/__pycache__/config.cpython-37.pyc b/__pycache__/config.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..815612f0b21c455920fd1f2bf0482f6a2ec8a21a GIT binary patch literal 468 zcmbVJF;2rU6m{CPRETaI0G3K!5;s95R1^>cBTKiaB1-*#h}ASUc1o2lh~sb!u91~n zFkx594B~(J=|4;Md(XZf4v&ec&-c;O!Xf0#lC}&dcV_8R13+Q|PV7J@?m##0g1aE& zUVO$@IJrOw(tu9cB#J^B(&&$XU5HLWz+P~#hCH2hrQ^~y@rd5t=TNZ+? z5j-X~cHh^f*eR4kRsJNTG`!8lRuy%^%L>(NTFj@TRLX?IyuJ6p*I3Vgv$B8rivfk& zh-X3}OLc4Fzmkt*w>dJg663Gw+krzfuo)ARsyS(8Ec+m;XCC?h-{%jr<$@_LE4^d_ faB0u*tTv>~__HVLW^la`ur2V${*&$-a2?w}>Nt&@ literal 0 HcmV?d00001 diff --git a/config.py b/config.py new file mode 100644 index 0000000..7f35d42 --- /dev/null +++ b/config.py @@ -0,0 +1,4 @@ +api_key = 'cbe14ed2a206c188303087c3bfd80202' +api_id = 'fd2cdee9' +snow_url = 'https://api.weatherunlocked.com/api/snowreport/13003?hourly_interval=6&app_id=fd2cdee9&app_key=cbe14ed2a206c188303087c3bfd80202' +forecast_url = 'https://api.weatherunlocked.com/api/resortforecast/13003?app_id=fd2cdee9&app_key=cbe14ed2a206c188303087c3bfd80202' \ No newline at end of file diff --git a/snow_notify.py b/snow_notify.py new file mode 100644 index 0000000..4c9a800 --- /dev/null +++ b/snow_notify.py @@ -0,0 +1,36 @@ +import requests +import json +import urllib.request as request +import config + +# with request.urlopen('https://api.weatherunlocked.com/api/snowreport/13003?app_id=fd2cdee9&app_key=cbe14ed2a206c188303087c3bfd80202') as response: +# if response.getcode() == 200: +# source = response.read() +# data = json.loads(source) +# else: +# print('An error occurred while attempting to retrieve the API data.') + +# type(data) +# data.keys() +# type(data['lowersnow_in']) +# print(type(data['lowersnow_in']).float) +api_id = config.api_id +api_key = config.api_key + + + +snow_request = requests.get(config.snow_url) +snow_report = snow_request.json() +print(snow_report) +print("Lower snow report:",snow_report['lowersnow_in'],"inches.") +if snow_report['newsnow_in'] >= 3: + print('You got Snow!') + print('The last snowfall size was',snow_report['lastsnow_in'],'inches.') + print('The snow type is',snow_report['conditions'],'.') +else: + print('Hopefully soon!') + print('The last snowfall size was',snow_report['lastsnow_in'],'inches on',snow_report['lastsnow']) + +forecast_request = requests.get(config.forecast_url) +forecast_report = forecast_request.json() +print(forecast_report)