Last active
January 6, 2016 18:51
-
-
Save robo-corg/7364895672bbf781de6c to your computer and use it in GitHub Desktop.
forecast.io plugin for bitbar with fun emoji icons
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import forecastio | |
icon_to_emoji = { | |
'clear-day': u'☀️', | |
'clear-night': u'🌙', | |
'rain': u'🌧', | |
'snow': u'❄️', | |
'sleet': u'🌨', | |
'wind': u'🌬', | |
'fog': u'🌫', | |
'cloudy': u'☁️', | |
'partly-cloudy-day': u'🌤', | |
'partly-cloudy-night': u'🌤' | |
} | |
# Change these: | |
api_key = None # You will need a forcast.io api key | |
lat, lng = 46.7333, -117.1667 | |
forecast = forecastio.load_forecast(api_key, lat, lng, units='us') | |
current_forecast = forecast.currently() | |
icon = icon_to_emoji.get(current_forecast.icon, u'').encode('UTF8') | |
print u'{:.0f}℉ {}'.encode('UTF8').format(current_forecast.temperature, icon) | |
print '---' | |
print u'{} | href=http://forecast.io/#/f/{},{}'.format(current_forecast.summary, lat, lng) | |
print u'Feels like: {:.0f}℉'.encode('UTF8').format(current_forecast.apparentTemperature) | |
print u'Wind {} mph'.format(current_forecast.windSpeed) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment