remove sentry and move to slog
This commit is contained in:
parent
a20bc22ab1
commit
5d2b8f39d9
18 changed files with 134 additions and 232 deletions
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"log"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
@ -15,15 +15,17 @@ type EpicStruct struct {
|
|||
idPrefix string
|
||||
headers map[string]string
|
||||
deals DealsMap
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func NewEpicApi() EpicStruct {
|
||||
func NewEpicApi(logger *slog.Logger) EpicStruct {
|
||||
epic := EpicStruct{
|
||||
url: "https://store-site-backend-static-ipv4.ak.epicgames.com/freeGamesPromotions",
|
||||
baseUrl: "https://store.epicgames.com/p/",
|
||||
idPrefix: "epic-",
|
||||
headers: make(map[string]string),
|
||||
deals: make(map[string]Deal),
|
||||
logger: logger,
|
||||
}
|
||||
epic.headers["Accept-Language"] = "en"
|
||||
epic.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0"
|
||||
|
@ -113,7 +115,7 @@ func (e EpicStruct) Load() error {
|
|||
productSlug = element.OfferMappings[0].PageSlug
|
||||
}
|
||||
if productSlug == "" {
|
||||
log.Printf("ERROR: product slug not found for: %v", element.Title)
|
||||
e.logger.Error("product slug not found", slog.String("title", element.Title))
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@ package api
|
|||
import (
|
||||
"fmt"
|
||||
"golang.org/x/net/html"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
|
@ -13,15 +14,17 @@ type GogStruct struct {
|
|||
idPrefix string
|
||||
headers map[string]string
|
||||
deals DealsMap
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func NewGogApi() GogStruct {
|
||||
func NewGogApi(logger *slog.Logger) GogStruct {
|
||||
gog := GogStruct{
|
||||
url: "https://www.gog.com/en/games?priceRange=0,0&discounted=true",
|
||||
baseUrl: "https://www.gog.com/game/",
|
||||
idPrefix: "gog-",
|
||||
headers: make(map[string]string),
|
||||
deals: make(map[string]Deal),
|
||||
logger: logger,
|
||||
}
|
||||
gog.headers["Accept-Language"] = "en"
|
||||
gog.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0"
|
||||
|
|
|
@ -3,6 +3,7 @@ package api
|
|||
import (
|
||||
"fmt"
|
||||
"golang.org/x/net/html"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
|
@ -13,15 +14,17 @@ type GogFrontStruct struct {
|
|||
idPrefix string
|
||||
headers map[string]string
|
||||
deals DealsMap
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func NewGogFrontApi() GogFrontStruct {
|
||||
func NewGogFrontApi(logger *slog.Logger) GogFrontStruct {
|
||||
gog := GogFrontStruct{
|
||||
url: "https://www.gog.com/",
|
||||
baseUrl: "https://www.gog.com/game/",
|
||||
idPrefix: "gog-",
|
||||
headers: make(map[string]string),
|
||||
deals: make(map[string]Deal),
|
||||
logger: logger,
|
||||
}
|
||||
gog.headers["Accept-Language"] = "en"
|
||||
gog.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0"
|
||||
|
|
|
@ -4,6 +4,7 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"golang.org/x/net/html"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
|
@ -14,15 +15,17 @@ type HumbleBundleStruct struct {
|
|||
idPrefix string
|
||||
headers map[string]string
|
||||
deals DealsMap
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func NewHumbleBundleApi() HumbleBundleStruct {
|
||||
func NewHumbleBundleApi(logger *slog.Logger) HumbleBundleStruct {
|
||||
humbleBundle := HumbleBundleStruct{
|
||||
url: "https://www.humblebundle.com/",
|
||||
baseUrl: "https://www.humblebundle.com/store/",
|
||||
idPrefix: "humblebundle-",
|
||||
headers: make(map[string]string),
|
||||
deals: make(map[string]Deal),
|
||||
logger: logger,
|
||||
}
|
||||
humbleBundle.headers["Accept-Language"] = "en"
|
||||
humbleBundle.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0"
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"fmt"
|
||||
"golang.org/x/net/html"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
|
@ -16,9 +17,10 @@ type SteamStruct struct {
|
|||
idPrefix string
|
||||
headers map[string]string
|
||||
deals DealsMap
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func NewSteamApi() SteamStruct {
|
||||
func NewSteamApi(logger *slog.Logger) SteamStruct {
|
||||
steam := SteamStruct{
|
||||
url: "https://store.steampowered.com/search/results?force_infinite=1&maxprice=free&specials=1",
|
||||
baseUrl: "https://store.steampowered.com/app/",
|
||||
|
@ -26,6 +28,7 @@ func NewSteamApi() SteamStruct {
|
|||
idPrefix: "steam-",
|
||||
headers: make(map[string]string),
|
||||
deals: make(map[string]Deal),
|
||||
logger: logger,
|
||||
}
|
||||
steam.headers["Accept-Language"] = "en"
|
||||
steam.headers["User-Agent"] = "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:93.0) Gecko/20100101 Firefox/93.0"
|
||||
|
|
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
"regexp"
|
||||
)
|
||||
|
@ -14,14 +15,16 @@ type UbisoftStruct struct {
|
|||
idPrefix string
|
||||
headers map[string]string
|
||||
deals DealsMap
|
||||
logger *slog.Logger
|
||||
}
|
||||
|
||||
func NewUbsioftApi() UbisoftStruct {
|
||||
func NewUbsioftApi(logger *slog.Logger) UbisoftStruct {
|
||||
ubisoft := UbisoftStruct{
|
||||
url: "https://free.ubisoft.com/configuration.js",
|
||||
idPrefix: "ubisoft-",
|
||||
headers: make(map[string]string),
|
||||
deals: make(map[string]Deal),
|
||||
logger: logger,
|
||||
}
|
||||
ubisoft.headers["referer"] = "https://free.ubisoft.com/"
|
||||
ubisoft.headers["origin"] = "https://free.ubisoft.com"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue