Skip to content

Commit 6841707

Browse files
author
unknown
committed
Merge branch 'hotfix/icon_error_hotfix'
2 parents 657eb74 + 7602d4e commit 6841707

3 files changed

Lines changed: 17 additions & 23 deletions

File tree

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
![Downloads](https://img.shields.io/nuget/dt/console-weather?style=for-the-badge&logo=nuget)
77
![License](https://img.shields.io/github/license/pazurkota/console-weather?style=for-the-badge)
88

9-
Console Weather project is a simple application project to check weather in console. You can get it on project official [NuGet](https://www.nuget.org/packages/console-weather/) page
9+
Console Weather project is a simple application project to check weather in console. You can get it on [NuGet](https://www.nuget.org/packages/console-weather/) page
1010

1111

1212

@@ -27,7 +27,7 @@ Console Weather project is a simple application project to check weather in cons
2727

2828
If you installed [.NET 7.0 or newer](https://dotnet.microsoft.com/en-us/download), just simply paste this command into console:
2929
```console
30-
$ dotnet tool install --global console-weather --version 1.6.0
30+
$ dotnet tool install --global console-weather --version 1.6.1
3131
```
3232

3333
If you want to update, just type:

console-weather/Icons/IconsHandler.cs

Lines changed: 13 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,27 @@
1-
using console_weather.API;
1+
using System.Net;
2+
using console_weather.API;
23

34
namespace console_weather.Icons;
45

56
public static class IconsHandler {
6-
private static readonly string DayIconsPath = @"Icons\Day\";
7-
private static readonly string NightIconsPath = @"Icons\Night\";
7+
// icons
8+
private static readonly string DayIconsUrl = "https://raw.githubusercontent.com/pazurkota/console-weather/master/console-weather/Icons/day/";
9+
private static readonly string NightIconsUrl = "https://raw.githubusercontent.com/pazurkota/console-weather/master/console-weather/Icons/night/";
810

11+
// data
912
private static readonly int IsDay = ApiData.ParseData().Current.IsDay;
10-
private static readonly int ConditionCole = ApiData.ParseData().Current.Condition.ConditionCode;
13+
private static readonly int ConditionCode = ApiData.ParseData().Current.Condition.ConditionCode;
1114

1215
public static string GetIcon() {
13-
var icon = IsDay == 1 ? GetDayIcon() : GetNightIcon();
14-
var iconContent = File.ReadAllText(icon);
16+
var iconsUrl = IsDay == 1 ? DayIconsUrl : NightIconsUrl;
17+
var icon = GetIconFromUrl(iconsUrl + GetConditionCode()[ConditionCode] + ".txt");
1518

16-
return iconContent;
17-
}
18-
19-
private static string GetDayIcon() {
20-
var dayIcons = Directory.GetFiles(DayIconsPath);
21-
var conditionCode = GetConditionCode()[ConditionCole];
22-
var icon = dayIcons.FirstOrDefault(icon => icon.Contains(conditionCode));
23-
2419
return icon;
2520
}
26-
27-
private static string GetNightIcon() {
28-
var nightIcons = Directory.GetFiles(NightIconsPath);
29-
var conditionCode = GetConditionCode()[ConditionCole];
30-
var icon = nightIcons.FirstOrDefault(icon => icon.Contains(conditionCode));
21+
22+
private static string GetIconFromUrl(string url) {
23+
var client = new WebClient();
24+
var icon = client.DownloadString(url);
3125

3226
return icon;
3327
}

console-weather/console-weather.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@
1515
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1616
<PackageProjectUrl>https://github.com/pazurkota/console-weather</PackageProjectUrl>
1717
<Description>Simple CLI App to check weather in C#</Description>
18-
<PackageVersion>1.6</PackageVersion>
19-
<VersionPrefix>1.6</VersionPrefix>
18+
<PackageVersion>1.6.1</PackageVersion>
19+
<VersionPrefix>1.6.1</VersionPrefix>
2020
<Title>Console Weather</Title>
2121
<Copyright>Copyright (c) 2023 pazurk0ta</Copyright>
2222
<RepositoryUrl>https://github.com/pazurkota/console-weather</RepositoryUrl>

0 commit comments

Comments
 (0)