Skip to content

Commit

Permalink
cardkingdom: Store all retail entries to save the URL
Browse files Browse the repository at this point in the history
  • Loading branch information
kodawah committed Apr 11, 2024
1 parent bf53827 commit 5bf6ee7
Showing 1 changed file with 23 additions and 15 deletions.
38 changes: 23 additions & 15 deletions cardkingdom/cardkingdom.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,30 +128,38 @@ func (ck *Cardkingdom) scrape() error {
if err != nil {
ck.printf("%v", err)
}
if card.SellQuantity > 0 && sellPrice > 0 {
u.Path = card.URL
if ck.Partner != "" {
q := u.Query()
q.Set("partner", ck.Partner)
q.Set("utm_source", ck.Partner)
q.Set("utm_medium", "affiliate")
q.Set("utm_campaign", ck.Partner)
u.RawQuery = q.Encode()
}

u.Path = card.URL
if ck.Partner != "" {
q := u.Query()
q.Set("partner", ck.Partner)
q.Set("utm_source", ck.Partner)
q.Set("utm_medium", "affiliate")
q.Set("utm_campaign", ck.Partner)
u.RawQuery = q.Encode()
}
link := u.String()

if card.SellQuantity > 0 && sellPrice > 0 {
details := parseConditions(card.ConditionValues, sellPrice)
for _, detail := range details {
out := &mtgban.InventoryEntry{
Conditions: detail.condition,
Price: detail.price,
Quantity: detail.quantity,
URL: u.String(),
}
err = ck.inventory.AddStrict(cardId, out)
if err != nil {
ck.printf("%v", err)
URL: link,
}
err = ck.inventory.AddUnique(cardId, out)
}
} else {
// Only save URL information
out := &mtgban.InventoryEntry{
URL: link,
}
err = ck.inventory.AddUnique(cardId, out)
}
if err != nil {
ck.printf("%v", err)
}

u, _ = url.Parse("https://www.cardkingdom.com/purchasing/mtg_singles")
Expand Down

0 comments on commit 5bf6ee7

Please sign in to comment.