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 0000000..815612f Binary files /dev/null and b/__pycache__/config.cpython-37.pyc differ 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)