mirror of
https://github.com/tym1116/BH3.git
synced 2025-12-15 16:04:44 +01:00
26 lines
644 B
C#
26 lines
644 B
C#
using SimpleJSON;
|
|
|
|
namespace MoleMole
|
|
{
|
|
public class WeatherInfoProvider_Wunderground : WeatherInfoProvider
|
|
{
|
|
protected override string GetUrl()
|
|
{
|
|
return "http://api.wunderground.com/api/a48bebc6f61128cf/conditions/q/autoip.json";
|
|
}
|
|
|
|
protected override WeatherInfo ParseWeatherInfo(string content)
|
|
{
|
|
WeatherInfo weatherInfo = new WeatherInfo();
|
|
JSONNode jSONNode = JSONNode.Parse(content);
|
|
if (jSONNode != null)
|
|
{
|
|
weatherInfo.weatherType = WeatherType.Sunny;
|
|
weatherInfo.temperature = jSONNode["current_observation"]["temp_c"].AsFloat;
|
|
}
|
|
weatherInfo.extraInfo = content;
|
|
return weatherInfo;
|
|
}
|
|
}
|
|
}
|