From 08a4aafaf97cb4a9d1c8028cb0476fdd1e44bfd8 Mon Sep 17 00:00:00 2001 From: nite07 Date: Thu, 21 Nov 2024 00:59:17 +0800 Subject: [PATCH] auto append sufix to Config.CFClearanceScraper.Url --- config/config.go | 4 ++++ crawler/freegog.go | 4 ---- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/config/config.go b/config/config.go index 76406dc..833e720 100644 --- a/config/config.go +++ b/config/config.go @@ -100,6 +100,10 @@ func init() { Config.OnlineFixAvaliable = Config.OnlineFix.User != "" && Config.OnlineFix.Password != "" Config.RedisAvaliable = Config.Redis.Host != "" Config.DatabaseAvaliable = Config.Database.Database != "" && Config.Database.Host != "" + + if Config.CFClearanceScraper.Url != "" && !strings.HasSuffix(Config.CFClearanceScraper.Url, "/cf-clearance-scraper") { + Config.CFClearanceScraper.Url += "/cf-clearance-scraper" + } } func loadEnvVariables(cfg interface{}) { diff --git a/crawler/freegog.go b/crawler/freegog.go index bb6a112..bab5605 100644 --- a/crawler/freegog.go +++ b/crawler/freegog.go @@ -96,10 +96,6 @@ func (c *FreeGOGCrawler) Crawl(num int) ([]*model.GameItem, error) { } func (c *FreeGOGCrawler) CrawlByUrl(url string, session *utils.WAFSession) (*model.GameItem, error) { - var err error - if err != nil { - return nil, errors.New("Failed to create session") - } resp, err := utils.FetchWithWAFSession(utils.FetchConfig{ Url: url, }, session)