trim spaces from titles

This commit is contained in:
Seraphim Strub 2024-05-29 21:37:48 +00:00
parent 1d5c7056be
commit 0b97f282e2
6 changed files with 12 additions and 6 deletions

View file

@ -6,6 +6,7 @@ import (
"io" "io"
"log/slog" "log/slog"
"net/http" "net/http"
"strings"
"time" "time"
) )
@ -131,7 +132,7 @@ func (e EpicStruct) Load() error {
} }
id := fmt.Sprintf("%v%v", e.idPrefix, element.Id) id := fmt.Sprintf("%v%v", e.idPrefix, element.Id)
title := element.Title title := strings.TrimSpace(element.Title)
url := fmt.Sprintf("%v%v", e.baseUrl, productSlug) url := fmt.Sprintf("%v%v", e.baseUrl, productSlug)
e.deals[id] = Deal{ e.deals[id] = Deal{

View file

@ -6,6 +6,7 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"regexp" "regexp"
"strings"
) )
type GogStruct struct { type GogStruct struct {
@ -125,7 +126,7 @@ func (e GogStruct) Load() error {
continue continue
} }
id := fmt.Sprintf("%v%v", e.idPrefix, appID) id := fmt.Sprintf("%v%v", e.idPrefix, appID)
title := bodyGame.Token().Data title := strings.TrimSpace(bodyGame.Token().Data)
url := fmt.Sprintf("%v%v", e.baseUrl, appID) url := fmt.Sprintf("%v%v", e.baseUrl, appID)
e.deals[id] = Deal{ e.deals[id] = Deal{

View file

@ -6,6 +6,7 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"regexp" "regexp"
"strings"
) )
type GogFrontStruct struct { type GogFrontStruct struct {
@ -125,7 +126,7 @@ func (e GogFrontStruct) Load() error {
continue continue
} }
id := fmt.Sprintf("%v%v", e.idPrefix, appID) id := fmt.Sprintf("%v%v", e.idPrefix, appID)
title := bodyGame.Token().Data title := strings.TrimSpace(bodyGame.Token().Data)
url := fmt.Sprintf("%v%v", e.baseUrl, appID) url := fmt.Sprintf("%v%v", e.baseUrl, appID)
e.deals[id] = Deal{ e.deals[id] = Deal{

View file

@ -7,6 +7,7 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"regexp" "regexp"
"strings"
) )
type HumbleBundleStruct struct { type HumbleBundleStruct struct {
@ -117,7 +118,7 @@ func (e HumbleBundleStruct) Load() error {
continue continue
} }
id := fmt.Sprintf("%v%v", e.idPrefix, appID[1]) id := fmt.Sprintf("%v%v", e.idPrefix, appID[1])
title := product.TileName title := strings.TrimSpace(product.TileName)
url := fmt.Sprintf("%v%v", e.baseUrl, appID[1]) url := fmt.Sprintf("%v%v", e.baseUrl, appID[1])
e.deals[id] = Deal{ e.deals[id] = Deal{

View file

@ -8,6 +8,7 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"regexp" "regexp"
"strings"
) )
type SteamStruct struct { type SteamStruct struct {
@ -139,7 +140,7 @@ func (e SteamStruct) Load() error {
continue continue
} }
id := fmt.Sprintf("%v%v", e.idPrefix, appID) id := fmt.Sprintf("%v%v", e.idPrefix, appID)
title := game.Data.Name title := strings.TrimSpace(game.Data.Name)
url := fmt.Sprintf("%v%v", e.baseUrl, appID) url := fmt.Sprintf("%v%v", e.baseUrl, appID)
e.deals[id] = Deal{ e.deals[id] = Deal{

View file

@ -8,6 +8,7 @@ import (
"log/slog" "log/slog"
"net/http" "net/http"
"regexp" "regexp"
"strings"
) )
type UbisoftStruct struct { type UbisoftStruct struct {
@ -111,7 +112,7 @@ func (e UbisoftStruct) Load() error {
continue continue
} }
title := news.Title title := strings.TrimSpace(news.Title)
if len(news.Links) != 1 { if len(news.Links) != 1 {
return errors.New(fmt.Sprintf("lenght of links for %v is more or less then 1", news.Title)) return errors.New(fmt.Sprintf("lenght of links for %v is more or less then 1", news.Title))
} }