-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from 3rob3/dev.jw.weatherapi
Remove old weather api and replace with openweathermap
- Loading branch information
Showing
11 changed files
with
119 additions
and
481 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
using ImmichFrame.Models; | ||
using OpenWeatherMap; | ||
using OpenWeatherMap.Models; | ||
using System; | ||
using System.Net.Http; | ||
using System.Threading.Tasks; | ||
|
||
namespace ImmichFrame.Helpers | ||
{ | ||
public class WeatherHelper | ||
{ | ||
private static readonly OpenWeatherMapOptions Options = new OpenWeatherMapOptions | ||
{ | ||
ApiKey = Settings.CurrentSettings.WeatherApiKey, | ||
UnitSystem = Settings.CurrentSettings.UnitSystem, | ||
Language = Settings.CurrentSettings.Language, | ||
}; | ||
public static Task<WeatherInfo?> GetWeather() | ||
{ | ||
var settings = Settings.CurrentSettings; | ||
return GetWeather(settings.WeatherLat, settings.WeatherLong); | ||
} | ||
public static async Task<WeatherInfo?> GetWeather(double latitude, double longitude) | ||
{ | ||
try | ||
{ | ||
IOpenWeatherMapService openWeatherMapService = new OpenWeatherMapService(Options); | ||
var weatherInfo = await openWeatherMapService.GetCurrentWeatherAsync(latitude, longitude); | ||
|
||
return weatherInfo; | ||
} | ||
catch | ||
{ | ||
//do nothing and return null | ||
} | ||
|
||
return null; | ||
} | ||
} | ||
} |
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
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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
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
Oops, something went wrong.