Add Scryfall image URL field to database
This commit is contained in:
parent
793fb28d38
commit
b61929a178
|
@ -1,5 +1,6 @@
|
||||||
penny_dreadful_downloader/legality_data/
|
penny_dreadful_downloader/legality_data/
|
||||||
a_scanner_dorkly/.venv/
|
a_scanner_dorkly/.venv/
|
||||||
scantap/images/
|
scantap/images/
|
||||||
|
sevenkeys/sevenkeys
|
||||||
MTG-Card-Identifier_v5.pdf
|
MTG-Card-Identifier_v5.pdf
|
||||||
info.txt
|
info.txt
|
||||||
|
|
|
@ -11,6 +11,7 @@ type CardPrinting struct {
|
||||||
IsFoil bool
|
IsFoil bool
|
||||||
IsPromo bool
|
IsPromo bool
|
||||||
CollectorNumber string
|
CollectorNumber string
|
||||||
|
ImageUrl string
|
||||||
Language string
|
Language string
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -22,8 +23,9 @@ func InsertCardPrinting(db *sql.DB, cardPrinting CardPrinting) error {
|
||||||
IsFoil,
|
IsFoil,
|
||||||
IsPromo,
|
IsPromo,
|
||||||
CollectorNumber,
|
CollectorNumber,
|
||||||
|
ImageUrl,
|
||||||
Language)
|
Language)
|
||||||
VALUES (?, ?, ?, ?, ?, ?, ?);`
|
VALUES (?, ?, ?, ?, ?, ?, ?, ?);`
|
||||||
|
|
||||||
insert, err := db.Prepare(query)
|
insert, err := db.Prepare(query)
|
||||||
defer insert.Close()
|
defer insert.Close()
|
||||||
|
@ -31,7 +33,7 @@ func InsertCardPrinting(db *sql.DB, cardPrinting CardPrinting) error {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
_, err = insert.Exec(cardPrinting.Id, cardPrinting.Name, cardPrinting.SetCode, cardPrinting.IsFoil, cardPrinting.IsPromo, cardPrinting.CollectorNumber, cardPrinting.Language)
|
_, err = insert.Exec(cardPrinting.Id, cardPrinting.Name, cardPrinting.SetCode, cardPrinting.IsFoil, cardPrinting.IsPromo, cardPrinting.CollectorNumber, cardPrinting.ImageUrl, cardPrinting.Language)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,6 +22,7 @@ CREATE TABLE IF NOT EXISTS CardPrinting (
|
||||||
IsFoil BOOLEAN NOT NULL,
|
IsFoil BOOLEAN NOT NULL,
|
||||||
IsPromo BOOLEAN NOT NULL,
|
IsPromo BOOLEAN NOT NULL,
|
||||||
CollectorNumber VARCHAR(10) NOT NULL,
|
CollectorNumber VARCHAR(10) NOT NULL,
|
||||||
|
ImageUrl VARCHAR(100) NOT NULL,
|
||||||
Language VARCHAR(3) NOT NULL
|
Language VARCHAR(3) NOT NULL
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
|
@ -1,13 +1,14 @@
|
||||||
package scryfall
|
package scryfall
|
||||||
|
|
||||||
type Card struct {
|
type Card struct {
|
||||||
Id string `json:"id"`
|
Id string `json:"id"`
|
||||||
Name string `json:"name"`
|
Name string `json:"name"`
|
||||||
Set string `json:"set"`
|
Set string `json:"set"`
|
||||||
Games []string `json:"games"`
|
Games []string `json:"games"`
|
||||||
Foil bool `json:"foil"`
|
Foil bool `json:"foil"`
|
||||||
NonFoil bool `json:"nonfoil"`
|
NonFoil bool `json:"nonfoil"`
|
||||||
Promo bool `json:"promo"`
|
Promo bool `json:"promo"`
|
||||||
CollectorNumber string `json:"collector_number"`
|
CollectorNumber string `json:"collector_number"`
|
||||||
Language string `json:"lang"`
|
ImageUris map[string]string `json:"image_uris"`
|
||||||
|
Language string `json:"lang"`
|
||||||
}
|
}
|
||||||
|
|
|
@ -124,6 +124,7 @@ func getCardPrintings(card scryfall.Card) []database.CardPrinting {
|
||||||
IsFoil: true,
|
IsFoil: true,
|
||||||
IsPromo: card.Promo,
|
IsPromo: card.Promo,
|
||||||
CollectorNumber: card.CollectorNumber,
|
CollectorNumber: card.CollectorNumber,
|
||||||
|
ImageUrl: card.ImageUris["png"],
|
||||||
Language: card.Language,
|
Language: card.Language,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue