Weather Info - SamRothCA/Today-Scripts GitHub Wiki

Via api.openweathermap.org and ruby. Running this requires ruby.

`weather.rb`: 
     `require "json"
     require 'net/http'
     url =  "http://api.openweathermap.org/data/2.5/weather?q=_enter your city a comma and your country here_"
     resp = Net::HTTP.get_response(URI.parse(url))
     data = resp.body
     hash = JSON.parse(data)
     weather = hash['weather'][0]['description']
     weather2 = hash['weather'][0]['main']
     puts "Weather: #{weather2}; #{weather}"
     puts ""
     base = hash['main']['temp']
     temp = (base-273.15)*1.8000+32
     temp = (temp*10).ceil/10.0
     lowBase = hash['main']['temp_min']
     low = (lowBase-273.15)*1.8000+32
     low = (low*10).ceil/10.0
     highBase = hash['main']['temp_max']
     high = (highBase-273.15)*1.8000+32
     high = (high*10).ceil/10.0
     puts "Temperature: #{temp} Fahrenheit, Low: #{low}, High: #{high}"`

Save that and copy the file url. Then put this in the TodayScripts edit box: ruby _insert your file url here_ Save and run to see the weather. Code by Demosthenes Amelius Locke