From d4fe69d4fba76327d5d752ea10893acc4cc211b3 Mon Sep 17 00:00:00 2001 From: Dom Date: Tue, 13 Aug 2019 16:42:52 +0200 Subject: [PATCH] add function to access BNN lists --- fileActions.go | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) diff --git a/fileActions.go b/fileActions.go index b18e555..9c9035e 100644 --- a/fileActions.go +++ b/fileActions.go @@ -6,6 +6,7 @@ import ( "net/http" "time" + bnn "gitea.statsd.de/dom/goBnn" "golang.org/x/text/encoding/charmap" ) @@ -145,3 +146,37 @@ func RetrievePricelist(client *http.Client) ([]SpricelistEntry, error) { return priceList, nil } + +// RetrieveBnnlistPL - Downloads list PL and converts bnn list into an array +func RetrieveBnnlistPL(client *http.Client) (bnn.Bnn, error) { + // Download bnn + resp, err := client.Get("https://static.paxan.de/2016/PL.BNN") + if err != nil { + return bnn.Bnn{}, err + } + + b, err := bnn.ReadBnn(resp.Body) + if err != nil { + return bnn.Bnn{}, err + } + + return b, nil + +} + +// RetrieveBnnlistPLF - Downloads list PLF and converts bnn list into an array +func RetrieveBnnlistPLF(client *http.Client) (bnn.Bnn, error) { + // Download bnn + resp, err := client.Get("https://static.paxan.de/2016/PLF.BNN") + if err != nil { + return bnn.Bnn{}, err + } + + b, err := bnn.ReadBnn(resp.Body) + if err != nil { + return bnn.Bnn{}, err + } + + return b, nil + +}