Skip to content

Instantly share code, notes, and snippets.

@robo-corg
Last active January 6, 2016 18:51
Show Gist options
  • Save robo-corg/7364895672bbf781de6c to your computer and use it in GitHub Desktop.
Save robo-corg/7364895672bbf781de6c to your computer and use it in GitHub Desktop.
forecast.io plugin for bitbar with fun emoji icons
#!/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