From 39a3603c8e756ab1a688730e048e030566d2d205 Mon Sep 17 00:00:00 2001 From: Elara6331 Date: Tue, 4 Jun 2024 15:00:42 -0700 Subject: [PATCH] Fix Nominatim geocoding --- .goreleaser.yaml | 1 + weather.go | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.goreleaser.yaml b/.goreleaser.yaml index bd8d9e0..8d98099 100644 --- a/.goreleaser.yaml +++ b/.goreleaser.yaml @@ -44,6 +44,7 @@ archives: - README.md - itd.toml - itd.service + allow_different_binary_count: true nfpms: - id: itd file_name_template: >- diff --git a/weather.go b/weather.go index 410d65f..d072bdc 100644 --- a/weather.go +++ b/weather.go @@ -155,10 +155,12 @@ func initWeather(ctx context.Context, wg WaitGroup, dev *infinitime.Device) erro func getLocation(ctx context.Context, loc string) (lat, lon float64, err error) { // Create request URL and perform GET request reqURL := fmt.Sprintf("https://nominatim.openstreetmap.org/search.php?q=%s&format=jsonv2", url.QueryEscape(loc)) + println(reqURL) req, err := http.NewRequestWithContext(ctx, http.MethodGet, reqURL, nil) if err != nil { return } + req.Header.Set("User-Agent", fmt.Sprintf("ITD/%s gitea.elara.ws/Elara6331/itd", strings.TrimSpace(version))) res, err := http.DefaultClient.Do(req) if err != nil { return @@ -210,7 +212,7 @@ func getWeather(ctx context.Context, lat, lon float64) (*METResponse, error) { } // Set identifying user agent as per NMI requirements - req.Header.Set("User-Agent", fmt.Sprintf("ITD/%s gitea.arsenm.dev/Arsen6331/itd", strings.TrimSpace(version))) + req.Header.Set("User-Agent", fmt.Sprintf("ITD/%s gitea.elara.ws/Elara6331/itd", strings.TrimSpace(version))) // Perform request res, err := http.DefaultClient.Do(req)