From 563e6ddf01721a4f16c87441d478fda7c46c0e76 Mon Sep 17 00:00:00 2001 From: Artyom Belousov Date: Wed, 3 Feb 2021 20:55:20 +0300 Subject: [PATCH] Fixed bug when card was on sale --- internal/cardsinfo/prices.go | 32 +------------------------------- 1 file changed, 1 insertion(+), 31 deletions(-) diff --git a/internal/cardsinfo/prices.go b/internal/cardsinfo/prices.go index 9a96aa2..541f06a 100644 --- a/internal/cardsinfo/prices.go +++ b/internal/cardsinfo/prices.go @@ -1,11 +1,9 @@ package cardsinfo import ( - "context" "fmt" "net/url" - scryfall "github.com/BlueMonday/go-scryfall" "github.com/antchfx/htmlquery" "github.com/pkg/errors" ) @@ -46,7 +44,7 @@ func GetPricesScg(name string) ([]CardPrice, error) { if editionNode.FirstChild != nil { price.Edition = editionNode.FirstChild.Data } - priceNode := htmlquery.FindOne(block, "//div[contains(concat(' ',normalize-space(@class),' '),' hawk-results-item__options-table-cell--price ')]") + priceNode := htmlquery.FindOne(block, "//span[@class='hawk-old-price']|//div[contains(concat(' ',normalize-space(@class),' '),' hawk-results-item__options-table-cell--price ')]") if priceNode.FirstChild != nil { price.Price = priceNode.FirstChild.Data } @@ -54,31 +52,3 @@ func GetPricesScg(name string) ([]CardPrice, error) { } return results, nil } - -func GetPricesTcg(name string) ([]CardPrice, error) { - client, err := scryfall.NewClient() - if err != nil { - return nil, errors.Wrap(err, "Cannot fetch prices") - } - ctx := context.Background() - opts := scryfall.SearchCardsOptions{ - Unique: scryfall.UniqueModePrints, - } - resp, err := client.SearchCards(ctx, fmt.Sprintf("!\"%v\"", name), opts) - var prices []CardPrice - for _, card := range resp.Cards { - edition := card.SetName + " #" + card.CollectorNumber - if card.Prices.USD == "" && card.Prices.USDFoil == "" { - continue - } - cardPrice := &TcgCardPrice{ - Edition: edition, - Price: card.Prices.USD, - PriceFoil: card.Prices.USDFoil, - Name: card.Name, - Link: card.PurchaseURIs.TCGPlayer, - } - prices = append(prices, cardPrice) - } - return prices, nil -}