From 07e9a962d29c2ada3f142d7e338739f515a0e2bc Mon Sep 17 00:00:00 2001 From: Florian Baumann Date: Wed, 18 Oct 2023 14:39:02 +0200 Subject: [PATCH] Fix export --- src/serra/export.go | 9 ++++----- src/serra/scryfall.go | 38 +++++++++++++++++++------------------- src/serra/update.go | 2 +- 3 files changed, 24 insertions(+), 25 deletions(-) diff --git a/src/serra/export.go b/src/serra/export.go index 5cd1e82..b1c62f9 100644 --- a/src/serra/export.go +++ b/src/serra/export.go @@ -15,9 +15,9 @@ func init() { var exportCmd = &cobra.Command{ Use: "export", Short: "Export cards from your collection", - Long: `Search and show cards from your collection. -If you directly put a card as an argument, it will be displayed -otherwise you'll get a list of cards as a search result.`, + Long: `Export cards from your collection. + Your data. Your choice. + Supports multiple output formats depending on where you want to export your collection.`, SilenceErrors: true, RunE: func(cmd *cobra.Command, args []string) error { cardList := Cards(rarity, set, sortby, name, oracle, cardType, reserved, foil, 0, 0) @@ -37,8 +37,7 @@ func exportTCGPowertools(cards []Card) { // 260009,1,Totally Lost,Gatecrash,GD,English,true,true,,,1000, // 260009,1,Totally Lost,Gatecrash,NM,English,true,true,,,1000, - fmt.Println("idProduct,quantity,name,set,condition,language,isFoil,isPlayset,isSigned,isFirstEd,price,comment") for _, card := range cards { - fmt.Printf("%s,%d,%s,%s,EX,German,false,false,,,%.2f,,\n", card.CardmarketID, card.SerraCount, card.Name, card.SetName, card.getValue(false)) + fmt.Printf("%.0f,%d,%s,%s,EX,German,false,false,,,%.2f,\n", card.CardmarketID, card.SerraCount, card.Name, card.SetName, card.getValue(false)) } } diff --git a/src/serra/scryfall.go b/src/serra/scryfall.go index c1c0638..a9e040f 100644 --- a/src/serra/scryfall.go +++ b/src/serra/scryfall.go @@ -26,7 +26,7 @@ type Card struct { Booster bool `json:"booster"` BorderColor string `json:"border_color"` CardBackID string `json:"card_back_id"` - CardmarketID string `json:"cardmarket_id"` + CardmarketID float64 `json:"cardmarket_id"` Cmc float64 `json:"cmc"` CollectorNumber string `json:"collector_number"` ColorIdentity []string `json:"color_identity"` @@ -99,24 +99,24 @@ type Card struct { TcgplayerInfiniteArticles string `json:"tcgplayer_infinite_articles"` TcgplayerInfiniteDecks string `json:"tcgplayer_infinite_decks"` } `json:"related_uris"` - ReleasedAt string `json:"released_at"` - Reprint bool `json:"reprint"` - Reserved bool `json:"reserved"` - RulingsURI string `json:"rulings_uri"` - ScryfallSetURI string `json:"scryfall_set_uri"` - ScryfallURI string `json:"scryfall_uri"` - Set string `json:"set"` - SetID string `json:"set_id"` - SetName string `json:"set_name"` - SetSearchURI string `json:"set_search_uri"` - SetType string `json:"set_type"` - SetURI string `json:"set_uri"` - StorySpotlight bool `json:"story_spotlight"` - Textless bool `json:"textless"` - TCGPlayerID string `json:"tcgplayer_id"` - TypeLine string `json:"type_line"` - URI string `json:"uri"` - Variation bool `json:"variation"` + ReleasedAt string `json:"released_at"` + Reprint bool `json:"reprint"` + Reserved bool `json:"reserved"` + RulingsURI string `json:"rulings_uri"` + ScryfallSetURI string `json:"scryfall_set_uri"` + ScryfallURI string `json:"scryfall_uri"` + Set string `json:"set"` + SetID string `json:"set_id"` + SetName string `json:"set_name"` + SetSearchURI string `json:"set_search_uri"` + SetType string `json:"set_type"` + SetURI string `json:"set_uri"` + StorySpotlight bool `json:"story_spotlight"` + Textless bool `json:"textless"` + TCGPlayerID float64 `json:"tcgplayer_id"` + TypeLine string `json:"type_line"` + URI string `json:"uri"` + Variation bool `json:"variation"` } // Getter for currency specific value diff --git a/src/serra/update.go b/src/serra/update.go index 0d3af20..2b06b63 100644 --- a/src/serra/update.go +++ b/src/serra/update.go @@ -89,7 +89,7 @@ var updateCmd = &cobra.Command{ updatedCard.Prices.Date = primitive.NewDateTimeFromTime(time.Now()) update := bson.M{ - "$set": bson.M{"serra_updated": primitive.NewDateTimeFromTime(time.Now()), "prices": updatedCard.Prices, "cmc": updatedCard.Cmc, "cardmarket_id": updatedCard.CardmarketID, "tcgplayer_id": updatedCard.TCGPlayerID}, + "$set": bson.M{"serra_updated": primitive.NewDateTimeFromTime(time.Now()), "prices": updatedCard.Prices, "cmc": updatedCard.Cmc, "cardmarketid": updatedCard.CardmarketID, "tcgplayerid": updatedCard.TCGPlayerID}, "$push": bson.M{"serra_prices": updatedCard.Prices}, } coll.storageUpdate(bson.M{"_id": bson.M{"$eq": card.ID}}, update)